-
Notifications
You must be signed in to change notification settings - Fork 208
PHPC-1459: Add serialization support for CursorId #1053
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
Conversation
--TEST-- | ||
MongoDB\Driver\CursorID serialization on 32-bit systems | ||
--SKIPIF-- | ||
<?php if (4 !== PHP_INT_SIZE) { die('skip Only for 32-bit platform'); } ?> |
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.
This needs two separate tests for 32-bit and 64-bit systems due to the different serialisation formats. I thought this was better than writing an EXPECTF
section to account for both int and string outputs of the 64-bit value.
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 it the serialisation formats that differ, or just the debug output?
If it's just the debug output, we do have prior art for using an EXPECTF in tests/functional/cursorid-001.phpt that you could copy in.
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.
Ah, yeah, that was what I wanted to avoid, but if we already use it then we should also use that in the serialisation tests.
return false; | ||
} | ||
|
||
intern->id = id; |
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.
Contrasting this with Int64.c, I noticed that CursorId.c has a get_debug_info
handler but no get_properties
handler. Likewise, the CursorId struct doesn't have a separate initialized
boolean to differentiate an empty struct from a populated one (since we don't have a pointer field to work with and prefer not to make assumptions based on any int
fields).
Since the BSON classes and RC/RP/WC value objects have both handlers, would it make sense to have a new ticket to do the same for CursorId? Practically, this would just allow one to call var_export()
on this object. I expect it'd just entail copying a bit more code from Int64.c into a separate PR. Thankfully this isn't something we need to bother documenting.
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.
--TEST-- | ||
MongoDB\Driver\CursorID serialization on 32-bit systems | ||
--SKIPIF-- | ||
<?php if (4 !== PHP_INT_SIZE) { die('skip Only for 32-bit platform'); } ?> |
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 it the serialisation formats that differ, or just the debug output?
If it's just the debug output, we do have prior art for using an EXPECTF in tests/functional/cursorid-001.phpt that you could copy in.
https://jira.mongodb.org/browse/PHPC-1459
Note that serialising an object will always have the identifier as string for portability between 32-bit and 64-bit platforms. This is consistent with the serialisation handling for
MongoDB\BSON\Int64
.