Skip to content

Commit c673e0a

Browse files
committed
PHPC-704: Do not set mongodb.debug from driver options
The mongodb.debug INI option is a global setting and should not be set based on a single Manager's constructor argument.
1 parent 0fa2246 commit c673e0a

File tree

2 files changed

+7
-25
lines changed

2 files changed

+7
-25
lines changed

php_phongo.c

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,29 +1399,8 @@ static bool php_phongo_apply_ssl_opts(mongoc_client_t *client, zval *zdriverOpti
13991399

14001400
static mongoc_client_t *php_phongo_make_mongo_client(const mongoc_uri_t *uri, zval *driverOptions TSRMLS_DC) /* {{{ */
14011401
{
1402-
#if PHP_VERSION_ID >= 70000
1403-
zval *zdebug = NULL;
1404-
#else
1405-
zval **zdebug = NULL;
1406-
#endif
1407-
const char *mongoc_version, *bson_version;
1408-
mongoc_client_t *client;
1409-
1410-
#if PHP_VERSION_ID >= 70000
1411-
if (driverOptions && (zdebug = zend_hash_str_find(Z_ARRVAL_P(driverOptions), "debug", sizeof("debug")-1)) != NULL) {
1412-
zend_string *key = zend_string_init(PHONGO_DEBUG_INI, sizeof(PHONGO_DEBUG_INI)-1, 0);
1413-
zend_string *value_str = zval_get_string(zdebug);
1414-
zend_alter_ini_entry_ex(key, value_str, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0);
1415-
zend_string_release(key);
1416-
zend_string_release(value_str);
1417-
}
1418-
#else
1419-
if (driverOptions && zend_hash_find(Z_ARRVAL_P(driverOptions), "debug", strlen("debug") + 1, (void**)&zdebug) == SUCCESS) {
1420-
convert_to_string(*zdebug);
1421-
1422-
zend_alter_ini_entry_ex((char *)PHONGO_DEBUG_INI, sizeof(PHONGO_DEBUG_INI), Z_STRVAL_PP(zdebug), Z_STRLEN_PP(zdebug), PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
1423-
}
1424-
#endif
1402+
const char *mongoc_version, *bson_version;
1403+
mongoc_client_t *client;
14251404

14261405
#ifdef HAVE_SYSTEM_LIBMONGOC
14271406
mongoc_version = mongoc_get_version();

tests/manager/manager-debug-001.phpt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ require_once __DIR__ . "/../utils/basic.inc";
1010
$name = tempnam(sys_get_temp_dir(), "PHONGO");
1111
unlink($name);
1212
mkdir($name);
13-
$manager = new MongoDB\Driver\Manager(STANDALONE, array(), array("debug" => $name));
13+
ini_set('mongodb.debug', $name);
14+
$manager = new MongoDB\Driver\Manager(STANDALONE);
1415
$bulk = new MongoDB\Driver\BulkWrite();
1516
$bulk->insert(array('_id' => 1, 'x' => 1));
1617
$result = $manager->executeBulkWrite(NS, $bulk);
18+
ini_set('mongodb.debug', 'off');
1719
foreach(glob($name."/*") as $file);
1820
$content = file($file);
1921
unlink($file);
2022
rmdir($name);
2123

22-
echo $content[0];
24+
echo $content[0], $content[1];
2325
foreach($content as $line) {
2426
if (strpos($line, "mongoc_bulk_operation_execute")) {
2527
echo $line;
@@ -30,6 +32,7 @@ foreach($content as $line) {
3032
===DONE===
3133
<?php exit(0); ?>
3234
--EXPECTF--
35+
[%s] PHONGO: DEBUG > Connection string: '%s'
3336
[%s] PHONGO: DEBUG > Creating Manager, phongo-1.%d.%d%S[%s] - mongoc-1.%s(%s), libbson-1.%s(%s), php-%s
3437
[%s] mongoc: TRACE > ENTRY: mongoc_bulk_operation_execute():%d
3538
[%s] mongoc: TRACE > EXIT: mongoc_bulk_operation_execute():%d

0 commit comments

Comments
 (0)