verbb / vizy

A flexible visual editor for Craft CMS
Other
44 stars 8 forks source link

Vizy tries to assign deleted fields in matrix #49

Closed dyerc closed 3 years ago

dyerc commented 3 years ago

Description

Unknown Property – yii\base\UnknownPropertyException
Setting unknown property: craft\behaviors\CustomFieldBehavior::linkTitle
[1] vendor/yiisoft/yii2/base/BaseObject.php
[2] storage/runtime/compiled_classes/CustomFieldBehavior_mobkndtzpbim.php – yii\base\BaseObject::__set('linkTitle', '')
[3] vendor/craftcms/cms/src/base/Element.php – craft\behaviors\CustomFieldBehavior::__set('linkTitle', '')
[4] vendor/craftcms/cms/src/base/Element.php – craft\base\Element::setFieldValue('linkTitle', '')
[5] vendor/craftcms/cms/src/fields/Matrix.php – craft\base\Element::setFieldValues([...])
[6] vendor/craftcms/cms/src/fields/Matrix.php– craft\fields\Matrix::_createBlocksFromSerializedData([...], verbb\vizy\elements\Block)
...
[10] vendor/craftcms/cms/src/fieldlayoutelements/BaseField.php – craft\fieldlayoutelements\CustomField::inputHtml(verbb\vizy\elements\Block, false)

I feel like Vizy needs to check whether all of the matrix fields exist before trying to assign stored json to it. In Craft's _createBlocksFromSerializedData function it doesn't appear to be doing this.

Steps to reproduce

  1. Create a Vizy field with a matrix block and multiple fields
  2. Create an entry and fill out the matrix fields
  3. Delete one of the matrix sub fields entirely
  4. Return to try and edit the entry. This results in a crash

Additional info

Additional context

engram-design commented 3 years ago

Yeah, this is one of the annoying things I find with Craft/Yii, in that it's not exactly friendly if you try and save a property on a model for a property that no longer exists. You'd get the same issue if you tried to set a custom field on an element (Entry/Matrix block) for something that didn't exist.

But yep, something we need to address. Thanks so much for your PR!

engram-design commented 3 years ago

Added in 1.0.3