verbb / hyper

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

Matrix migration issue #147

Closed cole007 closed 1 month ago

cole007 commented 2 months ago

Describe the bug

We have a Craft 4 site which is experiencing an issue when migrating link fields from Typed Link field to Hyper. Matrix fields are being overlooked in the migration which seems to be problem with import code where "vendor/verbb/hyper/src/migrations/PluginFieldMigration.php" is calling the wrong class for "oldFieldTypeClass".

Looking for "lenz\linkfield\fields\LinkField"

Actual class saved in fields table of database is "typedlinkfield\fields\LinkField".

Oddly we have some Craft 4 sites where this field type is in table as "lenz\linkfield\fields\LinkField" as expected.

Suggest perhaps doing a LIKE comparison against "%linkfield\fields\LinkField" or alternatively something like

->where(['type' => $this->oldFieldTypeClass])
->orWhere(['type' => 'typedlinkfield\fields\LinkField'])

(this solution has worked locally)

Steps to reproduce

  1. Install both Hyper and Typed Link Field (latest versions)
  2. Save Typed Link Field to a Matrix block

Am not sure if this dates from a specific release of Typed Link Field and the older class names/field types have persisted

Craft CMS version

4.9.1

Plugin version

1.1.28

Multi-site?

No

Additional context

Typed link field | 2.1.5

cole007 commented 2 months ago

If it is any help can see the different class name seems to have originated in projects using

sebastianlenz/linkfield:^1.0.15

engram-design commented 2 months ago

I've seen one other person raise this, and it seems to be that the Typed Link migration hasn't run, or hasn't run properly.

We're not going to get into the habit of providing support for multiple versions of these other plugins to migrate, so we really want to be on the latest before migrating to Hyper.

The issue is that it's not just a simple class name mixup, and that if field settings are in the old format, they need to be updated. See the migration where there's a few things to do.

The solution for now is to use Hyper to get the legacy Typed Link fields up to date, then migrate them to Hyper as normal. We've added a new console command to make this work.

To get this early, run composer require verbb/hyper:"dev-craft-4 as 1.1.28". Then run “./craft hyper/typed-link-legacy” to update the Typed Link fields to be what they’re supposed to be, and then run the Hyper migrations as normal.

If this is becoming a large enough issue, I'll incorporate it into the regular migration for Typed Link as a single step, but I'm hoping that either this isn't too much of a prevalent issue, or people ensure they get all up to date before migrating to Hyper.

engram-design commented 1 month ago

Updated in 1.1.29