Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed PHP-813: Add deprecation notices to usage of Mongo. #443

Closed
wants to merge 1 commit into from

2 participants

@derickr
Owner

For the tests, I also swapped to using "MongoClient" by default and looked at
individual tests at what they were testing to decide whether to go with
"old_mongo" specifically or mongo/new_mongo() or equivalents. I guess some
choices could be debated though.

In one case (tests/generic/bug00635.phpt) I changed the expected output (beyond
deprecation notices), but this test was testing something unrelated to w=0/w=1.

@derickr derickr Fixed PHP-818: Add deprecation notices to usage of Mongo.
For the tests, I also swapped to using "MongoClient" by default and looked at
individual tests at what they were testing to decide whether to go with
"old_mongo" specifically or mongo/new_mongo() or equivalents. I guess some
choices could be debated though.

In one case (tests/generic/bug00635.phpt) I changed the expected output (beyond
deprecation notices), but this test was testing something unrelated to w=0/w=1.
a7e6ed0
@bjori
Owner

LGTM

@derickr derickr referenced this pull request from a commit
@derickr derickr Merged pull request #443 3e86166
@derickr derickr closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 9, 2013
  1. @derickr

    Fixed PHP-818: Add deprecation notices to usage of Mongo.

    derickr authored
    For the tests, I also swapped to using "MongoClient" by default and looked at
    individual tests at what they were testing to decide whether to go with
    "old_mongo" specifically or mongo/new_mongo() or equivalents. I guess some
    choices could be debated though.
    
    In one case (tests/generic/bug00635.phpt) I changed the expected output (beyond
    deprecation notices), but this test was testing something unrelated to w=0/w=1.
This page is out of date. Refresh to see the latest.
Showing with 190 additions and 62 deletions.
  1. +2 −1  mongo.c
  2. +5 −1 mongoclient.c
  3. +1 −1  tests/auth-replicaset/legacy/bug00397.phpt
  4. +2 −2 tests/generic/bug00394.phpt
  5. +3 −3 tests/generic/bug00413.phpt
  6. +2 −2 tests/generic/bug00466.phpt
  7. +1 −1  tests/generic/bug00543.phpt
  8. +8 −2 tests/generic/bug00585.phpt
  9. +2 −2 tests/generic/bug00635.phpt
  10. +1 −1  tests/generic/connection-with-auth-failure.phpt
  11. +10 −3 tests/generic/mongo_batch_insert.phpt
  12. +74 −0 tests/generic/mongo_batch_insert_old.phpt
  13. +1 −1  tests/generic/mongoclient-ctor-001.phpt
  14. +2 −2 tests/generic/mongoclient-ctor-readPref-001.phpt
  15. +4 −4 tests/no-servers/mongoclient-connection-string.phpt
  16. +1 −1  tests/no-servers/mongoclient-default-auth-db.phpt
  17. +1 −1  tests/replicaset/legacy/bug00266.phpt
  18. +1 −0  tests/replicaset/legacy/bug00487.phpt
  19. +2 −1  tests/replicaset/legacy/bug00500.phpt
  20. +1 −0  tests/replicaset/legacy/bug00569-001.phpt
  21. +19 −1 tests/replicaset/legacy/bug00605.phpt
  22. +2 −0  tests/replicaset/legacy/bug00639-005.phpt
  23. +1 −1  tests/replicaset/legacy/log-1.phpt
  24. +1 −1  tests/replicaset/legacy/log-1_alternative.phpt
  25. +1 −1  tests/replicaset/legacy/log-2.phpt
  26. +1 −1  tests/replicaset/legacy/log-3.phpt
  27. +3 −3 tests/replicaset/legacy/log-4.phpt
  28. +3 −3 tests/replicaset/legacy/mongoclient-ctor-002.phpt
  29. +1 −1  tests/replicaset/legacy/mongocollection-findandmodify-001-errors.phpt
  30. +1 −1  tests/replicaset/legacy/mongocollection-findone.phpt
  31. +4 −4 tests/standalone/legacy/bug00464.phpt
  32. +1 −1  tests/standalone/legacy/bug00489.phpt
  33. +2 −1  tests/standalone/legacy/bug00500.phpt
  34. +1 −0  tests/standalone/legacy/bug00569-001.phpt
  35. +12 −1 tests/standalone/legacy/bug00605.phpt
  36. +1 −1  tests/standalone/legacy/log-1.phpt
  37. +1 −1  tests/standalone/legacy/log-2.phpt
  38. +1 −1  tests/standalone/legacy/log-3.phpt
  39. +3 −3 tests/standalone/legacy/log-4.phpt
  40. +7 −7 tests/utils/server.inc
