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
Failed update persists entity attributes #11201
Comments
So we either revert attributes on a failed save, or provide a revert() method and beg plugins to use it. Any other ideas? |
We might want to add |
We should start throwing exceptions, IMO. Ideally we would have a set of HTTP exceptions, which would be caught in router. Failing silently is not an option anymore. |
You mean if a plugin uses permissions in a valid way to block a save(), we should throw? Of course, plugins can try/catch a FailedSaveException, but it's a big BC break. |
Plugins should only be saving in actions, that would be caught by the router. So, we are just making their lives easier. |
Legacy written actions would lose custom error messages and, more importantly, any work that came after, or partial Ajax response data that was going to be returned. These aren't reasons not to change, but considerations we can't ignore. |
Let's stick with untestable code that has a brain of its own. Maybe in another 20 years we will finally learn |
save() returning false doesn't make it untestable. It's a trade off like everything else. The greater crime toward untestability is all the invisible caching. I gave a solution above that I could try. |
Another: the moment an attribute is changed, purge the entity cache of it and disable caching for it. Leave it to be cached on a later request. This is functionally the same as above though. We want to mark the entity dirty for the rest of the request. |
will this still be a problem when the attributes have been moved to metadata? |
It would for user entities |
Entities, metadata, annotations and relationships are now consistent in their lifecycle events. To avoid confusion, create, update and delete events have been deprecated, instead plugins should use create:before, create:after, update:before , update:after, delete:before and delete:after events. This also eliminates the bad practice of deleting rows from database right after they have been created, should a handler return false. Also updates entity save operations to throw HttpExceptions when problems occur. Failed entity update now resets entity attributes to their originals. Fixes Elgg#11201 Fixes Elgg#9033 Fixes Elgg#7997
Entities, metadata, annotations and relationships are now consistent in their lifecycle events. To avoid confusion, create, update and delete events have been deprecated, instead plugins should use create:before, create:after, update:before , update:after, delete:before and delete:after events. This also eliminates the bad practice of deleting rows from database right after they have been created, should a handler return false. Also updates entity save operations to throw HttpExceptions when problems occur. Failed entity update now resets entity attributes to their originals. Fixes Elgg#11201 Fixes Elgg#9033 Fixes Elgg#7997
Entities, metadata, annotations and relationships are now consistent in their lifecycle events. To avoid confusion, create, update and delete events have been deprecated, instead plugins should use create:before, create:after, update:before , update:after, delete:before and delete:after events. This also eliminates the bad practice of deleting rows from database right after they have been created, should a handler return false. Also updates entity save operations to throw HttpExceptions when problems occur. Failed entity update now resets entity attributes to their originals. Fixes Elgg#11201 Fixes Elgg#9033 Fixes Elgg#7997
There is no clear direction for a solution for now. If using save() do not assume it is successful |
The problem is that subsequent calls to other methods that do not require permissions checks could propagate these attributes to caches.
The text was updated successfully, but these errors were encountered: