Skip to content

Conversation

@Mary-Clb
Copy link
Contributor

@Mary-Clb Mary-Clb commented Nov 27, 2025

Checklist before requesting a review

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

  • It fixes !40347
  • The delete/purge/restore actions on an asset performed via Massive Actions were not logged on the glpi_events table, unlike their counterparts performed from item forms. The MassiveAction::processMassiveActionsForOneItemtype()is enhanced to log those events via Massive Actions, ensuring consistency with individual item actions.
@Mary-Clb Mary-Clb self-assigned this Nov 27, 2025
Copy link
Contributor

@trasher trasher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it seems OK, it may be very impacting on perfomances to log an entry each time an item is processed.

Since you do not use item propeties (like its ID) in messages;, maybe just logging a standard message like "%s deletes %d items from massive actin"?
An alternative would be to use a prepared statement, but it would be usefull only if we really want to keep trace of each affected item (seems useless to me).

Anyway, please add test cases :)

Copy link
Contributor

@trasher trasher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks globally OK, see last comments


switch ($action) {
case 'delete':
$deleted_count = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether performed individually or via bulk actions, I believe the same events should be generated, especially in the case of a deletion. Currently, we lose track of who deleted what in bulk mode, whereas this information is retained for individual actions.

I’d like to gather multiple opinions on this matter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we can handle massive actions just as regular ones; this would produce lot of entries in the logs (or a very huge/illisible one).

Also, as far as I can see; Event::log is currently mostly called from front files, therefore there probably are many cases where nothing is logged at all (cascade update/removal for example).

Maybe that part needs a rework; but with specs.

Side note: Massive actions logs should also be added on update massive action at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

5 participants