-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHPC-2412: Deprecate CursorId class #1616
Changes from all commits
baf9064
1b5c2e9
9e5f614
6a7187d
6143507
48da73c
d3ea5dd
9aac2e8
a3cbc53
62a3392
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ $iterator = new IteratorIterator($cursor); | |
$iterator->rewind(); | ||
$iterator->next(); | ||
|
||
printf("Cursor ID is zero: %s\n", (string) $cursor->getId() === '0' ? 'yes' : 'no'); | ||
printf("Cursor ID is zero: %s\n", $cursor->getId(true) == 0 ? 'yes' : 'no'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I'll double check this, as it may have been related to the casting issues fixed in #1617. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at The return type in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TL;DR: this is not an issue, because The dirty details: before the change to Now that we return an I did not add a specific test for the case you mentioned, as |
||
var_dump($cursor); | ||
|
||
$iterator->next(); | ||
|
@@ -35,7 +35,7 @@ $iterator->next(); | |
* is exhausted. While this is primarily done to ensure implicit sessions for | ||
* command cursors are returned to the pool ASAP, it also applies to explicit | ||
* sessions. */ | ||
printf("\nCursor ID is zero: %s\n", (string) $cursor->getId() === '0' ? 'yes' : 'no'); | ||
printf("\nCursor ID is zero: %s\n", $cursor->getId(true) == 0 ? 'yes' : 'no'); | ||
var_dump($cursor); | ||
|
||
?> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--TEST-- | ||
MongoDB\Driver\Cursor::getId | ||
--SKIPIF-- | ||
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?> | ||
<?php skip_if_not_live(); ?> | ||
<?php skip_if_not_clean(); ?> | ||
--FILE-- | ||
<?php | ||
|
||
require_once __DIR__ . "/../utils/basic.inc"; | ||
|
||
$manager = create_test_manager(); | ||
|
||
$bulk = new MongoDB\Driver\BulkWrite(); | ||
$bulk->insert(['_id' => 1]); | ||
$bulk->insert(['_id' => 2]); | ||
$bulk->insert(['_id' => 3]); | ||
$manager->executeBulkWrite(NS, $bulk); | ||
|
||
$cursor = $manager->executeQuery(NS, new MongoDB\Driver\Query([], ['batchSize' => 2])); | ||
|
||
var_dump($cursor->getId()); | ||
var_dump($cursor->getId(false)); | ||
var_dump($cursor->getId(true)); | ||
|
||
?> | ||
===DONE=== | ||
<?php exit(0); ?> | ||
--EXPECTF-- | ||
Deprecated: MongoDB\Driver\Cursor::getId(): The method "MongoDB\Driver\Cursor::getId" will no longer return a "MongoDB\Driver\CursorId" instance in the future. Pass "true" as argument to change to the new behavior and receive a "MongoDB\BSON\Int64" instance instead. in %s | ||
object(MongoDB\Driver\CursorId)#%d (%d) { | ||
["id"]=> | ||
%rint\(%d\)|string\(%d\) "%d"%r | ||
} | ||
|
||
Deprecated: MongoDB\Driver\Cursor::getId(): The method "MongoDB\Driver\Cursor::getId" will no longer return a "MongoDB\Driver\CursorId" instance in the future. Pass "true" as argument to change to the new behavior and receive a "MongoDB\BSON\Int64" instance instead. in %s | ||
object(MongoDB\Driver\CursorId)#%d (%d) { | ||
["id"]=> | ||
%rint\(%d\)|string\(%d\) "%d"%r | ||
} | ||
object(MongoDB\BSON\Int64)#%d (%d) { | ||
["integer"]=> | ||
string(%d) "%d" | ||
} | ||
===DONE=== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this worth using a
use
statement, or do those not work in stubs? I feel like we've discussed this before and there's probably a reason none of the existing stubs haveuse
statements.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately,
gen_stub.php
does not support this (at least in version 8.2 which I currently use to regenerate arginfo files):