Skip to content

Commit f6d1469

Browse files
committed
Merge pull request #1040
2 parents bd7d227 + 4cba19a commit f6d1469

18 files changed

+181
-1
lines changed

php_phongo.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,6 +2149,8 @@ static mongoc_ssl_opt_t* php_phongo_make_ssl_opt(mongoc_uri_t* uri, zval* zoptio
21492149
} else if (php_array_existsc(zoptions, "capath")) {
21502150
PHONGO_SSL_OPTION_SWAP_STRING(ssl_opt->ca_dir, "capath");
21512151
any_ssl_option_set = true;
2152+
2153+
php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The \"capath\" context driver option is deprecated. Please use the \"ca_dir\" driver option instead.");
21522154
}
21532155

21542156
if (php_array_existsc(zoptions, "crl_file")) {
@@ -2216,6 +2218,8 @@ static bool php_phongo_apply_driver_options_to_uri(mongoc_uri_t* uri, zval* zopt
22162218

22172219
return false;
22182220
}
2221+
2222+
php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The \"allow_invalid_hostname\" driver option is deprecated. Please use the \"tlsAllowInvalidHostnames\" URI option instead.");
22192223
}
22202224

22212225
if (php_array_existsc(zoptions, "weak_cert_validation")) {
@@ -2224,12 +2228,16 @@ static bool php_phongo_apply_driver_options_to_uri(mongoc_uri_t* uri, zval* zopt
22242228

22252229
return false;
22262230
}
2231+
2232+
php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The \"weak_cert_validation\" driver option is deprecated. Please use the \"tlsAllowInvalidCertificates\" URI option instead.");
22272233
} else if (php_array_existsc(zoptions, "allow_self_signed")) {
22282234
if (!mongoc_uri_set_option_as_bool(uri, MONGOC_URI_TLSALLOWINVALIDCERTIFICATES, php_array_fetchc_bool(zoptions, "allow_self_signed"))) {
22292235
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Failed to parse \"%s\" driver option", "allow_self_signed");
22302236

22312237
return false;
22322238
}
2239+
2240+
php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The \"allow_self_signed\" context driver option is deprecated. Please use the \"tlsAllowInvalidCertificates\" URI option instead.");
22332241
}
22342242

22352243
if (php_array_existsc(zoptions, "pem_file")) {
@@ -2238,12 +2246,16 @@ static bool php_phongo_apply_driver_options_to_uri(mongoc_uri_t* uri, zval* zopt
22382246

22392247
return false;
22402248
}
2249+
2250+
php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The \"pem_file\" driver option is deprecated. Please use the \"tlsCertificateKeyFile\" URI option instead.");
22412251
} else if (php_array_existsc(zoptions, "local_cert")) {
22422252
if (!php_phongo_apply_driver_option_to_uri(uri, zoptions, "local_cert", MONGOC_URI_TLSCERTIFICATEKEYFILE)) {
22432253
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Failed to parse \"%s\" driver option", "local_cert");
22442254

22452255
return false;
22462256
}
2257+
2258+
php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The \"local_cert\" context driver option is deprecated. Please use the \"tlsCertificateKeyFile\" URI option instead.");
22472259
}
22482260

22492261
if (php_array_existsc(zoptions, "pem_pwd")) {
@@ -2252,12 +2264,16 @@ static bool php_phongo_apply_driver_options_to_uri(mongoc_uri_t* uri, zval* zopt
22522264

22532265
return false;
22542266
}
2267+
2268+
php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The \"pem_pwd\" driver option is deprecated. Please use the \"tlsCertificateKeyFilePassword\" URI option instead.");
22552269
} else if (php_array_existsc(zoptions, "passphrase")) {
22562270
if (!php_phongo_apply_driver_option_to_uri(uri, zoptions, "passphrase", MONGOC_URI_TLSCERTIFICATEKEYFILEPASSWORD)) {
22572271
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Failed to parse \"%s\" driver option", "passphrase");
22582272

22592273
return false;
22602274
}
2275+
2276+
php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The \"passphrase\" context driver option is deprecated. Please use the \"tlsCertificateKeyFilePassword\" URI option instead.");
22612277
}
22622278

