Problem/Motivation

Editing a node causes an infinite loop when using the shadowbox formatter for file entities added to a node via the CKEditor media browser (from the media module). The offending code seems to be a node_load() in file_shadowbox_field_formatter_view() (file_shadowbox.module:230).

if(isset($entity->title)) {
    $node_title = $entity->title;
  } else {
    if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
      $node = node_load(arg(1));
      $node_title = $node->title;
    }
  }

We cannot assume that $entity is a node.

Steps to reproduce:

  1. Install and configure the media and wysiwyg modules (see versions below)
  2. Configure file entity display settings to use shadowbox (admin/config/media/file-types/manage/image/file-display)
  3. Create a page node and upload an image using the media browser CKEditor plugin
  4. Edit the page and re-save
  5. Observe infinite loop

Installed modules:
Drupal 7.16 - Default Modules
Shadowbox-7.x-4.x-dev
Media-7.x-1.2
Wysiwyg-7.x-2.2
Library Versions
Shadowbox.js-3.0.3
CKEditor-3.6.5.7647

Comments

draenen’s picture

Title: Infinite loop when using shadowbox formatter with media file entities on node_save() » Infinite loop when using shadowbox formatter with media file entities on node edit
Status: Active » Needs review
StatusFileSize
new1.06 KB

We first check if the entity type is actually a node. Just because we are on node/123/edit does not mean we are formatting a node.

$node_title = '';
  if (isset($entity->title)) {
    $node_title = $entity->title;
  }
  else if ($entity_type == 'node' && is_numeric(arg(1))) {
    $node = node_load(arg(1));
    $node_title = $node->title;
  }

See attached patch.

draenen’s picture

Whoops. Typo in that last patch. Trying again.

manfer’s picture

Status: Needs review » Fixed

Pushed

Status: Fixed » Closed (fixed)

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

  • Commit d4e24d6 on 7.x-4.x, 8.x-1.x authored by draenen:
    Issue #1832800 by draenen: infinite loop on shadowbox file field...