Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
d13ab854
Commit
d13ab854
authored
Jun 19, 2019
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-445: Leave key as-is if ChangeStream::next() fails to extract resume token
parent
401496aa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
6 deletions
+5
-6
ChangeStream.php
src/ChangeStream.php
+2
-1
WatchFunctionalTest.php
tests/Operation/WatchFunctionalTest.php
+3
-5
No files found.
src/ChangeStream.php
View file @
d13ab854
...
...
@@ -212,6 +212,8 @@ class ChangeStream implements Iterator
return
;
}
$this
->
resumeToken
=
$this
->
extractResumeToken
(
$this
->
csIt
->
current
());
/* Increment the key if the iteration event was a call to next() and we
* have already advanced past the first result. */
if
(
$isNext
&&
$this
->
hasAdvanced
)
{
...
...
@@ -219,7 +221,6 @@ class ChangeStream implements Iterator
}
$this
->
hasAdvanced
=
true
;
$this
->
resumeToken
=
$this
->
extractResumeToken
(
$this
->
csIt
->
current
());
}
/**
...
...
tests/Operation/WatchFunctionalTest.php
View file @
d13ab854
...
...
@@ -706,7 +706,7 @@ class WatchFunctionalTest extends FunctionalTestCase
$this
->
assertSame
(
1
,
$changeStream
->
key
());
}
public
function
testResumeTokenNotFound
Advances
Key
()
public
function
testResumeTokenNotFound
DoesNotAdvance
Key
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'4.1.8'
,
'>='
))
{
$this
->
markTestSkipped
(
'Server rejects change streams that modify resume token (SERVER-37786)'
);
...
...
@@ -717,8 +717,6 @@ class WatchFunctionalTest extends FunctionalTestCase
$operation
=
new
Watch
(
$this
->
manager
,
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$pipeline
,
$this
->
defaultOptions
);
$changeStream
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
/* Note: we intentionally do not start iteration with rewind() to ensure
* that we test extraction functionality within next(). */
$this
->
insertDocument
([
'x'
=>
1
]);
$this
->
insertDocument
([
'x'
=>
2
]);
$this
->
insertDocument
([
'x'
=>
3
]);
...
...
@@ -735,14 +733,14 @@ class WatchFunctionalTest extends FunctionalTestCase
$this
->
fail
(
'ResumeTokenException was not thrown'
);
}
catch
(
ResumeTokenException
$e
)
{}
$this
->
assertSame
(
1
,
$changeStream
->
key
());
$this
->
assertSame
(
0
,
$changeStream
->
key
());
try
{
$changeStream
->
next
();
$this
->
fail
(
'ResumeTokenException was not thrown'
);
}
catch
(
ResumeTokenException
$e
)
{}
$this
->
assertSame
(
2
,
$changeStream
->
key
());
$this
->
assertSame
(
0
,
$changeStream
->
key
());
}
public
function
testSessionPersistsAfterResume
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment