verbb / vizy

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

Crash when editing fields: TypeError: craft\helpers\StringHelper::encodeMb4(): Argument #1 ($str) must be of type string, null given #130

Closed tremby closed 1 year ago

tremby commented 2 years ago

Description

I just had a crash while editing fields.

Steps to reproduce I was doing a lot of screwing around with fields -- I removed some plugins, I deleted some fields, I didn't pay much regard to what order I was doing things in. But it was something like:

  1. Delete a field which is used in a custom Vizy block from settings -> fields
  2. Make a new similar field, though with a different handle.
  3. Go to edit the Vizy block which used the old field.
  4. See that it has disappeared from the field layout.
  5. Drag in the new replacement field.
  6. Hit save
TypeError: craft\helpers\StringHelper::encodeMb4(): Argument #1 ($str) must be of type string, null given, called in /srv/my-project/vendor/craftcms/cms/src/services/Fields.php on line 1386 and defined in /srv/my-project/vendor/craftcms/cms/src/helpers/StringHelper.php:455
Stack trace:
#0 /srv/my-project/vendor/craftcms/cms/src/services/Fields.php(1386): craft\helpers\StringHelper::encodeMb4(NULL)
#1 /srv/my-project/vendor/verbb/vizy/src/services/Service.php(102): craft\services\Fields->saveLayout(Object(craft\models\FieldLayout))
#2 /srv/my-project/vendor/verbb/vizy/src/services/Service.php(77): verbb\vizy\services\Service->saveField(Array, Object(craft\events\ConfigEvent))
#3 /srv/my-project/vendor/craftcms/cms/src/services/ProjectConfig.php(1118): verbb\vizy\services\Service->handleChangedField(Object(craft\events\ConfigEvent))
#4 [internal function]: craft\services\ProjectConfig->handleChangeEvent(Object(craft\events\ConfigEvent))
#5 /srv/my-project/vendor/yiisoft/yii2/base/Component.php(633): call_user_func(Array, Object(craft\events\ConfigEvent))
#6 /srv/my-project/vendor/craftcms/cms/src/models/ProjectConfigData.php(84): yii\base\Component->trigger('updateItem', Object(craft\events\ConfigEvent))
#7 /srv/my-project/vendor/craftcms/cms/src/services/ProjectConfig.php(507): craft\models\ProjectConfigData->commitChanges(Array, Array, 'fields.c7b3e991...', true, 'Save field \xE2\x80\x9Cc...', true)
#8 /srv/my-project/vendor/craftcms/cms/src/services/Fields.php(806): craft\services\ProjectConfig->set('fields.c7b3e991...', Array, 'Save field \xE2\x80\x9Cc...')
#9 /srv/my-project/vendor/craftcms/cms/src/controllers/FieldsController.php(329): craft\services\Fields->saveField(Object(verbb\vizy\fields\VizyField))
#10 [internal function]: craft\controllers\FieldsController->actionSaveField()
#11 /srv/my-project/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#12 /srv/my-project/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#13 /srv/my-project/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('save-field', Array)
#14 /srv/my-project/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('fields/save-fie...', Array)
#15 /srv/my-project/vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application->runAction('fields/save-fie...', Array)
#16 /srv/my-project/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#17 /srv/my-project/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#18 /srv/my-project/web/index.php(12): yii\base\Application->run()
#19 {main}

Additional info

Additional context Headless mode

tremby commented 2 years ago

If I go to the edit page again and hit save without doing anything, it seems to save OK.

If I try to drag the new field in and save again, I get the crash again.

The field is an "Assets" field, where I've set it to allow images only, and min 1 and max 1 relation.

tremby commented 2 years ago

I deleted the Vizy block and recreated it, and it seems to be behaving now.

engram-design commented 2 years ago

Hmmm, so the error points to creating a tab with no name, although I'm not sure how that'd happen. I'll try to recreate it.

engram-design commented 1 year ago

Couldn't reproduce this one, closing for now.