Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
field system
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
16 Dec 2009 at 18:35 UTC
Updated:
14 Jan 2010 at 08:30 UTC
Jump to comment: Most recent file
Comments
Comment #1
yched commentedSo the issue is that
- f_a_prepare_view() lets formatters load additional data (e.g. term object for a 'term field' tid value) so it's a 'multiple objects' hook, to allow multiple objects queries.
- f_a_prepare_view() needs to run before f_a_view()
- node_view_multiple($nodes) currently calls f_a_prepare_view($nodes), then loops on node_view($node) / node_build_content($node)
- node_build_content($node) doesn't call f_a_prepare_view() so that it doesn't run twice, and directly calls f_a_view().
So direct calls to node_view() - such as when previewing a comment on a node - skip the prepare_view step and formatters might not find the data they expect.
Current HEAD has code to prevent warnings in the taxo field formatters.
Note that comment.module uses the same comment_view_multiple() / comment_view() / comment_build_content() workflow, but comment_build_content() does call f_a_prepare_view(). So f_a_prepare_view() runs twice there...
Attached patch is quite similar to what #636992: Entity loading needs protection from infinite recursion does for entity_prepare_view()
- f_a_prepare_view() sets a $object->_field_view_prepared flag, and doesn't act on incoming objects with the flag on.
The '_' in front of the name is to prevent potential clashes with a UI-created field named 'view_prepared'
- The same object, or a subset of its fields, might be re-displayed using different formatters later in the request (e.g in a side block). In this case, the prepare_view steps need to run again. So just before it returns, f_a_view() unsets the flag that was set in f_a_prepare_view().
- removes the temporary fixes around taxonomy formatters.
- enhances the PHPdoc for f_a_prepare_view()
Comment #2
catchThis looks great, I found one typo:
s/aray/array
Also my American English spell checker wants optimization but I try to slip random UK English spellings into core whenever I'm able to so I won't say anything about that.
Otherwise RTBC.
This review is powered by Dreditor.
Comment #3
yched commentedThx ! Typo fixed.
Comment #4
moshe weitzman commentedRTBC now based on catch's review
Comment #5
dries commentedCommitted to CVS HEAD. Thanks.