Skip to content

Commit 2ed0241

Browse files
committed
Fix comment and don't use MongoDB\BSON\Binary objects
1 parent 890b71f commit 2ed0241

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/ChangeStream.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ public function next()
101101
$this->hasAdvanced = true;
102102
$this->resumeToken = $this->extractResumeToken($this->csIt->current());
103103
}
104-
// If the cursorId is 0, the server has invalidated the cursor so we
105-
// will never perform another getMore. This means that we cannot
106-
// resume and we can therefore unset the resumeCallable, which will
107-
// free any reference to Watch. This will also free the only
108-
// reference to an implicit session, since any such reference
109-
// belongs to Watch.
104+
/* If the cursorId is 0, the server has invalidated the cursor so we
105+
* will never perform another getMore. This means that we cannot
106+
* resume and we can therefore unset the resumeCallable, which will
107+
* free any reference to Watch. This will also free the only
108+
* reference to an implicit session, since any such reference
109+
* belongs to Watch. */
110110
if ($this->getCursorId() === 0) {
111111
unset($this->resumeCallable);
112112
}
@@ -139,12 +139,7 @@ public function rewind()
139139
$this->hasAdvanced = true;
140140
$this->resumeToken = $this->extractResumeToken($this->csIt->current());
141141
}
142-
// If the cursorId is 0, the server has invalidated the cursor so we
143-
// will never perform another getMore. This means that we cannot
144-
// resume and we can therefore unset the resumeCallable, which will
145-
// free any reference to Watch. This will also free the only
146-
// reference to an implicit session, since any such reference
147-
// belongs to Watch.
142+
// As with next(), free the callable once we know it will never be used.
148143
if ($this->getCursorId() === 0) {
149144
unset($this->resumeCallable);
150145
}

tests/Operation/WatchFunctionalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ function() use ($operation, &$changeStream) {
606606
},
607607
function($changeStream) use (&$originalSession) {
608608
if (isset($changeStream->aggregate)) {
609-
$originalSession = $changeStream->lsid;
609+
$originalSession = bin2hex((string) $changeStream->lsid->id);
610610
}
611611
}
612612
);
@@ -620,7 +620,7 @@ function() use (&$changeStream) {
620620
},
621621
function ($changeStream) use (&$sessionAfterResume) {
622622
if (isset($changeStream->aggregate)) {
623-
$sessionAfterResume = $changeStream->lsid;
623+
$sessionAfterResume = bin2hex((string) $changeStream->lsid->id);
624624
}
625625
}
626626
);

0 commit comments

Comments
 (0)