Skip to content

Commit ba57f71

Browse files
committed
Add typeMap to find options
1 parent 04dea18 commit ba57f71

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Queue.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ public function get(array $query, $runningResetDuration, $waitDurationInMillis =
186186
$resetTimestamp = min(max(0, $resetTimestamp * 1000), self::MONGO_INT32_MAX);
187187

188188
$update = ['$set' => ['resetTimestamp' => new \MongoDB\BSON\UTCDateTime($resetTimestamp), 'running' => true]];
189-
$options = ['sort' => ['priority' => 1, 'created' => 1]];
189+
$options = [
190+
'sort' => ['priority' => 1, 'created' => 1],
191+
'typeMap' => ['root' => 'array', 'document' => 'array', 'array' => 'array'],
192+
];
190193

191194
//ints overflow to floats, should be fine
192195
$end = microtime(true) + ($waitDurationInMillis / 1000.0);
@@ -205,7 +208,7 @@ public function get(array $query, $runningResetDuration, $waitDurationInMillis =
205208
//older mongo extension
206209
if ($message !== null && array_key_exists('_id', $message)) {
207210
// findOneAndUpdate does not correctly return result according to typeMap options so just refetch.
208-
$message = $this->collection->findOne(['_id' => $message->_id]);
211+
$message = $this->collection->findOne(['_id' => $message['_id']]);
209212
//id on left of union operator so a possible id in payload doesnt wipe it out the generated one
210213
return ['id' => $message['_id']] + (array)$message['payload'];
211214
}

0 commit comments

Comments
 (0)