drupal 8 take action when node deleted

Add comment here with Drupal 8 equivalent: https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_delete/7.x

It still exists in Drupal 8 and 9, as a specific case of hook_ENTITY_TYPE_delete:

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21entity.api.php/function/hook_ENTITY_TYPE_delete/9.0.x

… of course, we’re using a soft-delete (trashbin) workflow, made somewhat elegant by the Workflow Buttons module. So acting on actual delete isn’t going to do what we need.

Instead, we need to do stuff when the the workflow state changes.

In Drupal 8 and Drupal 9, this should be an event. It isn’t yet:

Dispatch events for changing content moderation states [#2873287] | Drupal.org

Until then, we have to dive into the guts of the moderation state a bit on a nodeapi hook. Fortunately as linked from that issue, the Content Moderation Notifications module gives a good example of the code needed to do that:

https://git.drupalcode.org/project/content_moderation_notifications/blob/8.x-1.x/content_moderation_notifications.module#n6

Anyhow what i was trying to do with that…

Remove specific node from index [#2824812] | Drupal.org

Thanks to the work in this issue - Index items only at end of page request [#2922525] | Drupal.org - see also this change record - “Index items immediately” will now only index items at the end of the page request | Drupal.org - the perceived performance should still be good.