Skip to content

Commit 6149730

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

7 files changed

+57
-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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "
3232
<?php exit(0); ?>
3333
--EXPECTF--
3434
Testing primary:
35+
Deprecated: MongoDB\Driver\Manager::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
3536
is_primary: true
3637
is_secondary: false
3738

3839
Testing secondary:
40+
Deprecated: MongoDB\Driver\Manager::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
3941
is_primary: false
4042
is_secondary: true
4143

tests/manager/manager-executeQuery-004.phpt

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

4344
Testing secondary:
45+
Deprecated: MongoDB\Driver\Manager::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
4446
is_primary: false
4547
is_secondary: true
4648

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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ echo "is_secondary: ", $cursor->getServer()->isSecondary() ? 'true' : 'false', "
3535
<?php exit(0); ?>
3636
--EXPECTF--
3737
Testing primary:
38+
Deprecated: MongoDB\Driver\Server::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
3839
is_primary: true
3940
is_secondary: false
4041

4142
Testing secondary:
43+
Deprecated: MongoDB\Driver\Server::executeCommand(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
4244
is_primary: false
4345
is_secondary: true
4446

tests/server/server-executeQuery-010.phpt

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

4647
Testing secondary:
48+
Deprecated: MongoDB\Driver\Server::executeQuery(): Passing the "readPreference" option directly is deprecated and will be removed in ext-mongodb 2.0%s
4749
is_primary: false
4850
is_secondary: true
4951

0 commit comments

Comments
 (0)