Skip to content

Commit a207c77

Browse files
committed
Merged pull request #850
2 parents 177efe9 + b172a20 commit a207c77

27 files changed

+688
-78
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ matrix:
3232
- php: 7.0
3333
env:
3434
- SERVER_VERSION=3.4.11
35+
- php: 7.0
36+
env:
37+
- SERVER_VERSION=4.0.0-rc4
3538

3639
before_install:
3740
- pip install "mongo-orchestration>=0.6.7,<1.0" --user `whoami`

Vagrantfile

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -39,48 +39,5 @@ Vagrant.configure(2) do |config|
3939
ldap.vm.provision "shell", path: "scripts/centos/essentials.sh", privileged: true
4040
ldap.vm.provision "shell", path: "scripts/centos/ldap/install.sh", privileged: true
4141
end
42-
43-
config.vm.define "freebsd", autostart: false do |bsd|
44-
bsd.vm.network "private_network", ip: "192.168.112.30"
45-
46-
bsd.vm.box = "geoffgarside/freebsd-10.0"
47-
48-
bsd.vm.provision "shell", path: "scripts/freebsd/essentials.sh", privileged: true
49-
bsd.vm.provision "file", source: "/tmp/PHONGO-SERVERS.json", destination: "/tmp/PHONGO-SERVERS.json"
50-
bsd.vm.provision "file", source: "scripts/configs/.gdbinit", destination: "/home/vagrant/.gdbinit"
51-
bsd.vm.provision "shell", path: "scripts/freebsd/phongo.sh", privileged: true
52-
bsd.vm.synced_folder ".", "/phongo", :nfs => true, id: "vagrant-root"
53-
end
54-
55-
config.vm.define "precise64" do |linux|
56-
linux.vm.network "private_network", ip: "192.168.112.40"
57-
58-
linux.vm.box = "http://files.vagrantup.com/precise64.box"
59-
linux.vm.provider "vmware_workstation" do |vmware, override|
60-
override.vm.box_url = 'http://files.vagrantup.com/precise64_vmware.box'
61-
override.vm.provision "shell", path: "scripts/vmware/kernel.sh", privileged: true
62-
end
63-
64-
linux.vm.provision "shell", path: "scripts/ubuntu/essentials.sh", privileged: true
65-
linux.vm.provision "file", source: "/tmp/PHONGO-SERVERS.json", destination: "/tmp/PHONGO-SERVERS.json"
66-
linux.vm.provision "file", source: "scripts/configs/.gdbinit", destination: "/home/vagrant/.gdbinit"
67-
linux.vm.provision "shell", path: "scripts/ubuntu/phongo.sh", privileged: true
68-
end
69-
70-
config.vm.define "precise32" do |linux|
71-
linux.vm.network "private_network", ip: "192.168.112.50"
72-
73-
linux.vm.box = "bjori/precise32"
74-
linux.vm.provider "vmware_workstation" do |vmware, override|
75-
override.vm.box_url = "bjori/precise32"
76-
override.vm.provision "shell", path: "scripts/vmware/kernel.sh", privileged: true
77-
end
78-
79-
linux.vm.provision "shell", path: "scripts/ubuntu/essentials.sh", privileged: true
80-
linux.vm.provision "file", source: "/tmp/PHONGO-SERVERS.json", destination: "/tmp/PHONGO-SERVERS.json"
81-
linux.vm.provision "file", source: "scripts/configs/.gdbinit", destination: "/home/vagrant/.gdbinit"
82-
linux.vm.provision "shell", path: "scripts/ubuntu/phongo.sh", privileged: true
83-
end
84-
8542
end
8643

php_phongo.c

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,39 @@ void phongo_throw_exception(php_phongo_error_domain_t domain TSRMLS_DC, const ch
180180
efree(message);
181181
va_end(args);
182182
}
183+
183184
void phongo_throw_exception_from_bson_error_t(bson_error_t* error TSRMLS_DC)
184185
{
185186
zend_throw_exception(phongo_exception_from_mongoc_domain(error->domain, error->code), error->message, error->code TSRMLS_CC);
186187
}
187188

