-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 1.4.0, 1.4.1
-
Component/s: None
-
None
-
Environment:PHP 7.2.2-3+ubuntu14.04.1+deb.sury.org+1 on both CLI and PHP-FPM
MongoDB extension version => 1.4.1
libbson bundled version => 1.9.2
libmongoc bundled version => 1.9.2
PHP library: mongodb/mongodb: 1.2.0
When we try to run an aggregation pipeline on a sharded collection we get the following exception:
MongoDB\Driver\Exception\RuntimeException: Cannot use $-modifiers in opts: "$gleStats"
On a non-sharded collection this works fine. Also the same aggregation on the same collection without any code change was working with version 1.3.4.
Code to reproduce:
$accountId = 600; $offset = 0; $limit = 10; $aggregateQuery = [ ['$match' => ['_id' => $accountId,]], ['$unwind' => '$items'], ['$sort' => ['items.d' => -1]], [ '$group' => [ '_id' => '_id', 'total' => ['$sum' => 1], 'results' => ['$push' => '$$ROOT'] ] ], [ '$project' => [ 'total' => 1, 'items' => [ '$slice' => [ '$results.items', $offset, $limit ] ] ] ], ]; $aggregated = $client->selectCollection('profiles', 'sortableResearchItems')->aggregate($aggregateQuery); $items = []; $total = null; foreach ($aggregated as $doc) { if (isset($doc['total']) && isset($doc['items'])) { $total = $doc['total']; foreach ($doc['items'] as $item) { var_dump($item); } } }
- depends on
-
CDRIVER-2517 Aggregation on sharded cluster fails when $gleStats is used as a cursor option
- Closed