diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-07-30 03:06:18 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-07-30 03:06:18 +0000 |
commit | 137011df918d911c9811b8d503ca5af037284c4c (patch) | |
tree | d87d47b2a9c5b61e5b9e803baa1bbfc2e2104417 | |
parent | a63facc8c6b8289f7d456226206c92ee491ecaeb (diff) | |
download | brdo-137011df918d911c9811b8d503ca5af037284c4c.tar.gz brdo-137011df918d911c9811b8d503ca5af037284c4c.tar.bz2 |
- Patch #844388 by lotyrin, bjaspan, effulgentsia: taxonomy terms disappear from node preview if previewed more than once.
-rw-r--r-- | modules/field/field.attach.inc | 23 | ||||
-rw-r--r-- | modules/node/node.pages.inc | 7 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.test | 6 |
3 files changed, 26 insertions, 10 deletions
diff --git a/modules/field/field.attach.inc b/modules/field/field.attach.inc index 3383a5793..faa8743c2 100644 --- a/modules/field/field.attach.inc +++ b/modules/field/field.attach.inc @@ -1035,10 +1035,17 @@ function field_attach_delete_revision($entity_type, $entity) { /** * Prepare field data prior to display. * - * This function must be called before field_attach_view(). It lets field - * types and formatters load additional data needed for display, and - * therefore accepts an array of entities to allow query optimisation when - * displaying lists of entities. + * This function lets field types and formatters load additional data + * needed for display that is not automatically loaded during + * field_attach_load(). It accepts an array of entities to allow query + * optimisation when displaying lists of entities. + * + * field_attach_prepare_view() and field_attach_view() are two halves + * of the same operation. It is safe to call + * field_attach_prepare_view() multiple times on the same entity + * before calling field_attach_view() on it, but calling any Field + * API operation on an entity between passing that entity to these two + * functions may yield incorrect results. * * @param $entity_type * The type of $entities; e.g. 'node' or 'user'. @@ -1076,8 +1083,12 @@ function field_attach_prepare_view($entity_type, $entities, $view_mode) { * Each field is displayed according to the display options specified in the * $instance definition for the given $view_mode. * - * The entity must have run through field_attach_prepare_view() beforehands. - * @see field_attach_prepare_view() + * field_attach_prepare_view() and field_attach_view() are two halves + * of the same operation. It is safe to call + * field_attach_prepare_view() multiple times on the same entity + * before calling field_attach_view() on it, but calling any Field + * API operation on an entity between passing that entity to these two + * functions may yield incorrect results. * * Sample structure: * @code diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc index 96a4ebfcb..d360bad3a 100644 --- a/modules/node/node.pages.inc +++ b/modules/node/node.pages.inc @@ -339,11 +339,10 @@ function node_preview($node) { field_attach_prepare_view('node', $nodes, 'full'); // Display a preview of the node. - // Previewing alters $node so it needs to be cloned. if (!form_get_errors()) { - $cloned_node = clone $node; - $cloned_node->in_preview = TRUE; - $output = theme('node_preview', array('node' => $cloned_node)); + $node->in_preview = TRUE; + $output = theme('node_preview', array('node' => $node)); + unset($node->in_preview); } drupal_set_title(t('Preview'), PASS_THROUGH); diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test index 605b6a86e..391dc01df 100644 --- a/modules/taxonomy/taxonomy.test +++ b/modules/taxonomy/taxonomy.test @@ -451,6 +451,12 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { $this->drupalGet('node/' . $node->nid); $this->assertText($term2->name, t('Term is displayed when viewing the node.')); + + //Preview the node + $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Preview')); + $this->assertNoUniqueText($term2->name, t('Term is displayed when previewing the node.')); + $this->drupalPost(NULL, NULL, t('Preview')); + $this->assertNoUniqueText($term2->name, t('Term is displayed when previewing the node again.')); } /** |