We have a content type with a term reference field that is hidden on page display, and while working with the Metatags module I noticed that tokens referencing fields that are hidden on the page display type were not being populated, and in fact were generating errors in the taxonomy field module. If I made the field visible in the display type, it worked fine.

Further investigation through the call stack found that the entity being used was already processed for the current page display type (in which the hidden fields were not fully processed), and when subsequent field format calls were made on the entity's fields, no hook_field_formatter_prepare_view hooks were being invoked on the fields due to $entity->_field_view_prepared being set to TRUE on the cloned entity.

This patch resets that flag on the cloned entity prior to running through the field rendering code, allowing all fields to be rendered on the entity for the "token" display type, resulting in all field tokens being processed fully and available for use.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, token-7.x-1.0-rc1-field_view_prepared_reset.patch, failed testing.

arpieb’s picture

Status: Needs work » Needs review
FileSize
658 bytes

Botched patch generation - here's a good one.

Status: Needs review » Needs work

The last submitted patch, token-7.x-1.0-rc1-field_view_prepared_reset.patch, failed testing.

arpieb’s picture

Third time's the charm...

arpieb’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, token-7.x-1.0-rc1-field_view_prepared_reset-1508404.patch, failed testing.

jec006’s picture

Version: 7.x-1.0-rc1 » 7.x-1.x-dev
Status: Needs work » Needs review
FileSize
641 bytes

Here's a better version

Dave Reid’s picture

Status: Needs review » Fixed

Makes sense since this seems to happen because meta tag calls token replacement from within hook_field_attach_view(). Committed to 7.x-1.x with http://drupalcode.org/project/token.git/commit/34b6142

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.