User tests: Successful: Unsuccessful:
This PR adds the data before the update in the table happend to the before and after save event.
This allows a plugin to check the changed values in the after save event and trigger further actions.
Before this PR, the Plugin needs to listen on the beforeSaveEvent, load the row from the database manually and preserve it in the plugin object and read the preserved data in the afterSaveEvent.
A event listener should be self contained and should not depend on any other plugin triggers (if possible).
In this case we now only need the afterSaveEvent and don't need to do another database query, which both increase performance.
Create a plugin, or use an existing plugin which listen to the onContentAfterSave
and onContentBeforeSave
events.
Test with the all extensions (also 3rd party) especially
check the value of $event->getArgument('oldData'); this should have the old values before the row has been updated.
No old Data
Old Data exists
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org: TBA
No documentation changes for manual.joomla.org needed
This PR doesn't touch the UserBeforeSave and UserAfterSave event since it doesn't implement the \Joomla\CMS\Event\Model\SaveEvent
class, the User Save events already include the old data. Never the less it would make sense to move the User Save events inline with all other Save events.
In the Documentation a migration part have to be added with motivate 3rd party extension developer to check there save function and also provide the old data to the event handler.
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_categories com_languages com_menus com_modules com_tags com_templates Libraries |
Labels |
Added:
Feature
PR-5.3-dev
|
Also possible, issue on this is that it only works if you use bind() in the table object for adding values, which might be true for this use case, but not if you just set a simple value.
So maybe this could be added additionally and adding the checkbox at the end of the load function.
Looks good to me
Nice nice idea.
However it should be done on Table level instead of Model, as other ORM doing:
Then you can do
$table->getPreviousData()
everywhere.