- 🇬🇧United Kingdom steven jones
I've found a minor performance optimization, in:
+++ b/workbench_moderation.module @@ -142,6 +142,154 @@ function workbench_moderation_menu() { + $has_view_access = (entity_access('view', $target_type, $target_id) !== FALSE); + $has_update_access = (entity_access('update', $target_type, $target_id) !== FALSE); + $items[$nid][$delta]['access'] = ($has_view_access || $has_update_access);
We always compute the
$has_update_access
value, but actually, if$has_view_access == TRUE
, the we don't need to.
If the update access is expensive to compute, then we can skip all of that by doing this:$items[$nid][$delta]['access'] = (entity_access('view', $target_type, $target_id) !== FALSE) || (entity_access('update', $target_type, $target_id) !== FALSE);
Simple, and no functional change, except I suppose if the entity_access call has side-effects, but urgh, let's not go down that rabbit hole.