Closed srosenbrand closed 2 years ago
using {{object.fieldName}} solves the issue
Are you saying that you don’t get the error when you use {{object.fieldName}}
?
What are you entering when you do get the error?
Correct, no more errors with normal syntax. The field was a plain text field.
The errors where visible in the debug toolbar (in logs) everywhere in the CP and front-end, even on the dashboard when no entry was open. When in the entry type field layout designer the amount of errors doubled. Although Craft did work and I could save the entries without problems, I constantly had 19 errors which didn't seem right. When I changed the sections one by one the errors also disappeared one by one.
The weird thing is, I just tried to replicate the issue for you and now shorthand seems to give no errors anymore. I did not run any updates afterwards. Maybe the initiated re-save of entries fixed something else and wasn't the syntax the issue after all?
The complete website was moved yesterday from another hosting provider to Fortrabbit and I updated to Craft 4 just before the errors occurred. Everything is running smooth now!
What was the Title Format you were using that did produce the errors?
It was {mainTitle}
and {shortTitle}
I have the same issue. Our log files are growing every minute by this stack error.
2022-09-29 18:32:48 [web.WARNING] [craft\models\FieldLayoutTab::setElements] Invalid field layout element config: Invalid field layout element class: craft\fieldlayoutelements\EntryTitleField {"memory":18296616}
2022-09-29 18:32:48 [web.ERROR] [yii\base\InvalidArgumentException] yii\base\InvalidArgumentException: Invalid field layout element class: craft\fieldlayoutelements\EntryTitleField in /var/www/project/cms/vendor/craftcms/cms/src/services/Fields.php:1273
Stack trace:
#0 /var/www/project/cms/vendor/craftcms/cms/src/models/FieldLayoutTab.php(288): craft\services\Fields->createLayoutElement(Array)
#1 /var/www/project/cms/vendor/yiisoft/yii2/base/Component.php(180): craft\models\FieldLayoutTab->setElements(Array)
#2 /var/www/project/cms/vendor/yiisoft/yii2/BaseYii.php(558): yii\base\Component->__set('elements', Array)
#3 /var/www/project/cms/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure(Object(craft\models\FieldLayoutTab), Array)
#4 /var/www/project/cms/vendor/craftcms/cms/src/base/Model.php(78): yii\base\BaseObject->__construct(Array)
#5 /var/www/project/cms/vendor/craftcms/cms/src/models/FieldLayoutTab.php(124): craft\base\Model->__construct(Array)
#6 /var/www/project/cms/vendor/craftcms/cms/src/services/Fields.php(1201): craft\models\FieldLayoutTab->__construct(Array)
#7 /var/www/project/cms/vendor/craftcms/cms/src/services/Fields.php(1179): craft\services\Fields->_createLayoutTabFromRow(Array, true)
#8 [internal function]: craft\services\Fields->craft\services\{closure}(Array)
#9 /var/www/project/cms/vendor/craftcms/cms/src/services/Fields.php(1178): array_map(Object(Closure), Array)
#10 /var/www/project/cms/vendor/craftcms/cms/src/models/FieldLayout.php(289): craft\services\Fields->getLayoutTabsById(206)
#11 /var/www/project/cms/vendor/craftcms/cms/src/models/FieldLayout.php(793): craft\models\FieldLayout->getTabs()
#12 /var/www/project/cms/vendor/craftcms/cms/src/models/FieldLayout.php(642): craft\models\FieldLayout->_elements(Object(Closure), NULL)
#13 /var/www/project/cms/vendor/craftcms/cms/src/models/FieldLayout.php(619): craft\models\FieldLayout->_customFields()
#14 /var/www/project/cms/vendor/craftcms/cms/src/behaviors/FieldLayoutBehavior.php(150): craft\models\FieldLayout->getCustomFields()
#15 [internal function]: craft\behaviors\FieldLayoutBehavior->getCustomFields()
#16 /var/www/project/cms/vendor/yiisoft/yii2/base/Component.php(297): call_user_func_array(Array, Array)
#17 /var/www/project/cms/vendor/craftcms/cms/src/services/Gql.php(1161): yii\base\Component->__call('getCustomFields', Array)
#18 /var/www/project/cms/vendor/craftcms/cms/src/gql/arguments/elements/Entry.php(98): craft\services\Gql->getContentArguments(Array, 'craft\\elements\\...')
#19 /var/www/project/cms/vendor/craftcms/cms/src/gql/arguments/elements/Entry.php(29): craft\gql\arguments\elements\Entry::getContentArguments()
#20 /var/www/project/cms/vendor/craftcms/cms/src/fields/Entries.php(80): craft\gql\arguments\elements\Entry::getArguments()
#21 /var/www/project/cms/vendor/craftcms/cms/src/gql/base/Generator.php(47): craft\fields\Entries->getContentGqlType()
#22 /var/www/project/cms/vendor/craftcms/cms/src/gql/types/generators/AssetType.php(59): craft\gql\base\Generator::getContentFields(Object(craft\models\Volume))
#23 /var/www/project/cms/vendor/craftcms/cms/src/gql/types/generators/AssetType.php(46): craft\gql\types\generators\AssetType::generateType(Object(craft\models\Volume))
#24 /var/www/project/cms/vendor/craftcms/cms/src/gql/interfaces/elements/Asset.php(55): craft\gql\types\generators\AssetType::generateTypes()
#25 /var/www/project/cms/vendor/craftcms/cms/src/fields/Assets.php(466): craft\gql\interfaces\elements\Asset::getType()
#26 /var/www/project/cms/vendor/craftcms/cms/src/gql/base/Generator.php(47): craft\fields\Assets->getContentGqlType()
#27 /var/www/project/cms/vendor/verbb/super-table/src/gql/types/generators/SuperTableBlockType.php(50): craft\gql\base\Generator::getContentFields(Object(verbb\supertable\models\SuperTableBlockType))
#28 /var/www/project/cms/vendor/verbb/super-table/src/gql/types/generators/SuperTableBlockType.php(34): verbb\supertable\gql\types\generators\SuperTableBlockType::generateType(Object(verbb\supertable\models\SuperTableBlockType))
#29 /var/www/project/cms/vendor/verbb/super-table/src/gql/interfaces/elements/SuperTableBlock.php(39): verbb\supertable\gql\types\generators\SuperTableBlockType::generateTypes()
#30 /var/www/project/cms/vendor/verbb/super-table/src/gql/types/elements/SuperTableBlock.php(19): verbb\supertable\gql\interfaces\elements\SuperTableBlock::getType()
#31 /var/www/project/cms/vendor/verbb/super-table/src/gql/types/generators/SuperTableBlockType.php(61): verbb\supertable\gql\types\elements\SuperTableBlock->__construct(Array)
#32 /var/www/project/cms/vendor/verbb/super-table/src/gql/types/generators/SuperTableBlockType.php(34): verbb\supertable\gql\types\generators\SuperTableBlockType::generateType(Object(verbb\supertable\models\SuperTableBlockType))
#33 /var/www/project/cms/vendor/verbb/super-table/src/fields/SuperTableField.php(962): verbb\supertable\gql\types\generators\SuperTableBlockType::generateTypes(Object(verbb\supertable\fields\SuperTableField))
#34 /var/www/project/cms/vendor/craftcms/cms/src/gql/base/Generator.php(47): verbb\supertable\fields\SuperTableField->getContentGqlType()
#35 /var/www/project/cms/vendor/craftcms/cms/src/gql/types/generators/MatrixBlockType.php(60): craft\gql\base\Generator::getContentFields(Object(craft\models\MatrixBlockType))
#36 /var/www/project/cms/vendor/craftcms/cms/src/gql/types/generators/MatrixBlockType.php(45): craft\gql\types\generators\MatrixBlockType::generateType(Object(craft\models\MatrixBlockType))
#37 /var/www/project/cms/vendor/craftcms/cms/src/fields/Matrix.php(921): craft\gql\types\generators\MatrixBlockType::generateTypes(Object(craft\fields\Matrix))
#38 /var/www/project/cms/vendor/craftcms/cms/src/gql/base/Generator.php(47): craft\fields\Matrix->getContentGqlType()
#39 /var/www/project/cms/vendor/craftcms/cms/src/gql/types/generators/EntryType.php(58): craft\gql\base\Generator::getContentFields(Object(craft\models\EntryType))
#40 /var/www/project/cms/vendor/craftcms/cms/src/gql/types/generators/EntryType.php(40): craft\gql\types\generators\EntryType::generateType(Object(craft\models\EntryType))
#41 /var/www/project/cms/vendor/craftcms/cms/src/gql/interfaces/elements/Entry.php(54): craft\gql\types\generators\EntryType::generateTypes()
#42 /var/www/project/cms/vendor/craftcms/cms/src/gql/queries/Entry.php(40): craft\gql\interfaces\elements\Entry::getType()
#43 /var/www/project/cms/vendor/craftcms/cms/src/services/Gql.php(1333): craft\gql\queries\Entry::getQueries()
#44 /var/www/project/cms/vendor/craftcms/cms/src/services/Gql.php(366): craft\services\Gql->_registerGqlQueries()
#45 /var/www/project/cms/vendor/craftcms/cms/src/services/Gql.php(501): craft\services\Gql->getSchemaDef(Object(craft\models\GqlSchema), true)
#46 /var/www/project/cms/vendor/craftcms/cms/src/controllers/GraphqlController.php(177): craft\services\Gql->executeQuery(Object(craft\models\GqlSchema), '\n query {\n ...', Array, NULL, true)
#47 [internal function]: craft\controllers\GraphqlController->actionApi()
#48 /var/www/project/cms/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#49 /var/www/project/cms/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#50 /var/www/project/cms/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('api', Array)
#51 /var/www/project/cms/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('graphql/api', Array)
#52 /var/www/project/cms/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('graphql/api', Array)
#53 /var/www/project/cms/vendor/craftcms/cms/src/web/Application.php(286): yii\web\Application->handleRequest(Object(craft\web\Request))
#54 /var/www/project/cms/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#55 /var/www/project/cms/web/index.php(21): yii\base\Application->run()
#56 {main} {"memory":18296992,"exception":"[object] (yii\\base\\InvalidArgumentException(code: 0): Invalid field layout element class: craft\\fieldlayoutelements\\EntryTitleField at /var/www/project/cms/vendor/craftcms/cms/src/services/Fields.php:1273)"}
It's not only in the GQL, also have it on various places.
2022-09-29 18:49:05 [web.ERROR] [yii\base\InvalidArgumentException] yii\base\InvalidArgumentException: Invalid field layout element class: craft\fieldlayoutelements\EntryTitleField in /var/www/project/cms/vendor/craftcms/cms/src/services/Fields.php:1273
Stack trace:
#0 /var/www/project/cms/vendor/craftcms/cms/src/models/FieldLayoutTab.php(288): craft\services\Fields->createLayoutElement(Array)
#1 /var/www/project/cms/vendor/yiisoft/yii2/base/Component.php(180): craft\models\FieldLayoutTab->setElements(Array)
#2 /var/www/project/cms/vendor/yiisoft/yii2/BaseYii.php(558): yii\base\Component->__set('elements', Array)
#3 /var/www/project/cms/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure(Object(craft\models\FieldLayoutTab), Array)
#4 /var/www/project/cms/vendor/craftcms/cms/src/base/Model.php(78): yii\base\BaseObject->__construct(Array)
#5 /var/www/project/cms/vendor/craftcms/cms/src/models/FieldLayoutTab.php(124): craft\base\Model->__construct(Array)
#6 /var/www/project/cms/vendor/craftcms/cms/src/services/Fields.php(1201): craft\models\FieldLayoutTab->__construct(Array)
#7 /var/www/project/cms/vendor/craftcms/cms/src/services/Fields.php(1179): craft\services\Fields->_createLayoutTabFromRow(Array, true)
#8 [internal function]: craft\services\Fields->craft\services\{closure}(Array)
#9 /var/www/project/cms/vendor/craftcms/cms/src/services/Fields.php(1178): array_map(Object(Closure), Array)
#10 /var/www/project/cms/vendor/craftcms/cms/src/services/Fields.php(1215): craft\services\Fields->getLayoutTabsById(Array)
#11 /var/www/project/cms/vendor/craftcms/cms/src/services/Fields.php(1097): craft\services\Fields->_loadTabs(Array)
#12 /var/www/project/cms/vendor/craftcms/cms/src/services/Sections.php(976): craft\services\Fields->getLayoutsByIds(Array)
#13 /var/www/project/cms/vendor/craftcms/cms/src/services/Sections.php(1047): craft\services\Sections->_entryTypes()
#14 /var/www/project/cms/vendor/craftcms/cms/src/elements/db/EntryQuery.php(402): craft\services\Sections->getEntryTypesByHandle('contentPage')
#15 /var/www/project/cms/vendor/craftcms/cms/src/helpers/Db.php(889): craft\elements\db\EntryQuery->craft\elements\db\{closure}('contentPage')
#16 /var/www/project/cms/vendor/craftcms/cms/src/helpers/Db.php(870): craft\helpers\Db::normalizeParam(Array, Object(Closure))
#17 /var/www/project/cms/vendor/craftcms/cms/src/elements/db/EntryQuery.php(405): craft\helpers\Db::normalizeParam('contentPage', Object(Closure))
#18 /var/www/project/cms/config/typesense.php(310): craft\elements\db\EntryQuery->type('contentPage')
#19 /var/www/project/cms/vendor/percipiolondon/craft-typesense/src/TypesenseCollectionIndex.php(57): craft\services\Config->{closure}(Object(craft\elements\db\EntryQuery))
#20 /var/www/project/cms/config/typesense.php(311): percipiolondon\typesense\TypesenseCollectionIndex->criteria(Object(Closure))
#21 /var/www/project/cms/vendor/craftcms/cms/src/services/Config.php(289): include('/var/www/projec...')
#22 /var/www/project/cms/vendor/craftcms/cms/src/services/Config.php(281): craft\services\Config->_configFromFileInternal('/var/www/projec...')
#23 /var/www/project/cms/vendor/craftcms/cms/src/services/Plugins.php(934): craft\services\Config->getConfigFromFile('typesense')
#24 /var/www/project/cms/vendor/craftcms/cms/src/services/Plugins.php(228): craft\services\Plugins->createPlugin('typesense', Array)
#25 /var/www/project/cms/vendor/craftcms/cms/src/base/ApplicationTrait.php(1477): craft\services\Plugins->loadPlugins()
#26 /var/www/project/cms/vendor/craftcms/cms/src/web/Application.php(105): craft\web\Application->_postInit()
#27 /var/www/project/cms/vendor/yiisoft/yii2/base/BaseObject.php(109): craft\web\Application->init()
#28 /var/www/project/cms/vendor/yiisoft/yii2/base/Application.php(204): yii\base\BaseObject->__construct(Array)
#29 [internal function]: yii\base\Application->__construct(Array)
#30 /var/www/project/cms/vendor/yiisoft/yii2/di/Container.php(419): ReflectionClass->newInstanceArgs(Array)
#31 /var/www/project/cms/vendor/yiisoft/yii2/di/Container.php(170): yii\di\Container->build('craft\\web\\Appli...', Array, Array)
#32 /var/www/project/cms/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('craft\\web\\Appli...', Array, Array)
#33 /var/www/project/cms/vendor/craftcms/cms/src/Craft.php(53): yii\BaseYii::createObject(Array, Array)
#34 /var/www/project/cms/vendor/craftcms/cms/bootstrap/bootstrap.php(239): Craft::createObject(Array)
#35 /var/www/project/cms/vendor/craftcms/cms/bootstrap/web.php(40): require('/var/www/projec...')
#36 /var/www/project/cms/web/index.php(20): require('/var/www/projec...')
#37 {main} {"memory":17287224,"exception":"[object] (yii\\base\\InvalidArgumentException(code: 0): Invalid field layout element class: craft\\fieldlayoutelements\\EntryTitleField at /var/www/project/cms/vendor/craftcms/cms/src/services/Fields.php:1273)"}
@cookie10codes did you also recently upgrade from 3 -> 4?
@brianjhanson yes, it occurred right after the upgrade
I'm not 100% sure yet, but my hunch is that something went wrong with this migration. That migration should convert instances of craft\fieldlayoutelements\EntryTitleField
(3.x class) to craft\fieldlayoutelements\entries\EntryTitleField
(4.x class).
The stack trace, looks like Craft is trying to load the 3.x version in your 4.x install.
If you look in project > entryTypes
yaml files do you see instances of craft\fieldlayoutelements\EntryTitleField
in there? If so, what was the value in the project config before the upgrade?
Hello @brianjhanson 👋🏼
Sorry for the late response, seems I didn't get the notification. My error logs are throwing Invalid field layout element class: craft\\fieldlayoutelements\\EntryTitleField at /var/www/project/cms/vendor/craftcms/cms/src/services/Fields.php:1273
and my yaml file where that dynamic title lives gives me craft\fieldlayoutelements\entries\EntryTitleField
Does this gives you the information you need? I can always provide more if you want to. Anything to resolve this issue so we don't need to delete the logs every minute on production 😬
Any chance you can send your composer.json
, composer.lock
, project config files and a database dump over to support@craftcms.com so I can try to tack this down?
Thanks for sending those files @cookie10codes! I was able to track this down to some errant values in fieldlayouttabs
DB table. It looks like at some point the database and the project config diverged a bit.
Can you both run project-config/apply --force
and see if that helps?
@brianjhanson @srosenbrand this fixed my issue, thanks!
What happened?
Description
When using Dynamic Entry Titles on entries / sections / entry types an error gets thrown in the logs.
yii\base\InvalidArgumentException: Invalid field layout element class: craft\fieldlayoutelements\EntryTitleField in /PATHTOPROJECT/vendor/craftcms/cms/src/services/Fields.php:1273
Steps to reproduce
Expected behavior
No errors
Actual behavior
An error that takes hours of searching to find fix for ;-)
Craft CMS version
4.2.3
PHP version
8.0.8
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
-