修改产品信息报错

bug问题 · fecshoper · 于 6年前 发布 · 2178 次阅读
Http status: 500 Internal Server Error
ajaxOptions: error
thrownError: Internal Server Error
Exception (MongoDB Exception) 'yii\mongodb\Exception' with message 'Mod on _id not allowed' 

in /www/yii2_fecshopendor/yiisoft/yii2-mongodb/Command.php:244

Stack trace:
#0 /www/yii2_fecshopendor/yiisoft/yii2-mongodb/Command.php(549): yii\mongodb\Command->executeBatch('full_search_pro...', Array)
#1 /www/yii2_fecshopendor/yiisoft/yii2-mongodb/Collection.php(289): yii\mongodb\Command->update('full_search_pro...', Array, Array, Array)
#2 /www/yii2_fecshopendor/yiisoft/yii2-mongodb/ActiveRecord.php(270): yii\mongodb\Collection->update(Array, Array)
#3 /www/yii2_fecshopendor/yiisoft/yii2/BaseActiveRecord.php(706): yii\mongodb\ActiveRecord->updateInternal(NULL)
#4 /www/yii2_fecshopendor/yiisoft/yii2/BaseActiveRecord.php(645): yii\db\BaseActiveRecord->update(true, NULL)
#5 /www/yii2_fecshopendorcyecommerce/fecshoprvices/helper/AR.php(99): yii\db\BaseActiveRecord->save()
#6 /www/yii2_fecshopendorcyecommerce/fecshoprvicesarch/MongoSearch.php(135): fecshop\services\helper\AR->save(Object(fecshop\models\mongodb\Search), Array)
#7 [internal function]: fecshop\services\search\MongoSearch->actionSyncProductInfo(Array, 20)
#8 /www/yii2_fecshopendorcyecommerce/fecshoprvices/Service.php(48): call_user_func_array(Array, Array)
#9 /www/yii2_fecshopendorcyecommerce/fecshoprvices/Search.php(62): fecshop\services\Service->__call('syncProductInfo', Array)
#10 [internal function]: fecshop\services\Search->actionSyncProductInfo(Array)
#11 /www/yii2_fecshopendorcyecommerce/fecshoprvices/Service.php(48): call_user_func_array(Array, Array)
#12 /www/yii2_fecshopendorcyecommerce/fecshoprvices/product/ProductMongodb.php(337): fecshop\services\Service->__call('syncProductInfo', Array)
#13 /www/yii2_fecshopendorcyecommerce/fecshoprvices/Product.php(336): fecshop\services\product\ProductMongodb->save(Array, '/obdstar-x300-k...')
#14 [internal function]: fecshop\services\Product->actionSave(Array, 'catalog/product...')
#15 /www/yii2_fecshopendorcyecommerce/fecshoprvices/Service.php(48): call_user_func_array(Array, Array)
#16 /www/yii2_fecshopendorcyecommerce/fecshop/app/appadmin/modules/Catalogock/productinfo/Manageredit.php(400): fecshop\services\Service->__call('save', Array)
#17 /www/yii2_fecshopendorcyecommerce/fecshop/app/appadmin/modules/Catalog/controllers/ProductinfoController.php(50): fecshop\app\appadmin\modules\Catalog\block\productinfo\Manageredit->save()
#18 [internal function]: fecshop\app\appadmin\modules\Catalog\controllers\ProductinfoController->actionManagereditsave()
#19 /www/yii2_fecshopendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#20 /www/yii2_fecshopendor/yiisoft/yii2/base/Controller.php(156): yii\base\InlineAction->runWithParams(Array)
#21 /www/yii2_fecshopendor/yiisoft/yii2/base/Module.php(523): yii\base\Controller->runAction('managereditsave', Array)
#22 /www/yii2_fecshopendor/yiisoft/yii2/web/Application.php(102): yii\base\Module->runAction('catalog/product...', Array)
#23 /www/yii2_fecshopendor/yiisoft/yii2/base/Application.php(380): yii\web\Application->handleRequest(Object(yii\web\Request))
#24 /www/yii2_fecshop/appadmin/web/index.php(71): yii\base\Application->run()
#25 {main}
共收到 12 条回复
Fecmall#16年前 0 个赞

不会是第一次保存产品吧,仅仅看报错我无法诊断问题,你是不是修改了哪里导致的报错?

看报错,应该是更新产品search导致的报错:

fecshop\services\Search->actionSyncProductInfo(Array) , 你传递的数据,是不是把 _id 也传递过去了?

mongodb "Mod on _id not allowed" 的原因:

db.update({_id:oid},{$set:{key:data}});

因为更新数据中包含了_id对象,既mongodb的主键对象,删除它就可以了
fecshoper#26年前 0 个赞

@Terry #1楼 换机器就报错

Fecmall#36年前 0 个赞

@fecshoper #2楼 你mongodb什么版本?稍等我看看

fecshoper#46年前 0 个赞

@Terry #3楼 2.4.9

Fecmall#56年前 0 个赞

@fecshoper [#2楼](#comment2) 将文件: https://github.com/fecshop/yii2_fecshop/blob/master/services/search/MongoSearch.php

133 行代码部分:

$one['name'] = Yii::$service->fecshoplang->getLangAttrVal($one_name, 'name', $langCode);
                            $one['description'] = Yii::$service->fecshoplang->getLangAttrVal($one_description, 'description', $langCode);
                            $one['short_description'] = Yii::$service->fecshoplang->getLangAttrVal($one_short_description, 'short_description', $langCode);
                            $one['sync_updated_at'] = time();
                            Yii::$service->helper->ar->save($searchModel, $one);

改成:

$one['name'] = Yii::$service->fecshoplang->getLangAttrVal($one_name, 'name', $langCode);
                            $one['description'] = Yii::$service->fecshoplang->getLangAttrVal($one_description, 'description', $langCode);
                            $one['short_description'] = Yii::$service->fecshoplang->getLangAttrVal($one_short_description, 'short_description', $langCode);
                            $one['sync_updated_at'] = time();
							unset($one['_id']);
                            Yii::$service->helper->ar->save($searchModel, $one);

也就是添加代码: unset($one['_id']);

试试可以不? 如果可以,告诉我下

fecshoper#66年前 0 个赞

@Terry [[#5楼](#comment5)](#comment5) 好了,是什么原因

另外上传图片很慢,是国外申请的域名,如果在本地,能不能不要通过域名保存?

Fecmall#76年前 0 个赞

@fecshoper #6楼 是个bug...,应该要删除掉 _id 数据的,虽然在我的3.2里面没有报错。

Fecmall#86年前 0 个赞

@fecshoper #6楼 已修复,一会fecshop也更新下,多谢提交,后面有问题提交过来,用的次数多少,bug就会越来越少,系统也越来越稳定。

fecshoper#96年前 0 个赞

@Terry #8楼 好,希望你的系统用的越来越多,另外图片上传慢,怎么解决

Fecmall#106年前 0 个赞

@fecshoper #9楼 服务器在国外?还是国内,这个和网速有关系。

你可以开多个浏览器窗口编辑产品,这个窗口上传图片,另外一个窗口编辑,等这个编辑完成文字部分,另外一个图片保存也就成功了。

fecshoper#116年前 0 个赞

@Terry #10楼 国外服务器,你是通过域名保存的图片,还是机器的相对路径保存的?

Fecmall#126年前 0 个赞

@fecshoper #11楼 图片上传到服务器,然后保存到服务器,不明白你想要表达的意思, 目前不支持用图片服务器,不过你可以重构,更详细的,你可以查看源码。

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics