I don't think this is fixable, but documenting the issue here anyway.

field_get_display() (which triggers this hook) is called for every field instance on every node in a node listing, regardless of whether it's going to be rendered or not - this makes complete sense because the hook allows you to change a formatter from hidden to not, or vice-versa. It also has to run before field_access() - since field_access() should only run on fields which are already hidden.

On a D7 site I'm working on, this is run 405 times - which is about as frequent as hook_url_outbound_alter(), which is in a similarly tricky spot of getting very risky as soon as you implement it.

While writing this, I had an evil idea, which may appear in http://drupal.org/project/performance_hacks shortly.

Comments

catch’s picture

Here's the evil for reference: http://drupal.org/cvs?commit=383108