Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/MongoDB/Query.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions tests/query/query-ctor-005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var_dump(new MongoDB\Driver\Query(
===DONE===
<?php exit(0); ?>
--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) {
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions tests/query/query-ctor_error-003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ echo throws(function() {
===DONE===
<?php exit(0); ?>
--EXPECT--
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===
1 change: 1 addition & 0 deletions tests/server/server-executeQuery-007.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var_dump(iterator_to_array($cursor));
===DONE===
<?php exit(0); ?>
--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) {
Expand Down
Loading