alcaeus / mongo-php-adapter

:link: Adapter to provide ext-mongo interface on top of mongo-php-library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception MongoCursorException: "Unknown modifier: $pushAll"

charanpahariapp opened this issue · comments

I am trying to update my collection

$shareUser->setSchedules(new \Doctrine\Common\Collections\ArrayCollection());

                foreach ($scheduleArray['schedules'] as $schedule)
                {
                    // Add the schedule to the array of schedules
                    $shareUser->addSchedule($schedule);
                    
                }

I am getting this error

request.CRITICAL: Uncaught PHP Exception MongoCursorException: "Unknown modifier: $pushAll" at /home/xxxxx/Desktop/mobile_api/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/ExceptionConverter.php line 86 {"exception":"[object] (MongoCursorException(code: 9): Unknown modifier: $pushAll at /home/xxxxx/Desktop/lsc_mobile_api/vendor/alcaeus/mongo-php-adapter/lib/Alcaeus/MongoDbAdapter/ExceptionConverter.php:86, MongoDB\Driver\Exception\BulkWriteException(code: 9): Unknown modifier: $pushAll at /home/xxxxxx/Desktop/lsc_mobile_api/vendor/mongodb/mongodb/src/Operation/Update.php:179)"} []

I am using
Symfony 2.8
php 7.2
Mongo 3.6
"alcaeus/mongo-php-adapter": "^1.0", in my composer.json

But when I use query builder
```
foreach ($scheduleArray['schedules'] as $schedule) {
$qb->field('schedules')->addToSet($schedule);
}


It works fine.

Please help me to resolve the issue

The $pushAll operator was deprecated in MongoDB 2.4 and removed in MongoDB 3.6. You should use $push combined with $each instead.

Judging from the code you posted, you might be using Doctrine MongoDB ODM. If so, please update to at least 1.2.1, which updates the pushAll strategy code to no longer use $pushAll but instead use $push with $each as well. Either way, this is not an issue in the adapter.