I've noticed with my custom entities (and in fact this can be seen with the ones from the test modules too) that there are a LOT of calls to the menu access callback, entity_operations_operation_access_callback().
This is for things like:
- access to each tab to see whether to display it
- some sort of figuring out of tab parentage the menu system does
- breadcrumb link access
Instantiating the operation handler each time is not that huge a cost, but each handler then usually calls entity_access() to figure out access. This can be expensive, as entity types may then pass access control on to a hook of their own.
Furthermore, caching access is a light: for each key we cache only a boolean. Therefore if it turns out that for some operations in the page request we only want to get access once, we've not wasted a huge amount of resources.
Access remains the same throughout the page request. It's feasible that an operation might want to get fresh access values if it does something like unpublish the entity, and then determines whether to redirect the user to the entity view, or the front page if they have now lost access to the entity (however, it's relatively rare to give the user permission to do something to an entity which results in them no longer being able to see it). This case is covered by using drupal_static() -- this hypothetical operation handler can clear the static after it has made its changes.
Comments
Comment #1
joachim commented