Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x]: Craft 5 upgrade error: A field layout element is missing its UUID #16411

Open
petehjfd opened this issue Jan 10, 2025 · 6 comments
Open
Labels

Comments

@petehjfd
Copy link

What happened?

Description

Hi @brandonkelly - I'm getting a very similar error to #16032 when upgrading to Craft 5.

I am upgrading from Craft 4.13.9 to 5.5.9.

The error I'm getting is:

Exception: A field layout element is missing its UUID. Reinstall Craft CMS ^4.4.14 and run `utils/fix-field-layout-uids` before upgrading to Craft CMS 5.

I only get this error when deploying the upgrade to the staging server. The upgrade works fine on local.

I rolled back to Craft 4 and ran utils/fix-field-layout-uids but it output that there was nothing to fix. I continued on with the Craft 5 upgrade for a second try and got the same error.

Expected behavior

Migrations to run and upgrade to craft 5.

Actual behavior

Migration fails with above error

Craft CMS version

Upgrading 4.13.9 to 5.5.9

PHP version

8.3.14

Operating system and version

Linux 6.8.0-44-generic

Database type and version

MySQL 8.0.40

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.12-98)

Installed plugins and versions

  • Amazon S3 2.2.1
  • Bugsnag 5.0.0
  • CKEditor 4.4.0
  • Freeform 5.8.6
  • Super Table 4.0.2
@petehjfd petehjfd added the bug label Jan 10, 2025
@ragnarfrosti
Copy link

We are experiencing the same problem. The upgrade worked locally but failed when pushed to the staging environment with the same error as @petehjfd.

The error seems to come from m230511_215903_content_refactor.php migration script (row 37).

So we decided to dump more information to the exception thrown there:

Image

There we see that there is a mismatch in the information in the migration compared to the one in the project config file.

The migration says there is no UID on the custom field in the layout, and the UID is missing in the array in the migration, but if we look at the file in the project config directory, the UID is there.

This is the data in the project.yaml
Image

This is the data in the migration where it seems to have lost the UID somewhere along the way:
Image

I hope this helps with debugging since we are also stuck here at the moment.

@ragnarfrosti
Copy link

Update from our perspective:

Our problem seems to be that we haven't pushed the commit with the project config changes from the utils/fix-field-layout-uids script to the staging environment before we started the upgrade process.

Since the update script from m230511_215903_content_refactor.php uses the values from the database, not from the project yaml files, it resulted in our error above.

Running the utils/fix-field-layout-uids command isn't mentioned in the upgrade instructions (https://craftcms.com/docs/5.x/upgrade.html) so we missed that. This is maybe something that should be mentioned there, and specifically that you need to do that and push out those changes before starting the Craft 5 update since these values need to exist in the database in all environments. Otherwise, the Craft 5 update won't be successful (in our case at least).

Sorry @petehjfd for hijacking your thread in case this won't help you.

@petehjfd
Copy link
Author

Thanks @ragnarfrosti

When you run utils/fix-field-layout-uids, does it actually find anything to fix?

It doesn't for us, so there wouldn't be any project config changes to actually push to staging.

Thanks

@ragnarfrosti
Copy link

Hi @petehjfd

Yes, the script found a couple of fields missing the uid, and therefore, the upgrade failed for us.

Did you run the php craft project-config/rebuild before running the php craft utils/fix-field-layout-uids script (and deploy that to all environments) before the Craft 5 upgrade? That's the only thing I can think of that might cause any mismatch in the YAML vs database project configs.

@petehjfd
Copy link
Author

@ragnarfrosti We are running php craft project-config/rebuild as part of the upgrade process, but we're not deploying that to staging/live as a separate step before continuing with the Craft 5 upgrade. That might be worth a try. Thanks for the suggestion.

@petehjfd
Copy link
Author

I've found a solution to our problem. I rolled back to Craft 4 and ran the latest Craft 4 updates. I then ran php craft project-config/rebuild and deployed to staging and live at this point. I believe it's this deployment that has resolved the issue. It essentially gets the staging and live databases ready to receive the Craft 5 upgrade (I think!)

So I think the upgrade guide should perhaps suggest deploying to all servers immediately after rebuilding the project config and before the Craft 5 upgrade to avoid this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants