-
-
Notifications
You must be signed in to change notification settings - Fork 547
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
Modifying Entry taxonomy data using an event listener causes an error in RelationshipFieldtype #11396
Comments
You've shared some example code, which looks fine to me. What does your actual code look like? Are you adding multiple terms, or just one? |
Hey @duncanmcclean, My actual use case would add multiple terms if if there are any. I have 2 fresh installs one using Eloquent and the other Flat Files. I can push a Repo if you'd like. public function handle(EntrySaving $event): void
{
$entry = $event->entry;
$entry->set('taxonomy_one', 'one'); ❌
$entry->set('taxonomy_three', ['term-two', 'term-two-two']); ❌
$entry->set('taxonomy_three', collect(['term-three', 'term-three-three'])); ❌
$entry->saveQuietly();
} I tested with a multi select and have a similar experience. $entry->set('select', 'one'); ✅
$entry->set('select', collect(['term-three', 'term-three-three'])); ❌ Reloading the page also fixes the issue. I have also noticed that if the entry has not been published Another observation, is that if I update one taxonomy, all of them will display incorrectly. |
Thanks! I was able to reproduce it. Looks like it'll be fixed by #11356. |
Also, you don't need to call |
@duncanmcclean Thanks! I was originally using Would there be an ETA on that pull request? I can reload the page for now while we're in development. |
I don't have an ETA on it, sorry! |
@duncanmcclean no problem, we're still in development for a few months. I'd love this resolved before the client begins entering content. But we can work around that. |
Bug description
Modifying an entries taxonomy data using an Event Listener causes errors in the control panel.
I'm using the Eloquent driver although I've tested this with a fresh flat file install as well and it's actually worse.
I'm using Revisions, but the problem exists when it's not enabled.
Save and Edit needs to be enabled, Save and Go To Listing doesn't result in the issue.
I'm syncing another entries taxonomies with the entry that's being edited. This is done through
EventSaved
orEventSaving
.Editing content, titles, or other regular fields through the Listeners don't result in this problem.
How to reproduce
I've tested with and without revisions
EventSave and EventSaving
If the error shows, then refresh the page, this really boils down to modifying the taxonomy data.
It's worse when using flat files since it happens on create.
The Database version on create is fine, but when you remove the link and terms then save revisions the EventSaving/Save fires again for some reason.
I've used the Vue inspector and can see that the data on the in
RelationshipFieldtype
represents the error above.Reloading the page, represents the data correctly.
Logs
Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
I've only tested this with Taxonomies.
The text was updated successfully, but these errors were encountered: