我有这段代码
public function deactivateDuplicateDevices(Document\Device $oDevice, Document\Passenger $oPassenger)
{
$passengerId = new \MongoId(oPassenger->getId());
$deviceId = new \MongoId($oDevice->getId());
return $this->createQueryBuilder('Device')
->update()
->multiple(true)
->field('activated')->set(false)
->field('passenger')->unsetField()->equals($passengerId)
->field('_id')->notEqual($deviceId)
->getQuery()
->execute();
}
在我的开发服务器上运行正常,但在本地计算机上崩溃了。
在dev上运行pecl list
返回
APC 3.1.13 beta
amqp 1.2.0 stable
intl 3.0.0 stable
mongo 1.3.7 stable
和本地回报:
mongo 1.5.6 stable
xdebug 2.2.5 stable
我机器上的崩溃信息是
"name":"MongoException","message":"Invalid object ID"},"code":500}
我尝试降级我当地版本的mongo,但我无法用pecl的糟糕文档来解决这个问题。例如我试过这个:
sudo pecl upgrade -f -c channel://pecl.php.net/mongo-1.3.7
但是我继续为我的所有频道排列获取channel does not exist
。
还在本地运行mongod --version
返回 db version v2.6.0 ,并在dev上返回 db version v2.4.3
这是完整的堆栈跟踪
{"response":{"file":"\/Users\/abdullah\/dev\/php\/smartTaxi\/vendor\/doctrine\/mongodb-odm\/lib\/Doctrine\/ODM\/MongoDB\/Mapping\/Types\/IdType.php","line":37,"trace":"#0 \/Users\/abdullah\/dev\/php\/smartTaxi\/vendor\/doctrine\/mongodb-odm\/lib\/Doctrine\/ODM\/MongoDB\/Mapping\/Types\/IdType.php(37): MongoId->__construct(1)\n#1 \/Users\/abdullah\/dev\/php\/smartTaxi\/vendor\/doctrine\/mongodb-odm\/lib\/Doctrine\/ODM\/MongoDB\/Mapping\/ClassMetadataInfo.php(1291): Doctrine\\ODM\\MongoDB\\Mapping\\Types\\IdType->convertToDatabaseValue(1)\n#2 \/Users\/abdullah\/dev\/php\/smartTaxi\/vendor\/doctrine\/mongodb-odm\/lib\/Doctrine\/ODM\/MongoDB\/Persisters\/DocumentPersister.php(990): Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadataInfo->getDatabaseIdentifierValue(1)\n#3 \/Users\/abdullah\/dev\/php\/smartTaxi\/vendor\/doctrine\/mongodb-odm\/lib\/Doctrine\/ODM\/MongoDB\/Persisters\/DocumentPersister.php(861): Doctrine\\ODM\\MongoDB\\Persisters\\DocumentPersister->prepareQueryElement('passenger', 1, NULL, true)\n#4 \/Users\/abdullah\/dev\/php\/smartTaxi\/vendor\/doctrine\/mongodb-odm\/lib\/Doctrine\/ODM\/MongoDB\/Persisters\/DocumentPersister.php(836): Doctrine\\ODM\\MongoDB\\Persisters\\DocumentPersister->prepareSubQuery(Array)\n#5 \/Users\/abdullah\/dev\/php\/smartTaxi\/vendor\/doctrine\/mongodb-odm\/lib\/Doctrine\/ODM\/MongoDB\/Query\/Expr.php(129): Doctrine\\ODM\\MongoDB\\Persisters\\DocumentPersister->prepareNewObj(Array)\n#6 \/Users\/abdullah\/dev\/php\/smartTaxi\/vendor\/doctrine\/mongodb-odm\/lib\/Doctrine\/ODM\/MongoDB\/Query\/Builder.php(239): Doctrine\\ODM\\MongoDB\\Query\\Expr->getNewObj()\n#7 \/Users\/abdullah\/dev\/php\/smartTaxi\/src\/St\/AppBundle\/Repository\/DeviceRepository.php(132): Doctrine\\ODM\\MongoDB\\Query\\Builder->getQuery()\n#8 \/Users\/abdullah\/dev\/php\/smartTaxi\/src\/St\/AppBundle\/Model\/PassengerManager.php(207): St\\AppBundle\\Repository\\DeviceRepository->deactivateDuplicateDevices(Object(St\\AppBundle\\Document\\Device), Object(MongoDBODMProxies\\__CG__\\St\\AppBundle\\Document\\Passenger))\n#9 \/Users\/abdullah\/dev\/php\/smartTaxi\/src\/St\/ApiBundle\/Controller\/PassengerController.php(96): St\\AppBundle\\Model\\PassengerManager->register(Object(St\\AppBundle\\Document\\Device), '6651')\n#10 [internal function]: St\\ApiBundle\\Controller\\PassengerController->verifyRegistrationAction()\n#11 \/Users\/abdullah\/dev\/php\/smartTaxi\/vendor\/jms\/cg\/src\/CG\/Proxy\/MethodInvocation.php(63): ReflectionMethod->invokeArgs(Object(EnhancedProxy_5e2a7e5669a027f8d79b4b96c7288b294d024637\\__CG__\\St\\ApiBundle\\Controller\\PassengerController), Array)\n#12 \/Users\/abdullah\/dev\/php\/smartTaxi\/vendor\/jms\/security-extra-bundle\/JMS\/SecurityExtraBundle\/Security\/Authorization\/Interception\/MethodSecurityInterceptor.php(120): CG\\Proxy\\MethodInvocation->proceed()\n#13 \/Users\/abdullah\/dev\/php\/smartTaxi\/vendor\/jms\/cg\/src\/CG\/Proxy\/MethodInvocation.php(58): JMS\\SecurityExtraBundle\\Security\\Authorization\\Interception\\MethodSecurityInterceptor->intercept(Object(CG\\Proxy\\MethodInvocation))\n#14 \/Users\/abdullah\/dev\/php\/smartTaxi\/app\/cache\/dev\/jms_diextra\/proxies\/St-ApiBundle-Controller-PassengerController.php(21): CG\\Proxy\\MethodInvocation->proceed()\n#15 [internal function]: EnhancedProxy_5e2a7e5669a027f8d79b4b96c7288b294d024637\\__CG__\\St\\ApiBundle\\Controller\\PassengerController->verifyRegistrationAction()\n#16 \/Users\/abdullah\/dev\/php\/smartTaxi\/app\/bootstrap.php.cache(1426): call_user_func_array(Array, Array)\n#17 \/Users\/abdullah\/dev\/php\/smartTaxi\/app\/bootstrap.php.cache(1390): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 1)\n#18 \/Users\/abdullah\/dev\/php\/smartTaxi\/app\/bootstrap.php.cache(1566): Symfony\\Component\\HttpKernel\\HttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#19 \/Users\/abdullah\/dev\/php\/smartTaxi\/app\/bootstrap.php.cache(617): Symfony\\Bundle\\FrameworkBundle\\HttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#20 \/Users\/abdullah\/dev\/php\/smartTaxi\/web\/app_dev.php(31): Symfony\\Component\\HttpKernel\\Kernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))\n#21 \/Users\/abdullah\/dev\/php\/smartTaxi\/vendor\/symfony\/symfony\/src\/Symfony\/Bundle\/FrameworkBundle\/Resources\/config\/router.php(30): require('\/Users\/abdullah...')\n#22 {main}","name":"MongoException","message":"Invalid object ID"},"code":500}
在php风暴中,如果我突出显示mongoid类型,它会告诉我这个
想法?
答案 0 :(得分:0)
所以基本上我这样做的方式就是去pecl网站here上的mongo包页面..我下载了mongo-1.3.7.tgz。然后我只是在它上面运行此命令(卸载原始的1.5.6版本using pecl uninstall mongo
后):
pecl install mongo-1.3.7.tgz
就是这样!很明显这是一个特定于版本的问题..一个被弃用的命令或者什么......