Change record status: 
Project: 
Introduced in branch: 
8.x-2.x
Introduced in version: 
8.x-2.2
Description: 

\Drupal\mongodb\MongoDb::countCollection() is deprecated in mongodb:8.x-2.2 and is removed from mongodb:8.x-2.3. Call \MongoDB\Collection::countDocuments() directly instead.

The method worked around differences between MongoDB PHP library versions before 1.4, and a library bug, PHPLIB-376. Neither applies to the library versions the module now supports.

One behavior differs: countCollection() returned 0 when the library threw an UnexpectedValueException, while countDocuments() lets the exception through.

Before

$count = MongoDb::countCollection($collection, $selector);

After

$count = $collection->countDocuments($selector);
Impacts: 
Module developers