Skip to content

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

Merged
merged 1 commit into from
Nov 11, 2019

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Nov 6, 2019

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.

@alcaeus alcaeus self-assigned this Nov 6, 2019
--TEST--
MongoDB\Driver\CursorID serialization on 32-bit systems
--SKIPIF--
<?php if (4 !== PHP_INT_SIZE) { die('skip Only for 32-bit platform'); } ?>
Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

@alcaeus alcaeus requested a review from jmikola November 7, 2019 06:23
return false;
}

intern->id = id;
Copy link
Member

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.

Copy link
Member Author

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'); } ?>
Copy link
Member

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.

alcaeus added a commit that referenced this pull request Nov 11, 2019
@alcaeus alcaeus merged commit 0a30941 into mongodb:master Nov 11, 2019
@alcaeus alcaeus deleted the phpc-1459 branch November 11, 2019 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants