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

Bug when renaming a media object with the model manager #2589

Open
mitelg opened this issue Sep 20, 2023 · 0 comments
Open

Bug when renaming a media object with the model manager #2589

mitelg opened this issue Sep 20, 2023 · 0 comments

Comments

@mitelg
Copy link
Contributor

mitelg commented Sep 20, 2023

Description:

As you can see here, there is an "onUpdate" function in the Media model. It is executed on the doctrine event "PostUpdate", so after a media object is updated. If the name of the media object was changed, this function renames the file of the media and then it updates the "path" attribute. But this new "path" attribute is never saved to the database, because the media object was already saved (PostUpdate). So when you update the name of a media object and save this media with the model manager, the file is renamed but the new path is not saved to the database and then this media is broken.

Environment:

Noticed it in 5.6.4, but in 5.7.11 it still looks exactly the same.

Steps to reproduce:

  • Load a media object with the model manager
  • Update the name of that media
  • Flush the object

Expected result:

  • The name and also the path are updated in the database

Actual result:

  • Only the name is updated in the database
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

1 participant