Download & Extend

jquery media js loads on all content types

Project:jQuery Media
Version:6.x-1.4-beta1
Component:Code
Category:bug report
Priority:minor
Assigned:Unassigned
Status:reviewed & tested by the community

Issue Summary

Hi,

I think we need to do a strict search in in_array() like below. Otherwise the js loads on all content types.



/**
*  Invoke the plugin if we support it for this node type.
*/
function jquery_media_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op == 'view') {
    if (in_array($node->type, variable_get('jquery_media_node_types', array()), TRUE)) {
      jquery_media_add();
    }
  }
}

Comments

#1

Status:active» reviewed & tested by the community

True. (Independently traced & fixed, then found this bug report.)

variable_get('jquery_media_node_types', array()) is

array( 'enabled-type1' => 'enabled-type1',
       'enabled-type2' => 'enabled-type2',
       'disabled-type1' => 0,
       'disabled-type2' => 0,
...)

... and comparing a string value 'non-strict' against an array which contains int(0), seems to always return TRUE, because (int)$node->type is 0 as well => match.

See http://www.php.net/manual/en/function.in-array.php#102681

AttachmentSize
509576.patch 543 bytes

#2

It of course helps if I provide, like, a correct patch.
Pesky brackets...

AttachmentSize
509576-2.patch 543 bytes
nobody click here