Skip to content

Commit 1e1b6f2

Browse files
Merge v1.20 into v1.x (#1689)
2 parents 5518255 + e19b31b commit 1e1b6f2

13 files changed

+75
-15
lines changed

.evergreen/config/build-variants.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ buildvariants:
6060
run_on: rhel80-small
6161
tasks:
6262
- name: "build-all-php"
63-
- name: build-rhel76
64-
display_name: "Build: RHEL 7.6"
65-
tags: ["build", "rhel", "x64", "pr", "tag"]
66-
run_on: rhel76-small
67-
tasks:
68-
- name: "build-all-php"
6963

7064
# Ubuntu LTS
7165
- name: build-ubuntu2204

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")

src/contrib/php_array_api.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,9 @@ char *php_array_zval_to_string(zval *z, int *plen, zend_bool *pfree) {
420420
* zval *php_array_fetchz_array(zval *zarr, zval *key)
421421
*/
422422
static inline zval *php_array_zval_to_array(zval *zarr) {
423-
return (zarr && (Z_TYPE_P(zarr) == IS_ARRAY)) ? zarr : NULL;
423+
if (!zarr) { return NULL; }
424+
ZVAL_DEREF(zarr);
425+
return Z_TYPE_P(zarr) == IS_ARRAY ? zarr : NULL;
424426
}
425427
PHP_ARRAY_FETCH_TYPE_MAP(zval*, array)
426428
#define php_array_fetchc_array(zarr, litstr) \
@@ -493,8 +495,10 @@ void *php_array_zval_to_resource(zval *z, int le) {
493495
*/
494496
static inline
495497
zval *php_array_zval_to_object(zval *z, zend_class_entry *ce) {
496-
return (z && (Z_TYPE_P(z) == IS_OBJECT) &&
497-
((!ce) || instanceof_function(Z_OBJCE_P(z), ce))) ? z : NULL;
498+
if (!z) { return NULL; }
499+
ZVAL_DEREF(z);
500+
if (Z_TYPE_P(z) != IS_OBJECT) { return NULL; }
501+
return (!ce) || instanceof_function(Z_OBJCE_P(z), ce) ? z : NULL;
498502
}
499503
#define php_array_fetch_object(zarr, key, ce) \
500504
php_array_zval_to_object(php_array_fetch(zarr, key), ce)

tests/bson/bug2456-001.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
PHPC-2456: References passed in a typeMap
3+
--FILE--
4+
<?php
5+
require_once __DIR__ . "/../utils/basic.inc";
6+
7+
$fieldPaths = [];
8+
9+
$typeMap = ['fieldPaths' => &$fieldPaths];
10+
11+
var_dump(MongoDB\BSON\Document::fromPHP([])->toPHP($typeMap));
12+
var_dump(MongoDB\BSON\PackedArray::fromPHP([])->toPHP($typeMap));
13+
14+
?>
15+
===DONE===
16+
<?php exit(0); ?>
17+
--EXPECTF--
18+
object(stdClass)#%d (0) {
19+
}
20+
array(0) {
21+
}
22+
===DONE===

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)