Skip to content

Commit 2543865

Browse files
authored
PHPC-2453: Deprecation notice for Query "modifiers" option (#1680)
1 parent 7da337f commit 2543865

10 files changed

+46
-6
lines changed

src/MongoDB/Query.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ bool phongo_query_init(zval* return_value, zval* filter, zval* options)
337337
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"modifiers\" option to be array, %s given", PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(modifiers));
338338
return false;
339339
}
340+
341+
php_error_docref(NULL, E_DEPRECATED, "The \"modifiers\" option is deprecated and will be removed in a future release");
340342
}
341343

342344
PHONGO_QUERY_OPT_BOOL("allowDiskUse", options, "allowDiskUse")

tests/query/query-ctor-003.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ var_dump(new MongoDB\Driver\Query(
3939
===DONE===
4040
<?php exit(0); ?>
4141
--EXPECTF--
42+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
43+
4244
Deprecated: MongoDB\Driver\Query::__construct(): The "$maxScan" option is deprecated and will be removed in a future release in %s on line %d
4345

4446
Deprecated: MongoDB\Driver\Query::__construct(): The "$snapshot" option is deprecated and will be removed in a future release in %s on line %d
@@ -81,6 +83,8 @@ object(MongoDB\Driver\Query)#%d (%d) {
8183
["readConcern"]=>
8284
NULL
8385
}
86+
87+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
8488
object(MongoDB\Driver\Query)#%d (%d) {
8589
["filter"]=>
8690
object(stdClass)#%d (%d) {
@@ -95,6 +99,8 @@ object(MongoDB\Driver\Query)#%d (%d) {
9599
["readConcern"]=>
96100
NULL
97101
}
102+
103+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
98104
object(MongoDB\Driver\Query)#%d (%d) {
99105
["filter"]=>
100106
object(stdClass)#%d (%d) {
@@ -109,6 +115,8 @@ object(MongoDB\Driver\Query)#%d (%d) {
109115
["readConcern"]=>
110116
NULL
111117
}
118+
119+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
112120
object(MongoDB\Driver\Query)#%d (%d) {
113121
["filter"]=>
114122
object(stdClass)#%d (%d) {

tests/query/query-ctor-004.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ var_dump(new MongoDB\Driver\Query(
4949
===DONE===
5050
<?php exit(0); ?>
5151
--EXPECTF--
52+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
53+
5254
Deprecated: MongoDB\Driver\Query::__construct(): The "maxScan" option is deprecated and will be removed in a future release in %s on line %d
5355

5456
Deprecated: MongoDB\Driver\Query::__construct(): The "snapshot" option is deprecated and will be removed in a future release in %s on line %d
@@ -91,6 +93,8 @@ object(MongoDB\Driver\Query)#%d (%d) {
9193
["readConcern"]=>
9294
NULL
9395
}
96+
97+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
9498
object(MongoDB\Driver\Query)#%d (%d) {
9599
["filter"]=>
96100
object(stdClass)#%d (%d) {
@@ -105,6 +109,8 @@ object(MongoDB\Driver\Query)#%d (%d) {
105109
["readConcern"]=>
106110
NULL
107111
}
112+
113+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
108114
object(MongoDB\Driver\Query)#%d (%d) {
109115
["filter"]=>
110116
object(stdClass)#%d (%d) {