View
3  mongo.c
@@ -47,6 +47,8 @@ MONGO_ARGINFO_STATIC ZEND_BEGIN_ARG_INFO_EX(arginfo_setPoolSize, 0, ZEND_RETURN_
ZEND_END_ARG_INFO()
static zend_function_entry mongo_methods[] = {
+ /* Deprecated, but done through a check in php_mongoclient_new so that we
+ * can control the deprecation message */
PHP_ME(Mongo, __construct, arginfo___construct, ZEND_ACC_PUBLIC)
/* All these methods only exist in Mongo, and no longer in MongoClient */
@@ -66,7 +68,6 @@ static zend_function_entry mongo_methods[] = {
{ NULL, NULL, NULL }
};
-
void mongo_init_Mongo(TSRMLS_D)
{
zend_class_entry ce;
View
6 mongoclient.c
@@ -54,7 +54,7 @@ ZEND_EXTERN_MODULE_GLOBALS(mongo)
zend_class_entry *mongo_ce_MongoClient;
extern zend_class_entry *mongo_ce_DB, *mongo_ce_Cursor, *mongo_ce_Exception;
-extern zend_class_entry *mongo_ce_ConnectionException;
+extern zend_class_entry *mongo_ce_ConnectionException, *mongo_ce_Mongo;
MONGO_ARGINFO_STATIC ZEND_BEGIN_ARG_INFO_EX(arginfo___construct, 0, ZEND_RETURN_VALUE, 0)
ZEND_ARG_INFO(0, server)
@@ -223,6 +223,10 @@ zend_object_value php_mongoclient_new(zend_class_entry *class_type TSRMLS_DC)
zend_object_value retval;
mongoclient *intern;
+ if (class_type == mongo_ce_Mongo) {
+ php_error_docref(NULL TSRMLS_CC, MONGO_E_DEPRECATED, "The Mongo class is deprecated, please use the MongoClient class");
+ }
+
intern = (mongoclient*)emalloc(sizeof(mongoclient));
memset(intern, 0, sizeof(mongoclient));
View
2  tests/auth-replicaset/legacy/bug00397.phpt
@@ -15,7 +15,7 @@ $opts = array(
"password" => $creds["admin"]->password,
"replicaSet" => $cfg["rsname"],
);
-$m = new Mongo($cfg["dsn"], $opts+array("readPreference" => MongoClient::RP_SECONDARY_PREFERRED));
+$m = new MongoClient($cfg["dsn"], $opts+array("readPreference" => MongoClient::RP_SECONDARY_PREFERRED));
$db = $m->selectDB("phpunit-unit");
$c = $db->selectCollection("example");
View
4 tests/generic/bug00394.phpt
@@ -6,7 +6,7 @@ Test for PHP-394: Crashes and mem leaks.
<?php
require_once "tests/utils/server.inc";
-$x = new Mongo(array());
+$x = new MongoClient(array());
var_dump($x);
if ($x) {
$x->connect();
@@ -45,7 +45,7 @@ if ($x) {
?>
--EXPECTF--
-Warning: Mongo::__construct() expects parameter 1 to be string, array given in %s on line %d
+Warning: MongoClient::__construct() expects parameter 1 to be string, array given in %s on line %d
NULL
Warning: MongoDB::__construct() expects exactly 2 parameters, 0 given in %s on line %d
View
6 tests/generic/bug00413.phpt
@@ -12,21 +12,21 @@ $pass = "wrong password";
$db = dbname();
try {
- $m = new mongo(sprintf("mongodb://%s:%s@%s:%d/%s", "", $pass, $host, $port, $db));
+ $m = new MongoClient(sprintf("mongodb://%s:%s@%s:%d/%s", "", $pass, $host, $port, $db));
echo "got a MongoClient object\n";
$m->$db->collection->findOne();
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
try {
- $m = new mongo(sprintf("mongodb://%s:%s@%s:%d/%s", $user, "", $host, $port, $db));
+ $m = new MongoClient(sprintf("mongodb://%s:%s@%s:%d/%s", $user, "", $host, $port, $db));
echo "got a MongoClient object\n";
$m->$db->collection->findOne();
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
try {
- $m = new mongo(sprintf("mongodb://%s:%s@%s:%d/%s", $user . "bogus", $pass, $host, $port, $db));
+ $m = new MongoClient(sprintf("mongodb://%s:%s@%s:%d/%s", $user . "bogus", $pass, $host, $port, $db));
echo "got a MongoClient object\n";
$m->$db->collection->findOne();
} catch (Exception $e) {
View
4 tests/generic/bug00466.phpt
@@ -5,8 +5,8 @@ Test for PHP-466: Seed list of 1 replicaset member, and one standalone, with arr
MongoLog::setModule(MongoLog::ALL);
MongoLog::setLevel(MongoLog::ALL);
function foo($c, $m) { echo $m, "\n"; } set_error_handler('foo');
-$m = new Mongo("mongodb://whisky:13000", array( "connect" => false, "replicaSet" => true ));
-$m = new Mongo("mongodb://whisky:13000", array( "connect" => false, "replicaSet" => 'seta' ));
+$m = new MongoClient("mongodb://whisky:13000", array( "connect" => false, "replicaSet" => true ));
+$m = new MongoClient("mongodb://whisky:13000", array( "connect" => false, "replicaSet" => 'seta' ));
?>
--EXPECTF--
PARSE INFO: Parsing mongodb://whisky:13000
View
2  tests/generic/bug00543.phpt
@@ -11,7 +11,7 @@ var_dump($m->connect());
try
{
- $m = new Mongo("mongodb://totallynonsense/", array( 'connect' => false ) );
+ $m = new MongoClient("mongodb://totallynonsense/", array( 'connect' => false ) );
var_dump(@$m->connect());
}
catch ( Exception $e )
View
10 tests/generic/bug00585.phpt
@@ -11,16 +11,22 @@ var_dump(get_class($m));
$gridfs = $m->selectDb(dbname())->getGridFS();
var_dump($gridfs->w);
-
$m = mongo_standalone();
var_dump(get_class($m));
$gridfs = $m->selectDb(dbname())->getGridFS();
+var_dump($gridfs->w);
+$m = old_mongo_standalone();
+var_dump(get_class($m));
+$gridfs = $m->selectDb(dbname())->getGridFS();
var_dump($gridfs->w);
?>
--EXPECTF--
string(11) "MongoClient"
int(1)
-string(5) "Mongo"
+string(11) "MongoClient"
int(1)
+%s: %s(): The Mongo class is deprecated, please use the MongoClient class in %sserver.inc on line %d
+string(5) "Mongo"
+int(1)
View
4 tests/generic/bug00635.phpt
@@ -17,13 +17,13 @@ var_dump(is_object($collection));
--EXPECTF--
object(MongoCollection)#%d (%d) {
["w"]=>
- int(0)
+ int(1)
["wtimeout"]=>
int(10000)
}
object(MongoCollection)#%d (%d) {
["w"]=>
- int(0)
+ int(1)
["wtimeout"]=>
int(10000)
}
View
2  tests/generic/connection-with-auth-failure.phpt
@@ -12,7 +12,7 @@ try {
$pass = "failed password";
$db = dbname();
- $m = new mongo(sprintf("mongodb://%s:%s@%s:%d/%s", $user, $pass, $host, $port, $db));
+ $m = new MongoClient(sprintf("mongodb://%s:%s@%s:%d/%s", $user, $pass, $host, $port, $db));
echo "Have mongo client object\n";
$m->$db->collection->findOne();
} catch (Exception $e) {
View
13 tests/generic/mongo_batch_insert.phpt
@@ -1,11 +1,11 @@
--TEST--
-Test for PHP-233: support keep_going flag.
+Test for PHP-233: support keep_going (continueOnError) flag
--SKIPIF--
<?php require_once "tests/utils/standalone.inc"; ?>
--FILE--
<?php
require_once "tests/utils/server.inc";
-$db = new MongoDB(mongo_standalone(), "phpunit");
+$db = new MongoDB(new_mongo_standalone(), "phpunit");
$object = $db->selectCollection('c');
$object->drop();
@@ -30,7 +30,12 @@ $doc4 = array(
'desc' => "FOUR",
);
-$object->batchInsert(array($doc1, $doc2, $doc3, $doc4), array('continueOnError' => true));
+try {
+ $object->batchInsert(array($doc1, $doc2, $doc3, $doc4), array('continueOnError' => true));
+} catch (MongoException $e) {
+ echo $e->getCode(), "\n";
+ echo $e->getMessage(), "\n";
+}
$c = $object->find();
foreach ($c as $item) {
@@ -38,6 +43,8 @@ foreach ($c as $item) {
}
?>
--EXPECTF--
+11000
+%s:%d: E11000 duplicate key error index: %s.c.$_id_ dup key: { : ObjectId('4cb4ab6d7addf98506010002') }
array(3) {
["_id"]=>
object(MongoId)#%d (1) {
View
74 tests/generic/mongo_batch_insert_old.phpt
@@ -0,0 +1,74 @@
+--TEST--
+Test for PHP-233: support keep_going (continueOnError) flag (old)
+--SKIPIF--
+<?php require_once "tests/utils/standalone.inc"; ?>
+--FILE--
+<?php
+require_once "tests/utils/server.inc";
+$db = new MongoDB(old_mongo_standalone(), "phpunit");
+$object = $db->selectCollection('c');
+$object->drop();
+
+$doc1 = array(
+ '_id' => new MongoId('4cb4ab6d7addf98506010001'),
+ 'id' => 1,
+ 'desc' => "ONE",
+);
+$doc2 = array(
+ '_id' => new MongoId('4cb4ab6d7addf98506010002'),
+ 'id' => 2,
+ 'desc' => "TWO",
+);
+$doc3 = array(
+ '_id' => new MongoId('4cb4ab6d7addf98506010002'),
+ 'id' => 3,
+ 'desc' => "THREE",
+);
+$doc4 = array(
+ '_id' => new MongoId('4cb4ab6d7addf98506010004'),
+ 'id' => 4,
+ 'desc' => "FOUR",
+);
+
+$object->batchInsert(array($doc1, $doc2, $doc3, $doc4), array('continueOnError' => true));
+
+$c = $object->find();
+foreach ($c as $item) {
+ var_dump($item);
+}
+?>
+--EXPECTF--
+%s: %s(): The Mongo class is deprecated, please use the MongoClient class in %sserver.inc on line %d
+array(3) {
+ ["_id"]=>
+ object(MongoId)#%d (1) {
+ ["$id"]=>
+ string(24) "4cb4ab6d7addf98506010001"
+ }
+ ["id"]=>
+ int(1)
+ ["desc"]=>
+ string(3) "ONE"
+}
+array(3) {
+ ["_id"]=>
+ object(MongoId)#%d (1) {
+ ["$id"]=>
+ string(24) "4cb4ab6d7addf98506010002"
+ }
+ ["id"]=>
+ int(2)
+ ["desc"]=>
+ string(3) "TWO"
+}
+array(3) {
+ ["_id"]=>
+ object(MongoId)#%d (1) {
+ ["$id"]=>
+ string(24) "4cb4ab6d7addf98506010004"
+ }
+ ["id"]=>
+ int(4)
+ ["desc"]=>
+ string(4) "FOUR"
+}
View
2  tests/generic/mongoclient-ctor-001.phpt
@@ -16,7 +16,7 @@ $port = standalone_port();
ini_set("mongo.default_host", $host);
ini_set("mongo.default_port", $port);
-$m = new Mongo;
+$m = new MongoClient;
foreach($m->getHosts() as $s) {
if ($s["host"] == $host) {
echo "Connected to correct host\n";
View
4 tests/generic/mongoclient-ctor-readPref-001.phpt
@@ -21,7 +21,7 @@ $a = array(
);
foreach ($a as $value) {
- $m = new mongo($baseString . $value);
+ $m = new MongoClient($baseString . $value);
$rp = $m->getReadPreference();
echo $rp["type"], "\n";
}
@@ -41,6 +41,6 @@ nearest
Fatal error: Uncaught exception 'MongoConnectionException' with message 'The readPreference value 'nonsense' is not supported.' in %smongoclient-ctor-readPref-001.php:%d
Stack trace:
-#0 %smongoclient-ctor-readPref-001.php(%d): Mongo->__construct('%s')
+#0 %smongoclient-ctor-readPref-001.php(%d): MongoClient->__construct('%s')
#1 {main}
thrown in %smongoclient-ctor-readPref-001.php on line %d
View
8 tests/no-servers/mongoclient-connection-string.phpt
@@ -12,25 +12,25 @@ MongoLog::setLevel(MongoLog::ALL);
echo "First one\n";
try {
- $m = new Mongo("mongodb:///tmp/mongodb-27017.sock/?replicaSet=foo", array("connect" => 0));
+ $m = new MongoClient("mongodb:///tmp/mongodb-27017.sock/?replicaSet=foo", array("connect" => 0));
} catch(Exception $e) {}
echo "\nSecond one\n";
try {
- $m = new Mongo("mongodb:///tmp/mongodb-27017.sock/databasename?replicaSet=foo", array("connect" => 0));
+ $m = new MongoClient("mongodb:///tmp/mongodb-27017.sock/databasename?replicaSet=foo", array("connect" => 0));
} catch(Exception $e) {}
echo "\nThird one\n";
try {
- $m = new Mongo("mongodb:///tmp/mongodb-27017.sock", array("connect" => 0));
+ $m = new MongoClient("mongodb:///tmp/mongodb-27017.sock", array("connect" => 0));
} catch(Exception $e) {}
echo "\nForth one\n";
try {
- $m = new Mongo("mongodb:///tmp/mongodb-27017.sock/databasename", array("connect" => 0));
+ $m = new MongoClient("mongodb:///tmp/mongodb-27017.sock/databasename", array("connect" => 0));
} catch(Exception $e) {}
?>
--EXPECTF--
View
2  tests/no-servers/mongoclient-default-auth-db.phpt
@@ -21,7 +21,7 @@ $dsns = array(
foreach ($dsns as $dsn) {
echo $dsn, "\n";
- $m = new Mongo($dsn, array('connect' => false));
+ $m = new MongoClient($dsn, array('connect' => false));
echo "\n";
}
?>
View
2  tests/replicaset/legacy/bug00266.phpt
@@ -15,7 +15,7 @@ $host2 = hostname("STANDALONE");
$port2 = port("STANDALONE");
$ip2 = gethostbyname($host2);
-$m = new Mongo("$ip:$port,$ip2:$port2", array("replicaSet" => true));
+$m = new MongoClient("$ip:$port,$ip2:$port2", array("replicaSet" => true));
$coll = $m->selectCollection("phpunit","bug00266");
try {
$coll->getIndexInfo();
View
1  tests/replicaset/legacy/bug00487.phpt
@@ -25,6 +25,7 @@ $c->findOne();
?>
===DONE===
--EXPECTF--
+%s: %s(): The Mongo class is deprecated, please use the MongoClient class in %sbug00487.php on line %d
string(%d) "%s:%d: not master and slaveOk=false"
%s: Function Mongo::setSlaveOkay() is deprecated in %s on line %d
View
3  tests/replicaset/legacy/bug00500.phpt
@@ -6,7 +6,7 @@ Test for PHP-500: MongoCollection insert, update and remove no longer return boo
<?php
require_once "tests/utils/server.inc";
// Connect to mongo
-$m = mongo();
+$m = old_mongo();
$c = $m->selectCollection(dbname(), 'crash');
$c->drop();
@@ -35,6 +35,7 @@ var_dump( $c->update( array( '_id' => 'yeah' ), array( 'value' => array( '$set'
var_dump( $c->remove( array( '_id' => 'yeah' ), array( 'safe' => true ) ) );
?>
--EXPECTF--
+%s: %s(): The Mongo class is deprecated, please use the MongoClient class in %sserver.inc on line %d
bool(true)
bool(true)
bool(true)
View
1  tests/replicaset/legacy/bug00569-001.phpt
@@ -42,6 +42,7 @@ foreach ( $tests as $key => $test )
}
?>
--EXPECTF--
+%s(): The Mongo class is deprecated, please use the MongoClient class
IO FINE: is_gle_op: no
Running test 0, with options: []:
View
20 tests/replicaset/legacy/bug00605.phpt
@@ -27,7 +27,6 @@ var_dump( $c->insert( array( 'test' => 'two' ), array( 'w' => 0 ) ) );
var_dump( $c->insert( array( 'test' => 'two' ), array( 'w' => 1 ) ) );
?>
--EXPECTF--
-bool(true)
array(5) {
["n"]=>
int(0)
@@ -45,6 +44,25 @@ array(5) {
["ok"]=>
float(1)
}
+array(5) {
+ ["n"]=>
+ int(0)
+ ["lastOp"]=>
+ object(MongoTimestamp)#%d (2) {
+ ["sec"]=>
+ int(%d)
+ ["inc"]=>
+ int(%d)
+ }
+ ["connectionId"]=>
+ int(%d)
+ ["err"]=>
+ NULL
+ ["ok"]=>
+ float(1)
+}
+
+%s: %s: The Mongo class is deprecated, please use the MongoClient class in %sserver.inc on line %d
bool(true)
bool(true)
array(5) {
View
2  tests/replicaset/legacy/bug00639-005.phpt
@@ -48,6 +48,8 @@ $info = $cursor->info();
echo "connection type: ", $info['connection_type_desc'], "\n";
?>
--EXPECTF--
+%s: %s: The Mongo class is deprecated, please use the MongoClient class in %sserver.inc on line %d
+
Deprecated: Function Mongo::setSlaveOkay() is deprecated in %s
pick server: random element %d while ignoring the primary
- connection: type: SECONDARY, socket: %d, ping: %d, hash: %s
View
2  tests/replicaset/legacy/log-1.phpt
@@ -16,7 +16,7 @@ MongoLog::setModule(MongoLog::ALL);
MongoLog::setLevel(MongoLog::ALL);
$config = MongoShellServer::getReplicasetInfo();
-$m = new Mongo("mongodb://" . $config["hosts"][0], array("replicaSet" => $config["rsname"]));
+$m = new MongoClient("mongodb://" . $config["hosts"][0], array("replicaSet" => $config["rsname"]));
MongoLog::setModule(0);
MongoLog::setLevel(0);
View
2  tests/replicaset/legacy/log-1_alternative.phpt
@@ -15,7 +15,7 @@ set_error_handler('error_handler');
MongoLog::setModule(MongoLog::ALL);
MongoLog::setLevel(MongoLog::ALL);
$config = MongoShellServer::getReplicasetInfo();
-$m = new Mongo($config["hosts"][0] . "/?replicaSet=" . $config["rsname"]);
+$m = new MongoClient($config["hosts"][0] . "/?replicaSet=" . $config["rsname"]);
MongoLog::setModule(0);
MongoLog::setLevel(0);
?>
View
2  tests/replicaset/legacy/log-2.phpt
@@ -15,7 +15,7 @@ set_error_handler('error_handler');
MongoLog::setModule(MongoLog::CON);
MongoLog::setLevel(MongoLog::ALL);
$config = MongoShellServer::getReplicasetInfo();
-$m = new Mongo($config["hosts"][0], array("replicaSet" => $config["rsname"]));
+$m = new MongoClient($config["hosts"][0], array("replicaSet" => $config["rsname"]));
MongoLog::setModule(0);
MongoLog::setLevel(0);
?>
View
2  tests/replicaset/legacy/log-3.phpt
@@ -15,7 +15,7 @@ set_error_handler('error_handler');
MongoLog::setModule(MongoLog::PARSE);
MongoLog::setLevel(MongoLog::ALL);
$config = MongoShellServer::getReplicasetInfo();
-$m = new Mongo("mongodb://" . $config["hosts"][0], array("replicaSet" => $config["rsname"]));
+$m = new MongoClient("mongodb://" . $config["hosts"][0], array("replicaSet" => $config["rsname"]));
?>
--EXPECTF--
PARSE INFO: Parsing mongodb://%s:%d
View
6 tests/replicaset/legacy/log-4.phpt
@@ -16,17 +16,17 @@ set_error_handler('error_handler');
echo "Warnings:\n";
MongoLog::setModule(MongoLog::ALL);
MongoLog::setLevel(MongoLog::WARNING);
-$m = new Mongo($config["hosts"][0], array("replicaSet" => $config["rsname"]));
+$m = new MongoClient($config["hosts"][0], array("replicaSet" => $config["rsname"]));
echo "Fine:\n";
MongoLog::setModule(MongoLog::ALL);
MongoLog::setLevel(MongoLog::FINE);
-$m = new Mongo($config["hosts"][0], array("replicaSet" => $config["rsname"]));
+$m = new MongoClient($config["hosts"][0], array("replicaSet" => $config["rsname"]));
echo "Info:\n";
MongoLog::setModule(MongoLog::ALL);
MongoLog::setLevel(MongoLog::INFO);
-$m = new Mongo("mongodb://" . $config["hosts"][0], array("replicaSet" => $config["rsname"]));
+$m = new MongoClient("mongodb://" . $config["hosts"][0], array("replicaSet" => $config["rsname"]));
MongoLog::setModule(0);
MongoLog::setLevel(0);
?>
View
6 tests/replicaset/legacy/mongoclient-ctor-002.phpt
@@ -23,12 +23,12 @@ $opts = array(
"password" => array("else"),
"connect" => "0",
);
-$m = new Mongo(null, $opts);
+$m = new MongoClient(null, $opts);
var_dump($opts, $m);
echo "All done\n";
?>
--EXPECTF--
-%s: Mongo::__construct(): The 'timeout' option is deprecated. Please use 'connectTimeoutMS' instead in %s on line %d
+%s: MongoClient::__construct(): The 'timeout' option is deprecated. Please use 'connectTimeoutMS' instead in %s on line %d
Notice: Array to string conversion in %smongoclient-ctor-002.php on line %d
@@ -51,7 +51,7 @@ array(5) {
["connect"]=>
string(1) "0"
}
-object(Mongo)#%d (4) {
+object(MongoClient)#%d (4) {
["connected"]=>
bool(false)
["status"]=>
View
2  tests/replicaset/legacy/mongocollection-findandmodify-001-errors.phpt
@@ -6,7 +6,7 @@ MongoCollection::findAndModify() helper
<?php
require_once "tests/utils/server.inc";
-$m = mongo();
+$m = new_mongo();
$col = $m->selectDB(dbname())->jobs;
$col->remove();
View
2  tests/replicaset/legacy/mongocollection-findone.phpt
@@ -7,7 +7,7 @@ MongoCollection::findOne() with setSlaveOkay().
require_once "tests/utils/server.inc";
$cfg = MongoShellServer::getReplicasetInfo();
-$mongoConnection = new Mongo($cfg["hosts"][0] . "," . $cfg["hosts"][1], array('replicaSet' => rsname()));
+$mongoConnection = new MongoClient($cfg["hosts"][0] . "," . $cfg["hosts"][1], array('replicaSet' => rsname()));
$dbname = dbname();
$db = $mongoConnection->$dbname;
$db->setSlaveOkay();
View
8 tests/standalone/legacy/bug00464.phpt
@@ -9,14 +9,14 @@ Test for PHP-464: Re-implement ->connected (var_dump())
require_once "tests/utils/server.inc";
$cfg = MongoShellServer::getStandaloneInfo();
-$m = new Mongo($cfg, array("connect" => false));
+$m = new MongoClient($cfg, array("connect" => false));
var_dump($m, $m->connected);
-$m = new Mongo($cfg);
+$m = new MongoClient($cfg);
var_dump($m, $m->connected);
?>
--EXPECTF--
-object(Mongo)#%d (%d) {
+object(MongoClient)#%d (%d) {
["connected"]=>
bool(false)
["status"]=>
@@ -27,7 +27,7 @@ object(Mongo)#%d (%d) {
NULL
}
bool(false)
-object(Mongo)#%d (%d) {
+object(MongoClient)#%d (%d) {
["connected"]=>
bool(true)
["status"]=>
View
2  tests/standalone/legacy/bug00489.phpt
@@ -9,7 +9,7 @@ MongoLog::setLevel(MongoLog::WARNING);
MongoLog::setModule(MongoLog::CON);
$dsn = MongoShellServer::getStandaloneInfo();
try {
- $m = new Mongo($dsn, array("replicaSet" => true));
+ $m = new MongoClient($dsn, array("replicaSet" => true));
echo "Have mongo object\n";
$m->foo->bar->findOne();
} catch(MongoConnectionException $e) {
View
3  tests/standalone/legacy/bug00500.phpt
@@ -7,7 +7,7 @@ Test for PHP-500: MongoCollection insert, update and remove no longer return boo
require_once "tests/utils/server.inc";
// Connect to mongo
-$m = mongo_standalone();
+$m = old_mongo_standalone();
$c = $m->selectCollection(dbname(), 'crash');
$c->drop();
@@ -36,6 +36,7 @@ var_dump( $c->update( array( '_id' => 'yeah' ), array( 'value' => array( '$set'
var_dump( $c->remove( array( '_id' => 'yeah' ), array( 'safe' => true ) ) );
?>
--EXPECTF--
+%s: %s: The Mongo class is deprecated, please use the MongoClient class in %sserver.inc on line %d
bool(true)
bool(true)
bool(true)
View
1  tests/standalone/legacy/bug00569-001.phpt
@@ -42,6 +42,7 @@ foreach ( $tests as $key => $test )
}
?>
--EXPECTF--
+%s: The Mongo class is deprecated, please use the MongoClient class
IO FINE: is_gle_op: no
Running test 0, with options: []:
View
13 tests/standalone/legacy/bug00605.phpt
@@ -27,7 +27,6 @@ var_dump( $c->insert( array( 'test' => 'two' ), array( 'w' => 0 ) ) );
var_dump( $c->insert( array( 'test' => 'two' ), array( 'w' => 1 ) ) );
?>
--EXPECTF--
-bool(true)
array(4) {
["n"]=>
int(0)
@@ -38,6 +37,18 @@ array(4) {
["ok"]=>
float(1)
}
+array(4) {
+ ["n"]=>
+ int(0)
+ ["connectionId"]=>
+ int(%d)
+ ["err"]=>
+ NULL
+ ["ok"]=>
+ float(1)
+}
+
+%s: %s: The Mongo class is deprecated, please use the MongoClient class in %sserver.inc on line %d
bool(true)
bool(true)
array(4) {
View
2  tests/standalone/legacy/log-1.phpt
@@ -15,7 +15,7 @@ set_error_handler('error_handler');
MongoLog::setModule(MongoLog::ALL);
MongoLog::setLevel(MongoLog::ALL);
$dsn = MongoShellServer::getStandaloneInfo();
-$m = new Mongo("mongodb://$dsn");
+$m = new MongoClient("mongodb://$dsn");
MongoLog::setModule(0);
MongoLog::setLevel(0);
?>
View
2  tests/standalone/legacy/log-2.phpt
@@ -17,7 +17,7 @@ MongoLog::setLevel(MongoLog::ALL);
$host = MongoShellServer::getStandaloneInfo();
-$m = new Mongo($host);
+$m = new MongoClient($host);
MongoLog::setModule(0);
MongoLog::setLevel(0);
View
2  tests/standalone/legacy/log-3.phpt
@@ -15,7 +15,7 @@ set_error_handler('error_handler');
MongoLog::setModule(MongoLog::PARSE);
MongoLog::setLevel(MongoLog::ALL);
$dsn = MongoShellServer::getStandaloneInfo();
-$m = new Mongo("mongodb://$dsn");
+$m = new MongoClient("mongodb://$dsn");
?>
--EXPECTF--
PARSE INFO: Parsing mongodb://%s:%d
View
6 tests/standalone/legacy/log-4.phpt
@@ -16,19 +16,19 @@ echo "Warnings:\n";
MongoLog::setModule(MongoLog::ALL);
MongoLog::setLevel(MongoLog::WARNING);
$dsn = MongoShellServer::getStandaloneInfo();
-$m = new Mongo("mongodb://$dsn");
+$m = new MongoClient("mongodb://$dsn");
echo "Fine:\n";
MongoLog::setModule(MongoLog::ALL);
MongoLog::setLevel(MongoLog::FINE);
$dsn = MongoShellServer::getStandaloneInfo();
-$m = new Mongo("mongodb://$dsn");
+$m = new MongoClient("mongodb://$dsn");
echo "Info:\n";
MongoLog::setModule(MongoLog::ALL);
MongoLog::setLevel(MongoLog::INFO);
$dsn = MongoShellServer::getStandaloneInfo();
-$m = new Mongo("mongodb://$dsn");
+$m = new MongoClient("mongodb://$dsn");
MongoLog::setModule(0);
MongoLog::setLevel(0);
?>
View
14 tests/utils/server.inc
@@ -270,24 +270,24 @@ function getServerVersion($mc = null) {
/* BC Layer for old tests */
function mongo() {
- $config = MongoShellServer::getReplicaSetInfo();
- return new Mongo($config["dsn"], array("replicaSet" => $config["rsname"]));
+ return new_mongo();
}
function old_mongo() {
- return mongo();
+ $config = MongoShellServer::getReplicaSetInfo();
+ return new Mongo($config["dsn"], array("replicaSet" => $config["rsname"]));
}
function new_mongo($unused1 = null, $unused2 = null, $unused3 = null, $options = array()) {
$config = MongoShellServer::getReplicaSetInfo();
return new MongoClient($config["dsn"], array("replicaSet" => $config["rsname"])+$options);
}
-function old_mongo_standalone() {
- return mongo_standalone();
-}
-function mongo_standalone($unused1 = null, $unused2 = null, $unused3 = null, $options = array()) {
+function old_mongo_standalone($unused1 = null, $unused2 = null, $unused3 = null, $options = array()) {
$dsn = MongoShellServer::getStandaloneInfo();
return new Mongo($dsn, $options);
}
+function mongo_standalone($unused1 = null, $unused2 = null, $unused3 = null, $options = array()) {
+ return new_mongo_standalone();
+}
function new_mongo_standalone($unused1 = null, $unused2 = null, $unused3 = null, $options = array()) {
$dsn = MongoShellServer::getStandaloneInfo();
return new MongoClient($dsn, $options);
Something went wrong with that request. Please try again.