-
Notifications
You must be signed in to change notification settings - Fork 209
PHPC-1490: Add support for var_export() and __set_state() in CursorId.c #1231
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a01b96f
PHPC-1490: Add support for var_export() and __set_state() in CursorId.c
tanlisu d3496d2
PHPC-1490: Add support for var_export() and __set_state() in CursorId.c
tanlisu 445f400
Merge branch 'master' of https://github.com/tanlisu/mongo-php-driver …
tanlisu e9faf26
PHPC-1490: Add support __set_state() in CursorId.c
tanlisu 1f4d118
PHPC-1490: Add support for __set_state() in CursorId.c
tanlisu fad228b
PHPC-1490: Add support for var_export() and __set_state() in CursorId.c
tanlisu 7fb5706
PHPC-1490: Add support for var_export() and __set_state() in CursorId.c
tanlisu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--TEST-- | ||
MongoDB\Driver\CursorId debug output | ||
--FILE-- | ||
<?php | ||
|
||
require_once __DIR__ . '/../utils/basic.inc'; | ||
|
||
$cursorId = unserialize('C:23:"MongoDB\Driver\CursorId":42:{a:1:{s:2:"id";s:19:"7250031947823432848";}}'); | ||
|
||
var_dump($cursorId); | ||
|
||
?> | ||
===DONE=== | ||
<?php exit(0); ?> | ||
--EXPECTF-- | ||
object(MongoDB\Driver\CursorId)#%d (%d) { | ||
["id"]=> | ||
%rint\(|string\(19\) "|%r7250031947823432848%r"|\)%r | ||
} | ||
===DONE=== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--TEST-- | ||
MongoDB\Driver\CursorId debug output on 32-bit platform | ||
--SKIPIF-- | ||
<?php if (4 !== PHP_INT_SIZE) { die('skip Only for 32-bit platform'); } ?> | ||
--FILE-- | ||
<?php | ||
|
||
require_once __DIR__ . '/../utils/basic.inc'; | ||
|
||
$cursorId = unserialize('C:23:"MongoDB\Driver\CursorId":42:{a:1:{s:2:"id";s:19:"7250031947823432848";}}'); | ||
|
||
var_dump($cursorId); | ||
|
||
?> | ||
===DONE=== | ||
<?php exit(0); ?> | ||
--EXPECTF-- | ||
object(MongoDB\Driver\CursorId)#%d (%d) { | ||
["id"]=> | ||
string(19) "7250031947823432848" | ||
} | ||
===DONE=== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--TEST-- | ||
MongoDB\Driver\CursorId debug output on 64-bit platform | ||
--SKIPIF-- | ||
<?php if (8 !== PHP_INT_SIZE) { die('skip Only for 64-bit platform'); } ?> | ||
--FILE-- | ||
<?php | ||
|
||
require_once __DIR__ . '/../utils/basic.inc'; | ||
|
||
$cursorId = unserialize('C:23:"MongoDB\Driver\CursorId":42:{a:1:{s:2:"id";s:19:"7250031947823432848";}}'); | ||
|
||
var_dump($cursorId); | ||
|
||
?> | ||
===DONE=== | ||
<?php exit(0); ?> | ||
--EXPECTF-- | ||
object(MongoDB\Driver\CursorId)#%d (%d) { | ||
["id"]=> | ||
int(7250031947823432848) | ||
} | ||
===DONE=== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--TEST-- | ||
MongoDB\Driver\CursorID serialization | ||
MongoDB\Driver\CursorId serialization | ||
--FILE-- | ||
<?php | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--TEST-- | ||
MongoDB\Driver\CursorId::__set_state() | ||
--FILE-- | ||
<?php | ||
|
||
var_export(MongoDB\Driver\CursorId::__set_state([ | ||
'id' => '7250031947823432848', | ||
])); | ||
echo "\n"; | ||
|
||
?> | ||
===DONE=== | ||
<?php exit(0); ?> | ||
--EXPECT-- | ||
MongoDB\Driver\CursorId::__set_state(array( | ||
'id' => '7250031947823432848', | ||
)) | ||
===DONE=== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--TEST-- | ||
MongoDB\Driver\CursorId::__set_state() requires "id" string field | ||
--FILE-- | ||
<?php | ||
|
||
require_once __DIR__ . '/../utils/basic.inc'; | ||
|
||
echo throws(function() { | ||
MongoDB\Driver\CursorId::__set_state(['id' => 0]); | ||
}, MongoDB\Driver\Exception\InvalidArgumentException::class), "\n"; | ||
|
||
?> | ||
===DONE=== | ||
<?php exit(0); ?> | ||
--EXPECT-- | ||
OK: Got MongoDB\Driver\Exception\InvalidArgumentException | ||
MongoDB\Driver\CursorId initialization requires "id" string field | ||
===DONE=== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--TEST-- | ||
MongoDB\Driver\CursorId::__toString() | ||
--FILE-- | ||
<?php | ||
|
||
$cursorId = unserialize('C:23:"MongoDB\Driver\CursorId":42:{a:1:{s:2:"id";s:19:"7250031947823432848";}}'); | ||
|
||
var_dump((string) $cursorId); | ||
|
||
?> | ||
===DONE=== | ||
<?php exit(0); ?> | ||
--EXPECT-- | ||
string(19) "7250031947823432848" | ||
===DONE=== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--TEST-- | ||
MongoDB\Driver\CursorId: var_export() | ||
--FILE-- | ||
<?php | ||
|
||
require_once __DIR__ . '/../utils/basic.inc'; | ||
|
||
$cursorId = unserialize('C:23:"MongoDB\Driver\CursorId":42:{a:1:{s:2:"id";s:19:"7250031947823432848";}}'); | ||
|
||
echo var_export($cursorId, true), "\n"; | ||
|
||
?> | ||
===DONE=== | ||
<?php exit(0); ?> | ||
--EXPECT-- | ||
MongoDB\Driver\CursorId::__set_state(array( | ||
'id' => '7250031947823432848', | ||
)) | ||
===DONE=== |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should keep this around so
var_dump()
behavior isn't changed by this PR. That should entail copying this tophp_phongo_cursorid_get_properties_hash
and placing it within a conditional dependent onis_debug
.