User tests: Successful: Unsuccessful:
There's no way of knowing if a user has changed the access level of an article if he uses the batch command
Added the events event_before_save and event_after_save to the function batchAccess in AdminModel class
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
A few things:
For edit operations, mainly in the back end, I guess it would be acceptable the performance loss. Read operations on the front end are performance crucial.
But. During development of custom fields, we got into a similar issue. In the list view is for every entity an event fired to gather the display data, eg. custom fields. We were talking there already about batch events to trigger one event with multiple entities. So for me this would be a welcoming addition.
We could use onContentBeforeBatch and onContentAfterBatch in the batch function
/**
* Content is passed by reference. Method is called before the batch function is runned.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since __DEPLOY_VERSION__
*/
public function onContentBeforeBatch(&$commands, &$pks, &$contexts) {}
/**
* Method is called after the batch function is runned.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since __DEPLOY_VERSION__
*/
public function onContentAfterBatch($commands, $pks, $contexts) {}
A good compromise, to maintain high performance, could be the use of the events onContentBeforeBatch and onContentAfterBatch for all batch commands except for copy, in that case you could use onContentBeforeSave and onContentAfterSave
/**
* Method is called before the batch function is runned.
*
* @param string $identifier The field to change.
* @param string $command The command to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since __DEPLOY_VERSION__
*/
public function onContentBeforeBatch($identifier, $command, &$pks, &$contexts) {}
/**
* Method is called after the batch function is runned.
*
* @param string $identifier The field to change.
* @param string $command The command to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function onContentAfterBatch($identifier, $command, $pks, $contexts) {}
Performance of event triggering in batch operations has troubled me too
I am also in favour of introducing onContentBeforeBatch, onContentAfterBatch
It is a chance to get it right now, before introducing something that later will be a B/C break to undo
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-03-25 08:17:38 |
Closed_By | ⇒ | laoneo | |
Labels |
Added:
?
Removed: ? |
I think this is a very important aspect of security. I wrote a simple plug-in to record user access to sensitive articles, but if a user can change the access level of an article without firing a trigger, the plug-in is not useful.