tests/query/query-ctor_error-002.phpt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ foreach ($tests as $options) {
2828
?>
2929
===DONE===
3030
<?php exit(0); ?>
31-
--EXPECT--
31+
--EXPECTF--
3232
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
3333
Expected "modifiers" option to be array, int given
3434

@@ -50,15 +50,23 @@ Expected "projection" option to be array or object, int given
5050
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
5151
Expected "sort" option to be array or object, int given
5252

53+
54+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
5355
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
5456
Expected "$hint" modifier to be string, array, or object, int given
5557

58+
59+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
5660
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
5761
Expected "$max" modifier to be array or object, int given
5862

63+
64+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
5965
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
6066
Expected "$min" modifier to be array or object, int given
6167

68+
69+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
6270
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
6371
Expected "$orderby" modifier to be array or object, int given
6472

tests/query/query-ctor_error-004.phpt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ foreach ($tests as $test) {
3131
?>
3232
===DONE===
3333
<?php exit(0); ?>
34-
--EXPECT--
34+
--EXPECTF--
3535
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
3636
Cannot use empty keys in filter document
3737
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
@@ -48,12 +48,20 @@ OK: Got MongoDB\Driver\Exception\InvalidArgumentException
4848
Cannot use empty keys in "projection" option
4949
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
5050
Cannot use empty keys in "sort" option
51+
52+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
5153
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
5254
Cannot use empty keys in "$hint" modifier
55+
56+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
5357
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
5458
Cannot use empty keys in "$max" modifier
59+
60+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
5561
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
5662
Cannot use empty keys in "$min" modifier
63+
64+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
5765
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
5866
Cannot use empty keys in "$orderby" modifier
5967
===DONE===

tests/query/query-ctor_error-007.phpt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ foreach ($tests as $options) {
3030
?>
3131
===DONE===
3232
<?php exit(0); ?>
33-
--EXPECT--
33+
--EXPECTF--
3434
OK: Got MongoDB\Driver\Exception\UnexpectedValueException
3535
MongoDB\BSON\PackedArray cannot be serialized as a root document
3636
OK: Got MongoDB\Driver\Exception\UnexpectedValueException
@@ -45,10 +45,16 @@ OK: Got MongoDB\Driver\Exception\UnexpectedValueException
4545
MongoDB\BSON\PackedArray cannot be serialized as a root document
4646
OK: Got MongoDB\Driver\Exception\UnexpectedValueException
4747
MongoDB\BSON\PackedArray cannot be serialized as a root document
48+
49+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
4850
OK: Got MongoDB\Driver\Exception\UnexpectedValueException
4951
MongoDB\BSON\PackedArray cannot be serialized as a root document
52+
53+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
5054
OK: Got MongoDB\Driver\Exception\UnexpectedValueException
5155
MongoDB\BSON\PackedArray cannot be serialized as a root document
56+
57+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
5258
OK: Got MongoDB\Driver\Exception\UnexpectedValueException
5359
MongoDB\BSON\PackedArray cannot be serialized as a root document
5460
===DONE===

tests/query/query-debug-001.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var_dump(new MongoDB\Driver\Query(
2222
===DONE===
2323
<?php exit(0); ?>
2424
--EXPECTF--
25+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
2526
object(MongoDB\Driver\Query)#%d (%d) {
2627
["filter"]=>
2728
object(stdClass)#%d (%d) {

tests/query/query-debug-003.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ object(MongoDB\Driver\Query)#%d (%d) {
3232
["readConcern"]=>
3333
NULL
3434
}
35+
36+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
3537
object(MongoDB\Driver\Query)#%d (%d) {
3638
["filter"]=>
3739
object(stdClass)#%d (0) {

tests/server/server-executeQuery-003.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var_dump(iterator_to_array($cursor));
2929
===DONE===
3030
<?php exit(0); ?>
3131
--EXPECTF--
32+
Deprecated: MongoDB\Driver\Query::__construct(): The "modifiers" option is deprecated and will be removed in a future release in %s on line %d
3233
bool(true)
3334
bool(true)
3435
array(3) {

tests/standalone/executiontimeoutexception-001.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ $server = $manager->selectServer(new \MongoDB\Driver\ReadPreference('primary'));
1616
$query = new MongoDB\Driver\Query(array("company" => "Smith, Carter and Buckridge"), array(
1717
'projection' => array('_id' => 0, 'username' => 1),
1818
'sort' => array('phoneNumber' => 1),
19-
'modifiers' => array(
20-
'$maxTimeMS' => 1,
21-
),
19+
'maxTimeMS' => 1,
2220
));
2321

2422
failMaxTimeMS($server);

0 commit comments

Comments
 (0)