mirror of
https://github.com/macintoshplus/mongo-php-driver.git
synced 2026-03-26 01:42:10 +01:00
This primarily fixes a bug introduced in6d46d62577for PHPC-359, since we convert tag sets from arrays to objects to ensure proper BSON serialization. Not only was the array mutation visible to calling contexts, but a crash could occur if the array was immutable due to OPcache. For Manager's $driverOptions, a comment in1060cb8ba4for PHPC-433 indicated that we should have separated its zval due to possible modification, but the appropriate zend_parse_parameters() flag was never used.
48 lines
816 B
PHP
48 lines
816 B
PHP
--TEST--
|
|
PHPC-851: ReadPreference constructor should not modify tagSets argument
|
|
--FILE--
|
|
<?php
|
|
|
|
$tagSets = [
|
|
['dc' => 'ny'],
|
|
[],
|
|
];
|
|
|
|
$rp = new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY_PREFERRED, $tagSets);
|
|
var_dump($tagSets);
|
|
|
|
/* Dump the Manager's ReadPreference to ensure that each element in the $tagSets
|
|
* argument was converted to an object. */
|
|
var_dump($rp);
|
|
|
|
?>
|
|
===DONE===
|
|
<?php exit(0); ?>
|
|
--EXPECTF--
|
|
array(2) {
|
|
[0]=>
|
|
array(1) {
|
|
["dc"]=>
|
|
string(2) "ny"
|
|
}
|
|
[1]=>
|
|
array(0) {
|
|
}
|
|
}
|
|
object(MongoDB\Driver\ReadPreference)#%d (%d) {
|
|
["mode"]=>
|
|
string(18) "secondaryPreferred"
|
|
["tags"]=>
|
|
array(2) {
|
|
[0]=>
|
|
object(stdClass)#%d (%d) {
|
|
["dc"]=>
|
|
string(2) "ny"
|
|
}
|
|
[1]=>
|
|
object(stdClass)#%d (%d) {
|
|
}
|
|
}
|
|
}
|
|
===DONE===
|