Skip to content

PHPC-1151: Maintain Session reference on Cursor #801

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 3 commits into from
Apr 16, 2018

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Apr 12, 2018

https://jira.mongodb.org/browse/PHPC-1151

Although Cursors no longer store a reference to client objects, this is similar to what is still done for ReadPreference objects (see: 78839bd).

@jmikola jmikola requested review from derickr and kvwalker April 12, 2018 17:21
@jmikola jmikola changed the base branch from master to v1.4 April 12, 2018 17:21
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
<?php NEEDS_CRYPTO(); ?>
<?php NEEDS('STANDALONE'); NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.6"); ?>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous build failure was due to Travis attempting to run these tests on a pre-3.6 server. This adds the necessary skips from other session tests; however, it means that these tests won't run on Travis at all.

This would probably be a good time to bring over the manual server installation we're currently doing in PHPLIB.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* assigned to the option. On error, false is returned and an exception is
* thrown. */
static bool phongo_parse_session(zval *options, bson_t *mongoc_opts, zval **zsession, mongoc_client_t *client TSRMLS_DC) /* {{{ */
static bool phongo_parse_session(zval *options, mongoc_client_t *client, bson_t *mongoc_opts, zval **zsession TSRMLS_DC) /* {{{ */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for moving the argument order around?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See commit message: 0b6f04f

@@ -54,6 +54,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
}
["readPreference"]=>
NULL
["session"]=>
NULL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a test case where "session" is not NULL?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not presently. Would you like it added to this PR or should I just intend to do so for one of the tests in #803 for PHPC-1152?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think putting it in #803 makes more sense.

Copy link
Contributor

@derickr derickr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -54,6 +54,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) {
}
["readPreference"]=>
NULL
["session"]=>
NULL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think putting it in #803 makes more sense.

Client is required, while the opts and zval arguments are optional.
jmikola added 2 commits April 16, 2018 11:28
This ensures that the Session and underlying mongoc_client_session_t will not be freed until after the Cursor's mongoc_cursor_t object is destroyed.
@jmikola jmikola merged commit cc90304 into mongodb:v1.4 Apr 16, 2018
jmikola added a commit that referenced this pull request Apr 16, 2018
@jmikola jmikola deleted the 1.4-phpc-1151 branch April 16, 2018 15:28
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.

3 participants