The actual error happens here in the taxonomy module

 switch ($display['type']) {
    case 'taxonomy_term_reference_link':
      foreach ($items as $delta => $item) {
        if ($item['tid'] == 'autocreate') {
          $element[$delta] = array(
            '#markup' => check_plain($item['name']),
          );
        }
        else {
          $term = $item['taxonomy_term'];
          $uri = entity_uri('taxonomy_term', $term);
          $element[$delta] = array(
            '#type' => 'link',
            '#title' => $term->name,
            '#href' => $uri['path'],
            '#options' => $uri['options'],
          );
        }
      }
      break;
      ....
  }

Which is triggered by this code in the node module.

  $nodes = array($node->nid => $node);
  field_attach_prepare_view('node', $nodes, 'full');

How to reproduce.

Steps

1. Create a vanilla Drupal installation.
2. Add a term reference field and set the display mode to "Link" (taxonomy_term_reference_link) and make it be displayable in teaser/full display
3. Start creating a node, and add a term in the term reference field.
4. Press "Preview" on the node form.
(The error also happens on node already created and being previewed in edit mode)

Actual result

The "fatal error page" is displayed.

Expected result

The node preview is displayed above the node form.

Comments

googletorp’s picture

Status: Active » Needs review
StatusFileSize
new479 bytes

When actually viewing a node

node_build_content()

Is used instead, I tried using this code instead and it stops the site from crashing when previewing the node, and everything seems to be working just fine.

googletorp’s picture

Issue summary: View changes

Adds how to reproduce error description in bug report.

googletorp’s picture

StatusFileSize
new475 bytes

Fixed a stupid c/p flaw in the previous patch.

The last submitted patch, 1: 2331493-1-node_preview.patch, failed testing.

jazzdrive3’s picture

StatusFileSize
new535 bytes

Re-rolled patch.

Confirming googletorp's diagnosis. Without a node_build_content(), the $item in taxonomy_field_formatter_view() never gets its 'taxonomy_term' index populated, which is what is eventually passed to entity_uri().

jazzdrive3’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 5: 2331493-5-node_preview.patch, failed testing.

Version: 7.31 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.