-
Notifications
You must be signed in to change notification settings - Fork 208
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--TEST-- | ||
PHPC-1151: Segfault if session unset before first getMore (find) | ||
--SKIPIF-- | ||
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?> | ||
<?php NEEDS_CRYPTO(); ?> | ||
<?php NEEDS('STANDALONE'); ?> | ||
<?php NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.6"); ?> | ||
<?php CLEANUP(STANDALONE); ?> | ||
--FILE-- | ||
<?php | ||
require_once __DIR__ . "/../utils/basic.inc"; | ||
|
||
$manager = new MongoDB\Driver\Manager(STANDALONE); | ||
|
||
$bulk = new MongoDB\Driver\BulkWrite; | ||
$bulk->insert(['_id' => 1]); | ||
$bulk->insert(['_id' => 2]); | ||
$bulk->insert(['_id' => 3]); | ||
$manager->executeBulkWrite(NS, $bulk); | ||
|
||
$query = new MongoDB\Driver\Query([], ['batchSize' => 2]); | ||
$session = $manager->startSession(); | ||
|
||
$cursor = $manager->executeQuery(NS, $query, ['session' => $session]); | ||
|
||
foreach ($cursor as $document) { | ||
unset($session); | ||
echo $document->_id, "\n"; | ||
} | ||
|
||
?> | ||
===DONE=== | ||
<?php exit(0); ?> | ||
--EXPECT-- | ||
1 | ||
2 | ||
3 | ||
===DONE=== |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--TEST-- | ||
PHPC-1151: Segfault if session unset before first getMore (aggregate) | ||
--SKIPIF-- | ||
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?> | ||
<?php NEEDS_CRYPTO(); ?> | ||
<?php NEEDS('STANDALONE'); ?> | ||
<?php NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.6"); ?> | ||
<?php CLEANUP(STANDALONE); ?> | ||
--FILE-- | ||
<?php | ||
require_once __DIR__ . "/../utils/basic.inc"; | ||
|
||
$manager = new MongoDB\Driver\Manager(STANDALONE); | ||
|
||
$bulk = new MongoDB\Driver\BulkWrite; | ||
$bulk->insert(['_id' => 1]); | ||
$bulk->insert(['_id' => 2]); | ||
$bulk->insert(['_id' => 3]); | ||
$manager->executeBulkWrite(NS, $bulk); | ||
|
||
$command = new MongoDB\Driver\Command([ | ||
'aggregate' => COLLECTION_NAME, | ||
'pipeline' => [], | ||
'cursor' => ['batchSize' => 2], | ||
]); | ||
$session = $manager->startSession(); | ||
|
||
$cursor = $manager->executeReadCommand(DATABASE_NAME, $command, ['session' => $session]); | ||
|
||
foreach ($cursor as $document) { | ||
unset($session); | ||
echo $document->_id, "\n"; | ||
} | ||
|
||
?> | ||
===DONE=== | ||
<?php exit(0); ?> | ||
--EXPECT-- | ||
1 | ||
2 | ||
3 | ||
===DONE=== |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--TEST-- | ||
PHPC-1151: Segfault if session unset before cursor is killed (find) | ||
--SKIPIF-- | ||
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?> | ||
<?php NEEDS_CRYPTO(); ?> | ||
<?php NEEDS('STANDALONE'); ?> | ||
<?php NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.6"); ?> | ||
<?php CLEANUP(STANDALONE); ?> | ||
--FILE-- | ||
<?php | ||
require_once __DIR__ . "/../utils/basic.inc"; | ||
|
||
$manager = new MongoDB\Driver\Manager(STANDALONE); | ||
|
||
$bulk = new MongoDB\Driver\BulkWrite; | ||
$bulk->insert(['_id' => 1]); | ||
$bulk->insert(['_id' => 2]); | ||
$bulk->insert(['_id' => 3]); | ||
$manager->executeBulkWrite(NS, $bulk); | ||
|
||
$query = new MongoDB\Driver\Query([], ['batchSize' => 2]); | ||
$session = $manager->startSession(); | ||
|
||
$cursor = $manager->executeQuery(NS, $query, ['session' => $session]); | ||
unset($session); | ||
unset($cursor); | ||
|
||
?> | ||
===DONE=== | ||
<?php exit(0); ?> | ||
--EXPECT-- | ||
===DONE=== |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--TEST-- | ||
PHPC-1151: Segfault if session unset before cursor is killed (aggregate) | ||
--SKIPIF-- | ||
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?> | ||
<?php NEEDS_CRYPTO(); ?> | ||
<?php NEEDS('STANDALONE'); ?> | ||
<?php NEEDS_ATLEAST_MONGODB_VERSION(STANDALONE, "3.6"); ?> | ||
<?php CLEANUP(STANDALONE); ?> | ||
--FILE-- | ||
<?php | ||
require_once __DIR__ . "/../utils/basic.inc"; | ||
|
||
$manager = new MongoDB\Driver\Manager(STANDALONE); | ||
|
||
$bulk = new MongoDB\Driver\BulkWrite; | ||
$bulk->insert(['_id' => 1]); | ||
$bulk->insert(['_id' => 2]); | ||
$bulk->insert(['_id' => 3]); | ||
$manager->executeBulkWrite(NS, $bulk); | ||
|
||
$command = new MongoDB\Driver\Command([ | ||
'aggregate' => COLLECTION_NAME, | ||
'pipeline' => [], | ||
'cursor' => ['batchSize' => 2], | ||
]); | ||
$session = $manager->startSession(); | ||
|
||
$cursor = $manager->executeReadCommand(DATABASE_NAME, $command, ['session' => $session]); | ||
unset($session); | ||
unset($cursor); | ||
|
||
?> | ||
===DONE=== | ||
<?php exit(0); ?> | ||
--EXPECT-- | ||
===DONE=== |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,8 @@ object(MongoDB\Driver\Cursor)#%d (%d) { | |
} | ||
["readPreference"]=> | ||
NULL | ||
["session"]=> | ||
NULL | ||
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. Do we have a test case where 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. 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. I think putting it in #803 makes more sense. |
||
["isDead"]=> | ||
bool(false) | ||
["currentIndex"]=> | ||
|
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.
What's the reason for moving the argument order around?
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.
See commit message: 0b6f04f