diff --git a/src/MongoDB/Query.c b/src/MongoDB/Query.c index 79c6135e0..ec0f1476f 100644 --- a/src/MongoDB/Query.c +++ b/src/MongoDB/Query.c @@ -209,6 +209,8 @@ static bool php_phongo_query_init_limit_and_singlebatch(php_phongo_query_t* inte if (php_array_fetchc_long(options, "limit") < 0) { zend_long limit = php_array_fetchc_long(options, "limit"); + php_error_docref(NULL, E_DEPRECATED, "Support for negative \"limit\" values is deprecated and will be removed in ext-mongodb 2.0"); + if (!BSON_APPEND_INT64(intern->opts, "limit", -limit)) { phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Error appending \"limit\" option"); return false; diff --git a/tests/query/query-ctor-005.phpt b/tests/query/query-ctor-005.phpt index e206d731c..c0a534613 100644 --- a/tests/query/query-ctor-005.phpt +++ b/tests/query/query-ctor-005.phpt @@ -20,6 +20,7 @@ var_dump(new MongoDB\Driver\Query( ===DONE=== --EXPECTF-- +Deprecated: MongoDB\Driver\Query::__construct(): Support for negative "limit" values is deprecated and will be removed in ext-mongodb 2.0 in %s on line %d object(MongoDB\Driver\Query)#%d (%d) { ["filter"]=> object(stdClass)#%d (%d) { @@ -36,6 +37,8 @@ object(MongoDB\Driver\Query)#%d (%d) { ["readConcern"]=> NULL } + +Deprecated: MongoDB\Driver\Query::__construct(): Support for negative "limit" values is deprecated and will be removed in ext-mongodb 2.0 in %s on line %d object(MongoDB\Driver\Query)#%d (%d) { ["filter"]=> object(stdClass)#%d (%d) { diff --git a/tests/query/query-ctor_error-003.phpt b/tests/query/query-ctor_error-003.phpt index 7616f8058..696222477 100644 --- a/tests/query/query-ctor_error-003.phpt +++ b/tests/query/query-ctor_error-003.phpt @@ -12,7 +12,8 @@ echo throws(function() { ?> ===DONE=== ---EXPECT-- +--EXPECTF-- +Deprecated: MongoDB\Driver\Query::__construct(): Support for negative "limit" values is deprecated and will be removed in ext-mongodb 2.0 in %s on line %d OK: Got MongoDB\Driver\Exception\InvalidArgumentException Negative "limit" option conflicts with false "singleBatch" option ===DONE=== diff --git a/tests/server/server-executeQuery-007.phpt b/tests/server/server-executeQuery-007.phpt index 22dd82cae..3f8c960cf 100644 --- a/tests/server/server-executeQuery-007.phpt +++ b/tests/server/server-executeQuery-007.phpt @@ -29,6 +29,7 @@ var_dump(iterator_to_array($cursor)); ===DONE=== --EXPECTF-- +Deprecated: MongoDB\Driver\Query::__construct(): Support for negative "limit" values is deprecated and will be removed in ext-mongodb 2.0 in %s on line %d bool(true) bool(true) array(2) {