Commit eec7ed6a authored by Jeremy Mikola's avatar Jeremy Mikola

Fix class check and control flow in extractResumeToken()

Ensure that the condition checks for MongoDB\BSON\Serializable and returns after recursing.
parent b8e07dba
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
namespace MongoDB; namespace MongoDB;
use MongoDB\BSON\Serializable;
use MongoDB\Driver\Cursor; use MongoDB\Driver\Cursor;
use MongoDB\Driver\Exception\ConnectionTimeoutException; use MongoDB\Driver\Exception\ConnectionTimeoutException;
use MongoDB\Driver\Exception\RuntimeException; use MongoDB\Driver\Exception\RuntimeException;
...@@ -143,8 +144,9 @@ class ChangeStream implements Iterator ...@@ -143,8 +144,9 @@ class ChangeStream implements Iterator
if ($document === null) { if ($document === null) {
throw new ResumeTokenException("Cannot extract a resumeToken from an empty document"); throw new ResumeTokenException("Cannot extract a resumeToken from an empty document");
} }
if ($document instanceof \Serializable) { if ($document instanceof Serializable) {
$this->extractResumeToken($document->bsonSerialize()); $this->extractResumeToken($document->bsonSerialize());
return;
} }
if (isset($document->_id)) { if (isset($document->_id)) {
$this->resumeToken = is_array($document) ? $document['_id'] : $document->_id; $this->resumeToken = is_array($document) ? $document['_id'] : $document->_id;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment