Skip to content

Commit bc8208a

Browse files
committed
PHPC-2489: Deprecate passing WriteConcern and ReadPreference objects to execute methods
1 parent 2b2e0be commit bc8208a

7 files changed

+65
-0
lines changed

src/phongo_util.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ zval* php_phongo_prep_legacy_option(zval* options, const char* key, bool* alloca
9292
Z_ADDREF_P(options);
9393
*allocated = true;
9494

95+
php_error_docref(NULL, E_DEPRECATED, "Passing the \"%s\" option directly is deprecated and will be removed in ext-mongodb 2.0", key);
96+
9597
return new_options;
9698
}
9799

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
MongoDB\Driver\Manager::executeBulkWrite() explicit WriteConcern argument is deprecated
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_live(); ?>
6+
<?php skip_if_not_clean(); ?>
7+
--FILE--
8+
<?php
9+
10+
require_once __DIR__ . "/../utils/basic.inc";
11+
12+
$manager = create_test_manager();
13+
14+
$bulk = new MongoDB\Driver\BulkWrite();
15+
$bulk->insert(['_id' => 1]);
16+
$manager->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0));
17+
18+
?>
19+
===DONE===
20+
<?php exit(0); ?>
21+
--EXPECTF--
22+
Deprecated: MongoDB\Driver\Manager::executeBulkWrite(): Passing the "writeConcern" option directly is deprecated and will be removed in ext-mongodb 2.0%s
23+
===DONE===

tests/manager/manager-executeCommand-003.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "
3232
<?php exit(0); ?>
3333
--EXPECTF--
3434
Testing primary:
35+
36+
Deprecated: MongoDB\Driver\Manager::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
3537
is_primary: true
3638
is_secondary: false
3739

3840
Testing secondary:
41+
42+
Deprecated: MongoDB\Driver\Manager::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
3943
is_primary: false
4044
is_secondary: true
4145

tests/manager/manager-executeQuery-004.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "
3737
<?php exit(0); ?>
3838
--EXPECTF--
3939
Testing primary:
40+
41+
Deprecated: MongoDB\Driver\Manager::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
4042
is_primary: true
4143
is_secondary: false
4244

4345
Testing secondary:
46+
47+
Deprecated: MongoDB\Driver\Manager::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
4448
is_primary: false
4549
is_secondary: true
4650

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
MongoDB\Driver\Server::executeBulkWrite() explicit WriteConcern argument is deprecated
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_live(); ?>
6+
<?php skip_if_not_clean(); ?>
7+
--FILE--
8+
<?php
9+
10+
require_once __DIR__ . "/../utils/basic.inc";
11+
12+
$manager = create_test_manager();
13+
$server = $manager->selectServer();
14+
15+
$bulk = new MongoDB\Driver\BulkWrite();
16+
$bulk->insert(['_id' => 1]);
17+
$server->executeBulkWrite(NS, $bulk, new MongoDB\Driver\WriteConcern(0));
18+
19+
?>
20+
===DONE===
21+
<?php exit(0); ?>
22+
--EXPECTF--
23+
Deprecated: MongoDB\Driver\Server::executeBulkWrite(): Passing the "writeConcern" option directly is deprecated and will be removed in ext-mongodb 2.0%s
24+
===DONE===

tests/server/server-executeCommand-005.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "
3535
<?php exit(0); ?>
3636
--EXPECTF--
3737
Testing primary:
38+
39+
Deprecated: MongoDB\Driver\Server::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
3840
is_primary: true
3941
is_secondary: false
4042

4143
Testing secondary:
44+
45+
Deprecated: MongoDB\Driver\Server::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
4246
is_primary: false
4347
is_secondary: true
4448

tests/server/server-executeQuery-010.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,14 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "
4040
<?php exit(0); ?>
4141
--EXPECTF--
4242
Testing primary:
43+
44+
Deprecated: MongoDB\Driver\Server::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
4345
is_primary: true
4446
is_secondary: false
4547

4648
Testing secondary:
49+
50+
Deprecated: MongoDB\Driver\Server::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
4751
is_primary: false
4852
is_secondary: true
4953

0 commit comments

Comments
 (0)