linkit
linkit copied to clipboard
Updating to Craft 3.1.x removes Asset and Entry sources
Updating a site to 3.1.5 results in LinkIt losing all its checked options for Entry and Assets under a linkit field. Fields that previous had "Entry" enabled as an option with some checkboxes turned on are now all unchecked on all fields - both as normal LinkIt fields, and LinkIt fields inside Matrix fields.
LinkIt 1.1.6 Craft 3.1.5
I can confirm this.
It seems to happen after upgrading to 3.1 regardless of using project.yaml or not.
I did the the following:
- Backup prod database (craft 3.0 and linkit 1.1.4)
- Import prod database to local machine (craft 3.1.8 and linkit 1.1.8)
- Sync changes on first admin pageload
- Go into linkit field settings to see that checkboxes for entry or category are not remembered from prod database.
Edit: Don't know if this is relevant or not, but the linkit-field is inside a super table inside a matrix.
Update - a project that I updated from Craft 3.0 to 3.1.11 today and linkit 1.1.8 just lost all it's entry source again, and I'm not using project.yaml. Happens to linkit fields which are standalone fields and inside matrix blocks. It's also not just entries it loses - it also forgets asset and category sources.
Still happening. Just upgraded a site not using project.yaml from 3.0.41 to 3.1.17.1 and my sources have disappeared again.
Linkit was on 1.1.6 on Craft 3.0.41 (latest available on that version). Updated Craft and LinkIt at the same time.
Just debugged this some more. The issue seems to be that the modal is now expecting uids and not ids as sources. So a linkit migration should probably have to convert the source ids to uids in the fields settings?
E.g. "sources":["section:3","section:4"] to "sources":["section:c0700229-5082-44c2-81b9-cbf9cf627f61","section:e7b877e2-6151-463d-b721-7254537b1275"]
After running migration without doing anything else
Formdata /actions/element-indexes/get-elements when opening modal:
context: modal
elementType: craft\elements\Entry
sources[]: section:3
sources[]: section:4
showSiteMenu: 0
After manually setting correct sources again on the linkit field
Formdata /actions/element-indexes/get-elements when opening modal:
context: modal
elementType: craft\elements\Entry
sources[]: section:c0700229-5082-44c2-81b9-cbf9cf627f61
sources[]: section:e7b877e2-6151-463d-b721-7254537b1275
showSiteMenu: 0
I did some tests in a fork, and changing the settings to use uids instead of ids seems to work.
@samhibberd Could something like this be the way to go for a fix? https://github.com/nettum/craft-linkit/blob/id_to_uid_migration/src/migrations/m190313_161737_ids_to_uid.php
This of course needs more work, at least the following:
- add migrations for ~~user~~, ~~asset~~ and product sources
- make it play with project config (this seems to work out of the box now?)
- update schema version
- more sanity checks (e.g. to see if the source references already are uids and not ids)?
As of now when I test on my local installation, entry, category, user or asset sources get migrated correctly and my project.yaml file gets updated with the code in my comment above. I don't know what product sources is, but assume it's from Craft Commerce.
Waiting for Sam's response to see if the code could be a potential PR (after at least adding product source migration) or if fruitstudios would like to fix it/tidy it up themselves.
This has been fixed as a part of 1.1.10.
@darylknight Is 1.1.10 migrationg sources for you? They still seems to be missing in my case, using the same steps as described in https://github.com/fruitstudios/craft-linkit/issues/51#issuecomment-461854091, but with craft 3.1.17.2 and linkit 1.1.10.
Worth mentioning that all linkit fields is in my case is inside a Matrix (and a few inside a super-table inside the same matrix)
@nettum is this when upgrading from a Craft 2 site, ie first install of the new Linkit? Ive only written the migration as a part of the install process, however, if you are already installed I will have to add this as a separate migration.
It's an upgrade from a Craft 3 site. I'm backing up the database from production (running Craft 3.0.36 and linkit 1.1.4) and importing it to the local database where the packages are updated (e.g. craft 3.1.17.2 and linkit 1.1.10). On the next admin pageload craft asks me to run migration so I do that. That's when the sources are getting lost.
I think I will need to write a separate migration for the element sources stuff.
Not that of a biggie for me as I don't have that many linkit fields and sources. I can go and manually add them again after the initial migrations from 3.0 to 3.1 is done.
But I assume this may happen for others and should be taken care of with a migration.
If you write a new migration I'll be happy to test (internettum on discord).
Experiencing the same issue - it basically renders the entry picker empty (because ALL or any specific sections aren't selected as sources). Going to start manually fixing them all up.
Just ran into this issue as well. Not sure when it occurred, but we have 20+ Linkit fields, some nested in various matrix/super table fields. Several had specific settings defined.
Wondering if there's still a concern of this happening again.
Just ran into this issue again during a Craft 2 > 3.4 upgrade.
I manually updated all my fields to the correct settings in 3.4. I then exported the production database (Craft 2), and imported locally as a new test database.
My hope was that re-defining all my field settings in 3.4 would force the changes on my fields and prevent settings being lost.
In my Entry sources, Singles were specifically unselected when comparing changes. Again, this was after setting up a project config with my desired Entry source settings.
Both Category and Asset sources were inconsistently unchecked in various places (individual Linkit fields, inside Matrix fields, and inside Super Table fields), and when they were set, they didn't always seem to have the desired sources checked.
This is extremely frustrating as it's very tedious and time consuming to manually go through and manually update these fields. Not to mention that it's prone to user error.
We are hoping for a smooth site upgrade transition with minimal downtime. Our client needs to push regular updates and we can't lock them out for too long.
Any assistance here would be greatly appreciated.
I feel like a lot of these issues could be resolved if managing settings wasn't such a pain in the first place. See: https://github.com/fruitstudios/craft-linkit/issues/31