Skip to content

[4.x]: Category values deleted when saving an entry #13057

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

Closed
LarsDol opened this issue Apr 5, 2023 · 14 comments
Closed

[4.x]: Category values deleted when saving an entry #13057

LarsDol opened this issue Apr 5, 2023 · 14 comments
Assignees

Comments

@LarsDol
Copy link

LarsDol commented Apr 5, 2023

What happened?

Description

We've gotten a report from one of our clients that since a recent Craft update (earlier this week), values of category fields disappear after saving an entry in the CMS.

The setup is as follows:

  • NEO content block repeater
  • Containing a Supertable field
  • Which has a few category fields

At first it seemed totally random when the categories disappeared, but I've got a hunch that it has something to do with the autosave draft feature. If I manage to save the entry (using CMD + S) before the autosave has finished, the values are saved correctly.

Steps to reproduce

  1. Setup the fields as described above
  2. Add a value to one (or more) of the category fields
  3. Wait for the autosave spinner to complete
  4. Hit CMD + S
  5. Values gone (in our project at least)

Expected behavior

Category values should be saved correctly. This is a rather large problem, as editors may unknowingly remove large parts of the website when editing unrelated content.

Actual behavior

See description above.


As the behaviour started happening after a Craft CMS (and maybe some plugin) updates, I suspect something's gone wrong there.

Hope you can help us out!

Thanks,
Lars

Craft CMS version

Craft Pro 4.4.6.1

PHP version

8.1.17

Operating system and version

Linux 5.4.0-146-generic

Database type and version

MySQL 8.0.32

Image driver and version

Imagick 3.6.0 (ImageMagick 6.9.10-23)

Installed plugins and versions

  • Bugsnag | 4.0.0
  • Neo | 3.7.5
  • Redactor | 3.0.4
  • SEO | v4.0.3
  • Super Table | 3.0.8.1
  • Typed link field | 2.1.5
@aleksei-kadeikin
Copy link

aleksei-kadeikin commented Apr 6, 2023

Hello there! We are having kinda same issue.

@i-just
Copy link
Contributor

i-just commented Apr 6, 2023

Hi, thanks for reaching out. I’m having trouble replicating this issue. Would you be able to please send over your composer.lock, config/project directory and database export to [email protected] so we can try to replicate and investigate further?

@LarsDol
Copy link
Author

LarsDol commented Apr 6, 2023

Hi @i-just! I'm afraid we can't send too much of our project's configuration (as that's classified), but we'll try to send you something that's a good replication of our situation.

@riekusvm
Copy link

riekusvm commented Apr 6, 2023

After some debugging in a stripped down repo it appears that newly created categories do not disappear, whereas previously existing categories are deleted upon save. @aleksei-kadeikin can you confirm that this is also the case on your end?

@riekusvm
Copy link

riekusvm commented Apr 6, 2023

Hi @i-just, I've just emailed you a stripped down version of our project config + composer.lock

@riekusvm
Copy link

riekusvm commented Apr 6, 2023

FYI:

craft resave/categories seems to fix the issue. That doesn't take away from the fact that a minor release of craft CMS may be backwards incompatible in regard to categories created in older versions.

@brandonkelly
Copy link
Member

If anyone else is able to provide Composer files + a database backup where this issue is reproducible, please send it to [email protected].

@wmdhosting
Copy link

I did entrification. on multisite setup..

And im able to add to entry exiting categories that are saved to all sites..

But not newly created Categories with propagation method
Let entry choose site ..:

@i-just
Copy link
Contributor

i-just commented Apr 25, 2023

@wmdhosting, let’s say you have 2 sites; you entrified your categories, and then for one of them, you changed the propagation setting to “let each entry choose which sites it should be saved to”; for that section (that used to be a category group) you created new entries which are enabled for both sites, and you can’t select those the newly created entries via the entries (formerly categories) field? Are there any errors shown or logged? Or are the new entries just not visible to select? Or are they disappearing upon saving, as mentioned previously in this thread?

@wmdhosting
Copy link

  1. I entriefied categories, and changed that Category section from "Save to all sites" to “let each entry choose which sites it should be saved to”
  2. I created then new category..
  3. I created then new entry in other news section just on 1 site that have same propagation method “let each entry choose which sites it should be saved to” and i selected that newly created category. that is avaible for that iste.. only.
  4. Category. disappearing upon saving, entry normally created.. dont see any errors
  5. Old categories that where entrified i can select and all works ok.. but i see that all that old categories are saved for all sites..

@i-just
Copy link
Contributor

i-just commented Apr 25, 2023

@wmdhosting, can you please send your composer files and a database backup (from after the entirfication) to [email protected] so we can dig deeper?

@wmdhosting
Copy link

OK. will try to put someowhere for download. as pretty big .. is 130 city portals. site setup...

@i-just
Copy link
Contributor

i-just commented Apr 25, 2023

OK. I can finally replicate it on a clean Craft 4 instance (even without entrification). Thank you, @wmdhosting, for sending your files and screenshots - much appreciated!

To replicate, you need to have the following:

  • at least 2 sites
  • a channel with propagation “let each site choose”, enabled for both sites
  • a section with propagation “let each site choose”, enabled for both sites
  • an entries field with sources set to your section, maintain hierarchy & manage relations on a per-site basis checked
  • that entries field is added to the channel you created
  • create a section entry enabled for the non-primary site only
  • create another section entry enabled for the non-primary site and added to the primary site added, but it can be disabled
  • create a channel entry, and try to add both section entries - only the second one (one that’s disabled for the primary site) is saved

I’m now working on a fix.

@brandonkelly
Copy link
Member

This is now fixed in Craft 4.4.8! (via #13119)

I think we were all looking in the wrong direction initially. Categories don’t have custom propagation method settings – they are supposed to always propagate to all sites.

However this could be a bug if there were any categories that hadn’t actually been propagated to all sites yet, e.g. if a new site was created and the queue job that is supposed to propagate categories to it hadn’t completed yet. Which would explain why the bug may have only occurred for older categories but not new ones.

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

No branches or pull requests

6 participants