189+
void phongo_throw_exception_from_bson_error_and_reply_t(bson_error_t* error, bson_t* reply TSRMLS_DC)
190+
{
191+
/* Server errors (other than ExceededTimeLimit) and write concern errors
192+
* may use CommandException and report the result document for the
193+
* failed command. For BC, ExceededTimeLimit errors will continue to use
194+
* ExcecutionTimeoutException and omit the result document. */
195+
if ((error->domain == MONGOC_ERROR_SERVER && error->code != PHONGO_SERVER_ERROR_EXCEEDED_TIME_LIMIT) || error->domain == MONGOC_ERROR_WRITE_CONCERN) {
196+
#if PHP_VERSION_ID >= 70000
197+
zval zv;
198+
#else
199+
zval* zv;
200+
#endif
201+
202+
zend_throw_exception(php_phongo_commandexception_ce, error->message, error->code TSRMLS_CC);
203+
php_phongo_bson_to_zval(bson_get_data(reply), reply->len, &zv);
204+
205+
#if PHP_VERSION_ID >= 70000
206+
phongo_add_exception_prop(ZEND_STRL("resultDocument"), &zv);
207+
#else
208+
phongo_add_exception_prop(ZEND_STRL("resultDocument"), zv TSRMLS_CC);
209+
#endif
210+
zval_ptr_dtor(&zv);
211+
} else {
212+
phongo_throw_exception_from_bson_error_t(error TSRMLS_CC);
213+
}
214+
}
215+
188216
static void php_phongo_log(mongoc_log_level_t log_level, const char* log_domain, const char* message, void* user_data)
189217
{
190218
struct timeval tv;
@@ -927,29 +955,7 @@ bool phongo_execute_command(mongoc_client_t* client, php_phongo_command_type_t t
927955
free_reply = true;
928956

929957
if (!result) {
930-
/* Server errors (other than ExceededTimeLimit) and write concern errors
931-
* may use CommandException and report the result document for the
932-
* failed command. For BC, ExceededTimeLimit errors will continue to use
933-
* ExcecutionTimeoutException and omit the result document. */
934-
if ((error.domain == MONGOC_ERROR_SERVER && error.code != PHONGO_SERVER_ERROR_EXCEEDED_TIME_LIMIT) || error.domain == MONGOC_ERROR_WRITE_CONCERN) {
935-
#if PHP_VERSION_ID >= 70000
936-
zval zv;
937-
#else
938-
zval* zv;
939-
#endif
940-
941-
zend_throw_exception(php_phongo_commandexception_ce, error.message, error.code TSRMLS_CC);
942-
php_phongo_bson_to_zval(bson_get_data(&reply), reply.len, &zv);
943-
944-
#if PHP_VERSION_ID >= 70000
945-
phongo_add_exception_prop(ZEND_STRL("resultDocument"), &zv);
946-
#else
947-
phongo_add_exception_prop(ZEND_STRL("resultDocument"), zv TSRMLS_CC);
948-
#endif
949-
zval_ptr_dtor(&zv);
950-
} else {
951-
phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
952-
}
958+
phongo_throw_exception_from_bson_error_and_reply_t(&error, &reply TSRMLS_CC);
953959
goto cleanup;
954960
}
955961

php_phongo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ void phongo_throw_exception(php_phongo_error_domain_t domain TSRMLS
111111
#endif /* PHP_VERSION_ID < 70000 */
112112
;
113113
void phongo_throw_exception_from_bson_error_t(bson_error_t* error TSRMLS_DC);
114+
void phongo_throw_exception_from_bson_error_and_reply_t(bson_error_t* error, bson_t* reply TSRMLS_DC);
114115

115116
/* This enum is used for processing options in phongo_execute_parse_options and
116117
* selecting a libmongoc function to use in phongo_execute_command. The values

scripts/presets/replicaset-30.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"noprealloc": true,
1313
"nssize": 1,
1414
"port": 3100,
15+
"bind_ip": "0.0.0.0,::",
1516
"smallfiles": true,
1617
"setParameter": {"enableTestCommands": 1}
1718
},
@@ -34,6 +35,7 @@
3435
"noprealloc": true,
3536
"nssize": 1,
3637
"port": 3101,
38+
"bind_ip": "0.0.0.0,::",
3739
"smallfiles": true,
3840
"setParameter": {"enableTestCommands": 1}
3941
},
@@ -56,6 +58,7 @@
5658
"noprealloc": true,
5759
"nssize": 1,
5860
"port": 3102,
61+
"bind_ip": "0.0.0.0,::",
5962
"smallfiles": true,
6063
"setParameter": {"enableTestCommands": 1}
6164
},

scripts/presets/replicaset-dns.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"noprealloc": true,
1313
"nssize": 1,
1414
"port": 27017,
15+
"bind_ip_all": true,
1516
"smallfiles": true,
1617
"setParameter": {"enableTestCommands": 1}
1718
},
@@ -30,6 +31,7 @@
3031
"noprealloc": true,
3132
"nssize": 1,
3233
"port": 27018,
34+
"bind_ip_all": true,
3335
"smallfiles": true,
3436
"setParameter": {"enableTestCommands": 1}
3537
},
@@ -48,6 +50,7 @@
4850
"noprealloc": true,
4951
"nssize": 1,
5052
"port": 27019,
53+
"bind_ip_all": true,
5154
"smallfiles": true,
5255
"setParameter": {"enableTestCommands": 1}
5356
},

scripts/presets/replicaset.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"noprealloc": true,
1313
"nssize": 1,
1414
"port": 3000,
15+
"bind_ip_all": true,
1516
"smallfiles": true,
1617
"setParameter": {"enableTestCommands": 1}
1718
},
@@ -34,6 +35,7 @@
3435
"noprealloc": true,
3536
"nssize": 1,
3637
"port": 3001,
38+
"bind_ip_all": true,
3739
"smallfiles": true,
3840
"setParameter": {"enableTestCommands": 1}
3941
},
@@ -56,6 +58,7 @@
5658
"noprealloc": true,
5759
"nssize": 1,
5860
"port": 3002,
61+
"bind_ip_all": true,
5962
"smallfiles": true,
6063
"setParameter": {"enableTestCommands": 1}
6164
},

scripts/presets/standalone-30.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"logpath": "/tmp/standalone-30/mongod.log",
99
"journal": true,
1010
"port": 2700,
11+
"bind_ip": "0.0.0.0,::",
1112
"setParameter": {"enableTestCommands": 1}
1213
},
1314
"version": "30-release"

scripts/presets/standalone-auth.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"logpath": "/tmp/standalone-auth/m.log",
1212
"journal": true,
1313
"port": 2200,
14+
"bind_ip_all": true,
1415
"setParameter": {"enableTestCommands": 1}
1516
}
1617
}

scripts/presets/standalone-plain.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"logpath": "/tmp/standalone-plain/m.log",
1212
"journal": true,
1313
"port": 2400,
14-
"setParameter": {"enableTestCommands": 1, "saslauthdPath": "/var/run/saslauthd/mux", "authenticationMechanisms": "MONGODB-CR,PLAIN"}
14+
"bind_ip_all": true,
15+
"setParameter": {"enableTestCommands": 1, "saslauthdPath": "/var/run/saslauthd/mux", "authenticationMechanisms": "SCRAM-SHA-1,PLAIN"}
1516
}
1617
}
1718

0 commit comments

Comments
 (0)