verbb / hyper

A Craft CMS plugin for managing links, focusing on user experience.
Other
22 stars 12 forks source link

Craft 4: TypedLinkField Migration failes on "processFieldSettings" with empty Exception [] #187

Closed LeoWie93 closed 2 weeks ago

LeoWie93 commented 3 weeks ago

Describe the bug

Hey

We are testing this plugins migration tool and stumble over the following error.

The field 'siteNavigationBlockCallToAction` is inside a normal matrix. (not supertable, but the plugin is installed and used in other areas)

Preparing to migrate field “eventLink” (2e14dccd-884e-40b1-bf35-3d35ae8101a4).
    > Field “eventLink” migrated.

Preparing to migrate field “callToAction” (9d9a97d5-f413-4493-add5-a02317d909ff).
    > Field “callToAction” migrated.

Preparing to migrate field “siteNavigationBlockCallToAction” (db4ddaf1-b195-4cd6-8509-e784c943bb19).
Exception: [] (/app/vendor/verbb/hyper/src/migrations/MigrateTypedLinkField.php:161)
#0 /app/vendor/verbb/hyper/src/migrations/PluginFieldMigration.php(46): verbb\hyper\migrations\MigrateTypedLinkField->processFieldSettings()
#1 /app/vendor/craftcms/cms/src/db/Migration.php(50): verbb\hyper\migrations\PluginFieldMigration->safeUp()
#2 /app/vendor/verbb/hyper/src/console/controllers/MigrateController.php(110): craft\db\Migration->up()
#3 /app/vendor/verbb/hyper/src/console/controllers/MigrateController.php(65): verbb\hyper\console\controllers\MigrateController->_migrate('verbb\\hyper\\mig...')
#4 [internal function]: verbb\hyper\console\controllers\MigrateController->actionTypedLinkField()
#5 /app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#6 /app/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#7 /app/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction('typed-link-fiel...', Array)
#8 /app/vendor/yiisoft/yii2/base/Module.php(552): yii\console\Controller->runAction('typed-link-fiel...', Array)
#9 /app/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('hyper/migrate/t...', Array)
#10 /app/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction('hyper/migrate/t...', Array)
#11 /app/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('hyper/migrate/t...', Array)
#12 /app/vendor/craftcms/cms/src/console/Application.php(122): yii\console\Application->handleRequest(Object(craft\console\Request))
#13 /app/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest(Object(craft\console\Request))
#14 /app/craft(13): yii\base\Application->run()
#15 {main}
136e7952f570:/app$ 

Steps to reproduce

  1. Install Hyper Plugin
  2. Run ./craft hyper/migrate/typed-link-field
  3. Get the error

Craft CMS version

4.11.3

Plugin version

1.2.1

Multi-site?

No

Additional context

It looks really similiar to this issue: https://github.com/verbb/hyper/issues/102

But our fields do have really specific field handles.

engram-design commented 3 weeks ago

So there's an error saving the Matrix field, but there are no listed Matrix Block Type errors. Can you send through the export of your Matrix field (using Field Manager, and you're welcome to send to support@verbb.io) so I can replicate your field on my end. This would be before starting anything to do with Hyper migrations.

LeoWie93 commented 3 weeks ago

So there's an error saving the Matrix field, but there are no listed Matrix Block Type errors. Can you send through the export of your Matrix field (using Field Manager, and you're welcome to send to support@verbb.io) so I can replicate your field on my end. This would be before starting anything to do with Hyper migrations.

Thank you for the prompt reply. We send you an export the to support mail :+1:

engram-design commented 3 weeks ago

Thanks for sending that through. I can see that Matrix doesn't actually add any field errors to their blocktype, which would explain the lack of error message here. Fixed for the next release. To get this early, run composer require verbb/hyper:"dev-craft-4 as 1.2.1".

But the error message is as follows:

{"siteNavigationBlock_siteNavigationBlockCallToAction":{"handle":["Handle should contain at most 28 characters."]}}

What's strange is that I can change the Typed Link field in the Matrix field manually, and that works. I can see how the field handle is too long, as in the database table for a Matrix field and Block Type, it's actually going to be something like field_siteNavigationBlock_siteNavigationBlockCallToAction_ndaunrgv which is too long of a column name for MySQL.

The reason this isn't an issue with Typed Link is because its content is stored in a different table, while Hyper is going to store content "normally" alongside other content.

So I believe shortening your field handle should do the trick.

LeoWie93 commented 2 weeks ago

@engram-design changing the fieldhandle inside the matrix block to something shorter did the trick. Thank you for the support!