verbb / field-manager

Field Manager is a Craft CMS plugin to make it easy to manage your fields and field groups.
MIT License
199 stars 16 forks source link

UnknownPropertyException: Setting unknown property #51

Closed davidrapson closed 5 years ago

davidrapson commented 6 years ago

Description

Recently when performing an import fields were reported as importing successfully but upon reloading all Craft pages return a fatal error. The only way to recover was to manually go into the database and remove the newly added fields directly.

Here is the stack trace:

yii\base\UnknownPropertyException: Setting unknown property: craft\behaviors\ContentBehavior::programmePartnersIntro in /var/app/current/vendor/yiisoft/yii2/base/BaseObject.php:163
Stack trace:
#0 /var/app/current/storage/runtime/compiled_classes/ContentBehavior.php(562): yii\base\BaseObject->__set('programmePartne...', NULL)
#1 /var/app/current/vendor/craftcms/cms/src/base/Element.php(1625): craft\behaviors\ContentBehavior->__set('programmePartne...', NULL)
#2 /var/app/current/vendor/craftcms/cms/src/base/Element.php(1604): craft\base\Element->setFieldValue('programmePartne...', NULL)
#3 /var/app/current/vendor/craftcms/cms/src/elements/db/ElementQuery.php(2223): craft\base\Element->setFieldValues(Array)
#4 /var/app/current/vendor/craftcms/cms/src/elements/db/ElementQuery.php(2144): craft\elements\db\ElementQuery->_createElement(Array)
#5 /var/app/current/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1139): craft\elements\db\ElementQuery->_createElements(Array)
#6 /var/app/current/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1184): craft\elements\db\ElementQuery->populate(Array)
#7 /var/app/current/vendor/craftcms/cms/src/elements/User.php(355): craft\elements\db\ElementQuery->one()
#8 /var/app/current/vendor/yiisoft/yii2/web/User.php(690): craft\elements\User::findIdentity('103')
#9 /var/app/current/vendor/craftcms/cms/src/web/User.php(412): yii\web\User->renewAuthStatus()
#10 /var/app/current/vendor/yiisoft/yii2/web/User.php(192): craft\web\User->renewAuthStatus()
#11 /var/app/current/vendor/craftcms/cms/src/web/twig/Extension.php(905): yii\web\User->getIdentity()
#12 /var/app/current/vendor/twig/twig/lib/Twig/ExtensionSet.php(339): craft\web\twig\Extension->getGlobals()
#13 /var/app/current/vendor/twig/twig/lib/Twig/Environment.php(903): Twig_ExtensionSet->getGlobals()
#14 /var/app/current/vendor/twig/twig/lib/Twig/Environment.php(923): Twig_Environment->getGlobals()
#15 /var/app/current/vendor/twig/twig/lib/Twig/Template.php(367): Twig_Environment->mergeGlobals(Array)
#16 /var/app/current/vendor/craftcms/cms/src/web/twig/Template.php(31): Twig_Template->display(Array, Array)
#17 /var/app/current/vendor/twig/twig/lib/Twig/Template.php(375): craft\web\twig\Template->display(Array)
#18 /var/app/current/vendor/twig/twig/lib/Twig/Environment.php(289): Twig_Template->render(Array)
#19 /var/app/current/vendor/craftcms/cms/src/web/View.php(330): Twig_Environment->render('500', Array)
#20 /var/app/current/vendor/craftcms/cms/src/web/View.php(377): craft\web\View->renderTemplate('500', Array)
#21 /var/app/current/vendor/craftcms/cms/src/web/Controller.php(155): craft\web\View->renderPageTemplate('500', Array)
#22 /var/app/current/vendor/craftcms/cms/src/controllers/TemplatesController.php(209): craft\web\Controller->renderTemplate('500', Array)
#23 [internal function]: craft\controllers\TemplatesController->actionRenderError()
#24 /var/app/current/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#25 /var/app/current/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#26 /var/app/current/vendor/craftcms/cms/src/web/Controller.php(103): yii\base\Controller->runAction('render-error', Array)
#27 /var/app/current/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('render-error', Array)
#28 /var/app/current/vendor/craftcms/cms/src/web/Application.php(282): yii\base\Module->runAction('templates/rende...', Array)
#29 /var/app/current/vendor/yiisoft/yii2/web/ErrorHandler.php(108): craft\web\Application->runAction('templates/rende...')
#30 /var/app/current/vendor/craftcms/cms/src/web/ErrorHandler.php(156): yii\web\ErrorHandler->renderException(Object(yii\base\UnknownPropertyException))
#31 /var/app/current/vendor/yiisoft/yii2/base/ErrorHandler.php(111): craft\web\ErrorHandler->renderException(Object(yii\base\UnknownPropertyException))
#32 /var/app/current/vendor/craftcms/cms/src/web/ErrorHandler.php(71): yii\base\ErrorHandler->handleException(Object(yii\base\UnknownPropertyException))
#33 [internal function]: craft\web\ErrorHandler->handleException(Object(yii\base\UnknownPropertyException))

