We've run into a few issues with the project config, one scenario:
@andris-sevcenko this ties into that project.yaml validation we were talking about. Craft should be performing basic validation across the entirety of new configs before syncing changes.
It should be ensuring there are no duplicate names/handles across:
global contextThere should also be an event that gives plugins a chance to add their own checks (e.g. Neo/Super Table should be checking if their own sub-fields’ names & handles are unique).
If there are any errors, they should be logged (and output if it’s a console request), and the sync should be aborted.
Related: #4369
In addition, we sometimes see some issues with the following scenario as well:
If between step 1 and 2 we haven't deployed it, project config tries to remove a plugin on the production that wasn't there in the first place, causing an error.
@lenvanessen I don’t think that’s quite right… Craft will only try to uninstall a plugin per a project.yaml change, if its stored project config previously had a record of the plugin being installed, but the new project.yaml file has it removed. So if you install and then uninstall a plugin before ever pushing to production, then production would never have known about the plugin to begin with.
More likely you did something like this:
project.yaml and composer.json + composer.lock)project.yaml and composer.json + composer.lock)If you do that, then Craft won’t be able to successfully uninstall the plugin, because plugins themselves are responsible for their own deinstallation. If the plugin’s files are no longer present (because of it being Composer-removed), then it won’t be around to uninstall itself.
@brandonkelly yes, makes sense.
I probably hit the same bug today.
Renamed the handle of a field used in globals from booking_link to booking_link_general.
Renamed the handle of a field used in different structures/singles from package_booking_link to booking_link.
A colleague did git pull and got both changes from project config, resulting in the following error:
Status: Internal Server Error
Respons: {"error":"SQLSTATE[23000]: Integrity constraint violation:
1062 Duplicate entry 'booking_link-global' for key 'fields.fields_handle_context_unq_idx'
The SQL being executed was:
UPDATE fields SET groupId=1, handle='booking_link', settings='{\\\"allowCustomText\\\":\\\"\\\",\\\"allowTarget\\\":\\\"\\\",\\\"allowedLinkNames\\\":{\\\"1\\\":\\\"entry\\\",\\\"8\\\":\\\"tel\\\",\\\"9\\\":\\\"url\\\"},\\\"autoNoReferrer\\\":\\\"\\\",\\\"defaultLinkName\\\":\\\"entry\\\",\\\"defaultText\\\":\\\"\\\",\\\"enableAriaLabel\\\":\\\"\\\",\\\"enableTitle\\\":\\\"\\\",\\\"typeSettings\\\":{\\\"entry\\\":{\\\"sources\\\":\\\"*\\\",\\\"allowCustomQuery\\\":\\\"\\\"},\\\"user\\\":{\\\"sources\\\":\\\"*\\\",\\\"allowCustomQuery\\\":\\\"\\\"},\\\"asset\\\":{\\\"sources\\\":\\\"*\\\",\\\"allowCustomQuery\\\":\\\"\\\"},\\\"category\\\":{\\\"sources\\\":\\\"*\\\",\\\"allowCustomQuery\\\":\\\"\\\"},\\\"site\\\":{\\\"sites\\\":\\\"*\\\"},\\\"custom\\\":{\\\"disableValidation\\\":\\\"\\\",\\\"allowAliases\\\":\\\"\\\"},\\\"email\\\":{\\\"disableValidation\\\":\\\"\\\",\\\"allowAliases\\\":\\\"\\\"},\\\"tel\\\":{\\\"disableValidation\\\":\\\"\\\",\\\"allowAliases\\\":\\\"\\\"},\\\"url\\\":{\\\"disableValidation\\\":\\\"\\\",\\\"allowAliases\\\":\\\"\\\"}}}', dateUpdated='2020-05-11 11:20:17' WHERE id=47"}
Workaround was to change handles between 2 syncs to all envs to avoid this error.
Craft 3.4.18
Typed link field 1.0.21
@nettum That sounds like a different bug. Can you post as a new GitHub issue please?
Of course, will try to replicate locally and post a new issue.
This is now fixed for the next 3.5 release.
@nettum sorry for the confusion… on further review I was wrong and this was the same bug as what you were reporting.