I just try to preview forum topic and I get many E_NOTICE errors.
It works well if default or plain text format selected.

Notice: Undefined index: taxonomy_term in taxonomy_field_formatter_view() (line 1368 of /home/www/d-test/dde/public/modules/taxonomy/taxonomy.module).
Notice: Trying to get property of non-object in entity_extract_ids() (line 7286 of /home/www/d-test/dde/public/includes/common.inc).
Notice: Trying to get property of non-object in taxonomy_term_uri() (line 148 of /home/www/d-test/dde/public/modules/taxonomy/taxonomy.module).
Notice: Trying to get property of non-object in taxonomy_field_formatter_view() (line 1372 of /home/www/d-test/dde/public/modules/taxonomy/taxonomy.module).

--
I tested it on two different installations.

Comments

james.williams’s picture

This is probably nothing to do with which format is selected, but rather a symptom of the underlying issue behind #844388: Taxonomy terms disappear from node preview if previewed more than once. Taxonomy needs hook_field_formatter_prepare_view() to be invoked, but this won't happen with the way the preview function currently works.

Taxonomy adds term data to each field item during taxonomy_field_formatter_prepare_view() which is needed for displaying the terms. On clicking preview the first time, the $node object is rendered correctly (with terms), and a flag is set on the $node object, which persists through to the next time preview is clicked. This flag stops hook_field_formatter_prepare_view() being invoked on the second preview.

Chi’s picture

I have read #844388, but it's marked as fixed more than half year ago.

I also have similar problem with image_field_formatter.

james.williams’s picture

Chi, it looks like a module-specific fix will have to be found for your issue. The node's URI gets incorrectly set, but this cannot be fixed at this stage, so it may be something that's stuck until Drupal 8 - see comment #13 on #1025870: Previewing a node causes $node->uri['path'] to be set to 'node/' in hook_node_insert(). My problem was with pathauto - if it helps, the workaround for that is the patch in comment #10 on #955926: Path not linked to node id after previewing then saving node. I imagine image_field_formatter may need something similar.

catch’s picture

Status: Needs review » Closed (duplicate)