Steps to reproduce

The following is the export.json that caused the error

[
    {
        "name": "Programme Partners",
        "handle": "programmePartners",
        "instructions": "",
        "required": null,
        "translationMethod": "site",
        "translationKeyFormat": null,
        "type": "craft\\fields\\Matrix",
        "settings": {
            "minBlocks": 1,
            "maxBlocks": "",
            "localizeBlocks": "",
            "blockTypes": {
                "new1": {
                    "name": "Partner",
                    "handle": "partner",
                    "fields": {
                        "new1": {
                            "name": "Partner Title",
                            "handle": "partnerTitle",
                            "required": 1,
                            "instructions": "",
                            "translationMethod": "site",
                            "translationKeyFormat": null,
                            "type": "craft\\fields\\PlainText",
                            "typesettings": {
                                "placeholder": "",
                                "code": "",
                                "multiline": "",
                                "initialRows": 4,
                                "charLimit": "",
                                "columnType": "text"
                            }
                        },
                        "new2": {
                            "name": "Partner Subtitle",
                            "handle": "partnerSubtitle",
                            "required": 0,
                            "instructions": "",
                            "translationMethod": "site",
                            "translationKeyFormat": null,
                            "type": "craft\\fields\\PlainText",
                            "typesettings": {
                                "placeholder": "",
                                "code": "",
                                "multiline": "",
                                "initialRows": 4,
                                "charLimit": "",
                                "columnType": "text"
                            }
                        },
                        "new3": {
                            "name": "Partner Logo",
                            "handle": "partnerLogo",
                            "required": 0,
                            "instructions": "",
                            "translationMethod": "site",
                            "translationKeyFormat": null,
                            "type": "craft\\fields\\Assets",
                            "typesettings": {
                                "useSingleFolder": 1,
                                "defaultUploadLocationSource": "folder:5",
                                "defaultUploadLocationSubpath": "",
                                "singleUploadLocationSource": "folder:5",
                                "singleUploadLocationSubpath": "programme-partners",
                                "restrictFiles": 1,
                                "allowedKinds": [
                                    "image"
                                ],
                                "sources": "*",
                                "source": null,
                                "targetSiteId": null,
                                "viewMode": "list",
                                "limit": 1,
                                "selectionLabel": "Add a logo",
                                "localizeRelations": ""
                            }
                        },
                        "new4": {
                            "name": "Partner Description",
                            "handle": "partnerDescription",
                            "required": 1,
                            "instructions": "",
                            "translationMethod": "site",
                            "translationKeyFormat": null,
                            "type": "craft\\fields\\PlainText",
                            "typesettings": {
                                "placeholder": "",
                                "code": "",
                                "multiline": "",
                                "initialRows": 4,
                                "charLimit": "",
                                "columnType": "text"
                            }
                        },
                        "new5": {
                            "name": "Partner URL",
                            "handle": "partnerUrl",
                            "required": 0,
                            "instructions": "",
                            "translationMethod": "site",
                            "translationKeyFormat": null,
                            "type": "craft\\fields\\Url",
                            "typesettings": []
                        }
                    }
                }
            }
        }
    },
    {
        "name": "Programme Partners Intro",
        "handle": "programmePartnersIntro",
        "instructions": "",
        "required": null,
        "translationMethod": "language",
        "translationKeyFormat": null,
        "type": "craft\\redactor\\Field",
        "settings": {
            "redactorConfig": "Basics.json",
            "purifierConfig": "",
            "cleanupHtml": 1,
            "purifyHtml": 1,
            "columnType": "text",
            "availableVolumes": "",
            "availableTransforms": ""
        }
    },
    {
        "name": "Research Partners Intro",
        "handle": "researchPartnersIntro",
        "instructions": "",
        "required": null,
        "translationMethod": "site",
        "translationKeyFormat": null,
        "type": "craft\\redactor\\Field",
        "settings": {
            "redactorConfig": "Basics.json",
            "purifierConfig": "",
            "cleanupHtml": 1,
            "purifyHtml": 1,
            "columnType": "text",
            "availableVolumes": "",
            "availableTransforms": ""
        }
    },
    {
        "name": "Strategic Programme Aims",
        "handle": "strategicProgrammeAims",
        "instructions": "",
        "required": null,
        "translationMethod": "language",
        "translationKeyFormat": null,
        "type": "craft\\redactor\\Field",
        "settings": {
            "redactorConfig": "Full.json",
            "purifierConfig": "safe-iframe-media.json",
            "cleanupHtml": 1,
            "purifyHtml": 1,
            "columnType": "text",
            "availableVolumes": "*",
            "availableTransforms": "*"
        }
    },
    {
        "name": "Strategic Programme Impact",
        "handle": "strategicProgrammeImpact",
        "instructions": "",
        "required": null,
        "translationMethod": "site",
        "translationKeyFormat": null,
        "type": "craft\\fields\\Matrix",
        "settings": {
            "minBlocks": 1,
            "maxBlocks": "",
            "localizeBlocks": "",
            "blockTypes": {
                "new1": {
                    "name": "Content Area",
                    "handle": "contentArea",
                    "fields": {
                        "new1": {
                            "name": "Title",
                            "handle": "contentTitle",
                            "required": 1,
                            "instructions": "",
                            "translationMethod": "site",
                            "translationKeyFormat": null,
                            "type": "craft\\fields\\PlainText",
                            "typesettings": {
                                "placeholder": "",
                                "code": "",
                                "multiline": "",
                                "initialRows": 4,
                                "charLimit": "",
                                "columnType": "text"
                            }
                        },
                        "new2": {
                            "name": "Content",
                            "handle": "contentBody",
                            "required": 1,
                            "instructions": "",
                            "translationMethod": "site",
                            "translationKeyFormat": null,
                            "type": "craft\\redactor\\Field",
                            "typesettings": {
                                "redactorConfig": "Basics.json",
                                "purifierConfig": "",
                                "cleanupHtml": 1,
                                "purifyHtml": 1,
                                "columnType": "text",
                                "availableVolumes": "",
                                "availableTransforms": ""
                            }
                        }
                    }
                }
            }
        }
    }
]

There's quite a few fields here, but none use custom field plugins, all default Craft fields.

Additional info

jsunsawyer commented 6 years ago

I just ran into this same issue when importing several fields for a new section on our production site.

Plugin version: 2.0.2 Craft version: 3.0.25

engram-design commented 6 years ago

@davidrapson Sorry for the delay, but I'm unable to reproduce this I'm afraid. Certainly seems like it didn't import properly, and I know Craft 3 can be a little more 'fatal' when field errors occur (as in, you can't load any CP page).

@jsunsawyer Don't suppose you'd be able to supply your field import JSON?

jsunsawyer commented 6 years ago

@engram-design Sent you an export of my field in the Craft slack.

I did create a new field group and added each new field to it when I experienced the issue. Might be worth testing that as well.

engram-design commented 5 years ago

Should be fixed in 2.1.0