robuust / craft-reverserelations

Reverse Relations for Craft
MIT License
12 stars 15 forks source link

yii\base\InvalidArgumentException: Invalid field UID: 879bbadb-a3aa-4f41-a7d0-08455014431e in /app/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php:109 #36

Closed jamesmacwhite closed 2 years ago

jamesmacwhite commented 2 years ago

I'm getting the following error repeated in the Yii Debug toolbar, along with another UID reference

Both UIDs relates to a Reverse Relations Entry field on specific entry types.

I don't know if this is related to either out of sync project config or if it's an issue with the plugin.

I couldn't find much specific info around the Invalid field UID, but just wondered if there was anything in the plugin that could be causing it?

The error isn't happening on saves and such, but is being raised by the app generally.

yii\base\InvalidArgumentException: Invalid field UID: 879bbadb-a3aa-4f41-a7d0-08455014431e in /app/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php:109
Stack trace:
#0 /app/vendor/yiisoft/yii2/base/BaseObject.php(159): craft\fieldlayoutelements\CustomField->setFieldUid('879bbadb-a3aa-4...')
#1 /app/vendor/yiisoft/yii2/BaseYii.php(558): yii\base\BaseObject->__set('fieldUid', '879bbadb-a3aa-4...')
#2 /app/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure(Object(craft\fieldlayoutelements\CustomField), Array)
#3 /app/vendor/craftcms/cms/src/fieldlayoutelements/BaseField.php(59): yii\base\BaseObject->__construct(Array)
#4 /app/vendor/craftcms/cms/src/fieldlayoutelements/CustomField.php(39): craft\fieldlayoutelements\BaseField->__construct(Array)
#5 [internal function]: craft\fieldlayoutelements\CustomField->__construct(NULL, Array)
#6 /app/vendor/yiisoft/yii2/di/Container.php(419): ReflectionClass->newInstanceArgs(Array)
#7 /app/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build('craft\\fieldlayo...', Array, Array)
#8 /app/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('craft\\fieldlayo...', Array, Array)
#9 /app/vendor/craftcms/cms/src/Craft.php(61): yii\BaseYii::createObject(Array, Array)
#10 /app/vendor/craftcms/cms/src/services/Fields.php(1345): Craft::createObject(Array)
#11 /app/vendor/craftcms/cms/src/models/FieldLayoutTab.php(141): craft\services\Fields->createLayoutElement(Array)
#12 /app/vendor/yiisoft/yii2/base/BaseObject.php(109): craft\models\FieldLayoutTab->init()
#13 /app/vendor/craftcms/cms/src/services/Fields.php(1230): yii\base\BaseObject->__construct(Array)
#14 /app/vendor/craftcms/cms/src/services/Fields.php(1252): craft\services\Fields->_createLayoutTabFromRow(Array, true)
#15 /app/vendor/craftcms/cms/src/services/Fields.php(1138): craft\services\Fields->_loadTabs(Array)
#16 /app/vendor/craftcms/cms/src/services/Sections.php(1032): craft\services\Fields->getLayoutsByIds(Array)
#17 /app/vendor/craftcms/cms/src/services/Sections.php(1009): craft\services\Sections->_entryTypes()
#18 /app/vendor/craftcms/cms/src/models/Section.php(334): craft\services\Sections->getEntryTypesBySectionId(30)
#19 /app/vendor/craftcms/cms/src/elements/Entry.php(1152): craft\models\Section->getEntryTypes()
#20 /app/vendor/craftcms/cms/src/controllers/EntriesController.php(731): craft\elements\Entry->getType()
#21 /app/vendor/craftcms/cms/src/controllers/EntriesController.php(86): craft\controllers\EntriesController->_prepEditEntryVariables(Array)
#22 [internal function]: craft\controllers\EntriesController->actionEditEntry('apprenticeships', 27, NULL, NULL, NULL, NULL)
#23 /app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#24 /app/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#25 /app/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('edit-entry', Array)
#26 /app/vendor/craftcms/cms/src/web/Application.php(293): yii\base\Module->runAction('entries/edit-en...', Array)
#27 /app/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('entries/edit-en...', Array)
#28 /app/vendor/craftcms/cms/src/web/Application.php(278): yii\web\Application->handleRequest(Object(craft\web\Request))
#29 /app/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#30 /app/web/index.php(12): yii\base\Application->run()
#31 {main}
boboldehampsink commented 2 years ago

This mostly occurs when your project config is out of sync. Try to search for the UID in your project config and see if something seems corrupt.

jamesmacwhite commented 2 years ago

Thanks for the quick response. I've searched the UID and found it relates to the Reverse Relations Entry fields, there are two in this project, one each assigned to the entry types in certain sections and that's what is triggering it. I have tried resaving the field, but it doesn't seem to have changed much project config wise.

boboldehampsink commented 2 years ago

Can you remove and add the field again, see if that fixes it?

jamesmacwhite commented 2 years ago

I'll do some debugging, this was originally from a Craft CMS 2 migration, where a Craft CMS 3 migration replaced the Craft CMS 2 field with a Craft CMS 3 field and it's possible that migration could have created the new field incorrectly.

Now that the project has been migrated from Craft CMS 2 with project config implemented (as it was disabled during the Craft CMS 2 to 3 development) I'll see if it can fix it.

Thanks for your guidance.

jamesmacwhite commented 2 years ago

I ended up creating the two Reverse Relation fields and then re-adding the field to the entry types they were on. This seems to have cleared the issue once resaving the entry types.

Looking at the project config changes, it seems the type when re-saving after recreating and re-saving was changed from craft\fieldlayoutelements\CustomField to craft\fieldlayoutelements\EntryTitleField, which possibly seems to be where the issue was, as the stacktrace showed CustomField related errors.