22632279
if (php_array_existsc(zoptions, "ca_file")) {
@@ -2266,12 +2282,16 @@ static bool php_phongo_apply_driver_options_to_uri(mongoc_uri_t* uri, zval* zopt
22662282

22672283
return false;
22682284
}
2285+
2286+
php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The \"ca_file\" driver option is deprecated. Please use the \"tlsCAFile\" URI option instead.");
22692287
} else if (php_array_existsc(zoptions, "cafile")) {
22702288
if (!php_phongo_apply_driver_option_to_uri(uri, zoptions, "cafile", MONGOC_URI_TLSCAFILE)) {
22712289
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Failed to parse \"%s\" driver option", "cafile");
22722290

22732291
return false;
22742292
}
2293+
2294+
php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The \"cafile\" context driver option is deprecated. Please use the \"tlsCAFile\" URI option instead.");
22752295
}
22762296

22772297
return true;

src/MongoDB/Manager.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ static bool php_phongo_manager_merge_context_options(zval* zdriverOptions TSRMLS
7979
return false;
8080
}
8181

82+
/* When running PHP in debug mode, php_error_docref duplicates the current
83+
* scope, leading to a COW violation in zend_hash_merge and
84+
* zend_symtable_str_del (called by php_array_unsetc). This macro allows
85+
* that violation in debug mode and is a NOOP when in non-debug. */
86+
#if PHP_VERSION_ID >= 70200
87+
HT_ALLOW_COW_VIOLATION(Z_ARRVAL_P(zdriverOptions));
88+
#endif
89+
90+
php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "The \"context\" driver option is deprecated.");
91+
8292
/* Perform array union (see: add_function() in zend_operators.c) */
8393
#if PHP_VERSION_ID >= 70000
8494
zend_hash_merge(Z_ARRVAL_P(zdriverOptions), Z_ARRVAL_P(zcontextOptions), zval_add_ref, 0);
@@ -90,6 +100,7 @@ static bool php_phongo_manager_merge_context_options(zval* zdriverOptions TSRMLS
90100
#endif
91101

92102
php_array_unsetc(zdriverOptions, "context");
103+
93104
return true;
94105
} /* }}} */
95106

tests/connect/bug0720.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ var_dump($cursor->toArray()[0]);
3030
===DONE===
3131
<?php exit(0); ?>
3232
--EXPECTF--
33+
Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_invalid_hostname" driver option is deprecated. Please use the "tlsAllowInvalidHostnames" URI option instead.%s
34+
35+
Deprecated: MongoDB\Driver\Manager::__construct(): The "ca_file" driver option is deprecated. Please use the "tlsCAFile" URI option instead.%s
3336
object(stdClass)#%d (%d) {
3437
["ok"]=>
3538
float(1)

tests/connect/standalone-ssl-no_verify-001.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ var_dump($cursor->toArray()[0]);
2121
===DONE===
2222
<?php exit(0); ?>
2323
--EXPECTF--
24+
Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_invalid_hostname" driver option is deprecated. Please use the "tlsAllowInvalidHostnames" URI option instead.%s
25+
26+
Deprecated: MongoDB\Driver\Manager::__construct(): The "weak_cert_validation" driver option is deprecated. Please use the "tlsAllowInvalidCertificates" URI option instead.%s
2427
object(stdClass)#%d (%d) {
2528
["ok"]=>
2629
float(1)

tests/connect/standalone-ssl-no_verify-002.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ var_dump($cursor->toArray()[0]);
2525
===DONE===
2626
<?php exit(0); ?>
2727
--EXPECTF--
28+
Deprecated: MongoDB\Driver\Manager::__construct(): The "context" driver option is deprecated.%s
29+
30+
Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_invalid_hostname" driver option is deprecated. Please use the "tlsAllowInvalidHostnames" URI option instead.%s
31+
32+
Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_self_signed" context driver option is deprecated. Please use the "tlsAllowInvalidCertificates" URI option instead.%s
2833
object(stdClass)#%d (%d) {
2934
["ok"]=>
3035
float(1)

