PHP7 MongoDB Invalid reply to find command

error message:

PHP Fatal error: Uncaught MongoDB\\Driver\\Exception\\RuntimeException: Invalid reply to find command. in .../library/MongoDB/Operation/Find.php:299
Stack trace:
-sharp0 .../library/MongoDB/Operation/Find.php(299): MongoDB\\Driver\\Server->executeQuery("crm.t_accountin...", Object(MongoDB\\Driver\\Query), Array)
-sharp1 .../library/MongoDB/Operation/FindOne.php(126): MongoDB\\Operation\\Find->execute(Object(MongoDB\\Driver\\Server))
-sharp2 .../library/MongoDB/Collection.php(657): MongoDB\\Operation\\FindOne->execute(Object(MongoDB\\Driver\\Server))
-sharp3 .../Mongo.php(211): MongoDB\\Collection->findOne(Array, Array)
-sharp4 xxx.php(315): xxx->fetchRow("xxx...", Array, "xxx...")
-sharp5 xxx.php(220): xxx->fetchR in xxx/library/MongoDB/Operation/Find.php on line 299

some people on the website say that this problem has been fixed in 1.2 version:
PHPC-625

mongodb/mongo-php-driver-sharp527

The

syntax is based on php-library findOne document .

manipulate fetchRow in the class by yourself, where private functions are all simple transformations:

/**
 * 
 *
 * @param string $collectionName 
 * @param array $condition 
 * @param string|null $fields 
 * @return array|bool
 */
public function fetchRow($collectionName, $condition = [], $fields = null) {
    $options = [];
    if (! empty($fields)) {
        $options["projection"] = $this->_toFieldsArray($fields);
    }
    $result = $this->getConnection()
        ->selectCollection($this->database, $collectionName)
        ->findOne($condition, $options);
    $result = $this->_toArray($result);
    
    return $this->_checkCharset($result, false);
}
Jun.28,2021

MongoDB version 3.2.0
MongoDB extension version 1.5.1 stable

If you have reproducible errors on the most recent stable release of the driver (1.5.x), please open a new issue so we can investigate and track that going forward. I'm not sure why you would be calling pcntl_fork () from a web SAPI, but note that the driver still does not support sharing its resources across forked PHP processes. The fixes I referred to in -sharp174 (comment) only pertain to including the PID when persisting libmongoc client objects (and their sockets), which ensure that creating a new Manager in a child process with the same URI will not attempt to re-use resources from the parent process.

  

post the code you wrote

Menu