craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

Error Invalid owner ID MatrixBlock after saving existing entry [3.x]: #11463

Closed FabioIaderosa closed 2 years ago

FabioIaderosa commented 2 years ago

What happened?

Description

After upgrading the cms to version 3.7.43, resaving existing entries which have matrix field included, throw an 503 error and give a blank screen. Looking at the log files and stack tracks, There is the following error: The error only happens to only existing entries, newly created ones are working.

Full trace:

2022-06-20 13:49:43 [-][21533][ffskmrropgbmc3nvs1t2k2bebh][error][yii\base\InvalidConfigException] yii\base\InvalidConfigException: Invalid owner ID: 21874 in /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/elements/MatrixBlock.php:320
Stack trace:
#0 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/helpers/ElementHelper.php(413): craft\elements\MatrixBlock->getOwner()
#1 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/helpers/ElementHelper.php(439): craft\helpers\ElementHelper::rootElement(Object(craft\elements\MatrixBlock))
#2 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/services/Elements.php(2802): craft\helpers\ElementHelper::isRevision(Object(craft\elements\MatrixBlock))
#3 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/services/Elements.php(2968): craft\services\Elements->_saveElementInternal(Object(craft\elements\MatrixBlock), true, false, true, Array)
#4 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/services/Elements.php(2747): craft\services\Elements->_propagateElement(Object(craft\elements\MatrixBlock), Array, 3, Object(craft\elements\MatrixBlock))
#5 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/services/Elements.php(785): craft\services\Elements->_saveElementInternal(Object(craft\elements\MatrixBlock), false, true, true)
#6 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/services/Matrix.php(714): craft\services\Elements->saveElement(Object(craft\elements\MatrixBlock), false)
#7 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/fields/Matrix.php(1055): craft\services\Matrix->saveField(Object(craft\fields\Matrix), Object(craft\elements\Entry))
#8 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/base/Element.php(4160): craft\fields\Matrix->afterElementPropagate(Object(craft\elements\Entry), false)
#9 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/elements/Entry.php(1722): craft\base\Element->afterPropagate(false)
#10 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/services/Elements.php(2759): craft\elements\Entry->afterPropagate(false)
#11 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/services/Elements.php(785): craft\services\Elements->_saveElementInternal(Object(craft\elements\Entry), true, false, true)
#12 /var/www/vhosts/sitename/test/data/backend/modules/menatwork/listeners/SaveListener.php(70): craft\services\Elements->saveElement(Object(craft\elements\Entry), true, false)
#13 [internal function]: modules\menatwork\listeners\SaveListener->addAlgoliaSlug(Object(craft\events\ModelEvent))
#14 /var/www/vhosts/sitename/test/data/backend/vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Array, Object(craft\events\ModelEvent))
#15 /var/www/vhosts/sitename/test/data/backend/vendor/yiisoft/yii2/base/Component.php(642): yii\base\Event::trigger('craft\\elements\\...', 'afterSave', Object(craft\events\ModelEvent))
#16 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/base/Element.php(4148): yii\base\Component->trigger('afterSave', Object(craft\events\ModelEvent))
#17 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/elements/Entry.php(1680): craft\base\Element->afterSave(true)
#18 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/services/Elements.php(2716): craft\elements\Entry->afterSave(true)
#19 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/services/Elements.php(1245): craft\services\Elements->_saveElementInternal(Object(craft\elements\Entry), false, false, true, Array)
#20 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/services/Revisions.php(168): craft\services\Elements->duplicateElement(Object(craft\elements\Entry), Array)
#21 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/elements/Entry.php(1726): craft\services\Revisions->createRevision(Object(craft\elements\Entry), 21533, '')
#22 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/services/Elements.php(2759): craft\elements\Entry->afterPropagate(false)
#23 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/services/Elements.php(785): craft\services\Elements->_saveElementInternal(Object(craft\elements\Entry), true, false, true)
#24 /var/www/vhosts/sitename/test/data/backend/modules/menatwork/listeners/SaveListener.php(70): craft\services\Elements->saveElement(Object(craft\elements\Entry), true, false)
#25 [internal function]: modules\menatwork\listeners\SaveListener->addAlgoliaSlug(Object(craft\events\ModelEvent))
#26 /var/www/vhosts/sitename/test/data/backend/vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Array, Object(craft\events\ModelEvent))
#27 /var/www/vhosts/sitename/test/data/backend/vendor/yiisoft/yii2/base/Component.php(642): yii\base\Event::trigger('craft\\elements\\...', 'afterSave', Object(craft\events\ModelEvent))
#28 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/base/Element.php(4148): yii\base\Component->trigger('afterSave', Object(craft\events\ModelEvent))
#29 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/elements/Entry.php(1680): craft\base\Element->afterSave(false)
#30 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/services/Elements.php(2716): craft\elements\Entry->afterSave(false)
#31 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/services/Elements.php(785): craft\services\Elements->_saveElementInternal(Object(craft\elements\Entry), true, true, true)
#32 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/controllers/EntriesController.php(403): craft\services\Elements->saveElement(Object(craft\elements\Entry))
#33 [internal function]: craft\controllers\EntriesController->actionSaveEntry(false)
#34 /var/www/vhosts/sitename/test/data/backend/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#35 /var/www/vhosts/sitename/test/data/backend/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#36 /var/www/vhosts/sitename/test/data/backend/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('save-entry', Array)
#37 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/web/Application.php(293): yii\base\Module->runAction('entries/save-en...', Array)
#38 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/web/Application.php(602): craft\web\Application->runAction('entries/save-en...', Array)
#39 /var/www/vhosts/sitename/test/data/backend/vendor/craftcms/cms/src/web/Application.php(272): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#40 /var/www/vhosts/sitename/test/data/backend/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#41 /var/www/vhosts/sitename/test/data/backend/web/index.php(21): yii\base\Application->run()
#42 {main}

Steps to reproduce

  1. Change content of existing entries
  2. Save entry

Expected behavior

New content of existing entry can be saved.

Actual behavior

New content of existing entry cannot be saved.

Craft CMS version

3.7.43

PHP version

7.3.33

Operating system and version

Linux 4.15.0-169-generic

Database type and version

MySQL 5.5.5

Image driver and version

GD 7.3.33

Installed plugins and versions

brandonkelly commented 2 years ago

The error is getting triggered from your afterSave event handler, modules\menatwork\listeners\SaveListener::addAlgoliaSlug().

If you send your composer.json, composer.lock, and modlues/* files, plus a database backup, over to support@craftcms.com, we can help look into it from there.

FabioIaderosa commented 2 years ago

thanks brandon, i have send the files.

olivierbon commented 2 years ago

Resolved in support!