tests/connect/standalone-ssl-verify_cert-001.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ var_dump($cursor->toArray()[0]);
2525
===DONE===
2626
<?php exit(0); ?>
2727
--EXPECTF--
28+
Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_invalid_hostname" driver option is deprecated. Please use the "tlsAllowInvalidHostnames" URI option instead.%s
29+
30+
Deprecated: MongoDB\Driver\Manager::__construct(): The "weak_cert_validation" driver option is deprecated. Please use the "tlsAllowInvalidCertificates" URI option instead.%s
31+
32+
Deprecated: MongoDB\Driver\Manager::__construct(): The "ca_file" driver option is deprecated. Please use the "tlsCAFile" URI option instead.%s
2833
object(stdClass)#%d (%d) {
2934
["ok"]=>
3035
float(1)

tests/connect/standalone-ssl-verify_cert-002.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ var_dump($cursor->toArray()[0]);
2929
===DONE===
3030
<?php exit(0); ?>
3131
--EXPECTF--
32+
Deprecated: MongoDB\Driver\Manager::__construct(): The "context" driver option is deprecated.%s
33+
34+
Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_invalid_hostname" driver option is deprecated. Please use the "tlsAllowInvalidHostnames" URI option instead.%s
35+
36+
Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_self_signed" context driver option is deprecated. Please use the "tlsAllowInvalidCertificates" URI option instead.%s
37+
38+
Deprecated: MongoDB\Driver\Manager::__construct(): The "cafile" context driver option is deprecated. Please use the "tlsCAFile" URI option instead.%s
3239
object(stdClass)#%d (%d) {
3340
["ok"]=>
3441
float(1)

tests/connect/standalone-ssl-verify_cert-error-001.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ echo throws(function() use ($driverOptions) {
2424
===DONE===
2525
<?php exit(0); ?>
2626
--EXPECTF--
27+
Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_invalid_hostname" driver option is deprecated. Please use the "tlsAllowInvalidHostnames" URI option instead.%s
28+
29+
Deprecated: MongoDB\Driver\Manager::__construct(): The "weak_cert_validation" driver option is deprecated. Please use the "tlsAllowInvalidCertificates" URI option instead.%s
2730
OK: Got MongoDB\Driver\Exception\ConnectionTimeoutException thrown from executeCommand
2831
No suitable servers found (`serverSelectionTryOnce` set): [%s calling ismaster on '%s:%d']
2932
===DONE===

tests/connect/standalone-ssl-verify_cert-error-002.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ echo throws(function() use ($driverOptions) {
2828
===DONE===
2929
<?php exit(0); ?>
3030
--EXPECTF--
31+
Deprecated: MongoDB\Driver\Manager::__construct(): The "context" driver option is deprecated.%s
32+
33+
Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_invalid_hostname" driver option is deprecated. Please use the "tlsAllowInvalidHostnames" URI option instead.%s
34+
35+
Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_self_signed" context driver option is deprecated. Please use the "tlsAllowInvalidCertificates" URI option instead.%s
3136
OK: Got MongoDB\Driver\Exception\ConnectionTimeoutException thrown from executeCommand
3237
No suitable servers found (`serverSelectionTryOnce` set): [%s calling ismaster on '%s:%d']
3338
===DONE===

tests/manager/bug0572.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ var_dump($cursor->toArray()[0]);
2727
===DONE===
2828
<?php exit(0); ?>
2929
--EXPECTF--
30+
Deprecated: MongoDB\Driver\Manager::__construct(): The "context" driver option is deprecated.%s
31+
32+
Deprecated: MongoDB\Driver\Manager::__construct(): The "allow_self_signed" context driver option is deprecated. Please use the "tlsAllowInvalidCertificates" URI option instead.%s
3033
object(stdClass)#%d (%d) {
3134
["ok"]=>
3235
float(1)

0 commit comments

Comments
 (0)