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:
- Install and configure the media and wysiwyg modules (see versions below)
- Configure file entity display settings to use shadowbox (admin/config/media/file-types/manage/image/file-display)
- Create a page node and upload an image using the media browser CKEditor plugin
- Edit the page and re-save
- 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
Comment #1
draenen commentedWe 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.
See attached patch.
Comment #2
draenen commentedWhoops. Typo in that last patch. Trying again.
Comment #3
manfer commentedPushed