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

Update to 2.0.8 losing all icon values in CP/GraphQL #66

Open
ctigelaar opened this issue Dec 13, 2022 · 3 comments
Open

Update to 2.0.8 losing all icon values in CP/GraphQL #66

ctigelaar opened this issue Dec 13, 2022 · 3 comments

Comments

@ctigelaar
Copy link

ctigelaar commented Dec 13, 2022

I upgraded a site to Craft 4, including v2.0.8 of IconPicker. Somehow the migration of the icons went not perfect, because I have no icons anymore. As in, in CP the stored value in DB is not selected anymore and GQL is not returning any value. It looks like #60, but that one should be resolved in 2.0.8, but my bug is introduced in that version.

I did some debugging and found out that in the convertModel method in the migration (https://github.com/verbb/icon-picker/blob/craft-4/src/migrations/m221111_000000_modernize_model.php), you are checking for a $type variable. If it exists you are migrating, if not you are not performing anything. Well, that's where it goes wrong, because my values stored in the database have type: null, see below:

{
"icon":"/urban-building/008-school.svg",
"sprite":null,
"glyphId":null,
"glyphName":null,
"iconSet":null,
"type":null,
"css":null,
"width":null,
"height":null
}

If I manually convert icon to value and type to svg the CP is showing my icon again in the field.

I'm an IconPicker user since 1.1.10 and always performed the updates all the time, so I don't know what happened in the meantime. But the fact that the if/else branching stops on checking if $type exists seems to rough, because I didn't get any error during migration or whatsoever.

Maybe you can provide me a migration file to fix my values so everything works again? Would be highly appreciated.

N.B. Because I also had this issue (#64), I installed dev-craft-4 as 2.0.8 today, but the bug with missing values was introduced by updating to v2.0.8.

Steps to reproduce

  1. See description

Craft CMS version

4.3.4

Plugin version

dev-craft-4 as 2.0.8

Multi-site?

No

Additional context

No response

@engram-design
Copy link
Member

Strange. I don't see how it would be possible for the type to be null for Icon Picker 1 fields, that shouldn't be possible. But that's indeed what's happening on your install.

We should probably be a little less "all-or-nothing" about the migration where we retain the existing values if they can't be migrated. It does cause some other extra handling on our end, but probably worth the hassle to ensure content isn't wiped.

Should be fixed in 2.0.9 however because the content of the fields has already been modified, you'll need to revert to a database backup before your initial Icon Picker update to restore those old values, and they'll be migrated again. Apologies for the hassle.

@engram-design
Copy link
Member

Oh, and just wanted to confirm that your example above:

{
"icon":"/urban-building/008-school.svg",
"sprite":null,
"glyphId":null,
"glyphName":null,
"iconSet":null,
"type":null,
"css":null,
"width":null,
"height":null
}

Was the content of the field before updating to Icon Picker 2, or after?

@ctigelaar
Copy link
Author

Thanks for getting back to me, I came up with a migration script myself to fix the missing data. It works again.

Was the content of the field before updating to Icon Picker 2, or after?

The object as shown was after the 2.0.8 update. Only then I realised something was wrong.

Maybe somehow the data migration scripts didn't run on my site, that's the only reason I can find as an explanation. I also understand you should draw the line somewhere to find a starting point for your migration script. So for now I'm good, thanks.

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

No branches or pull requests

2 participants