jQuery.extend can't merge object and array in some case and the result will be that the second value overwrites the first one. For example: jQuery.extend(true, a, b); "b" will overwrite "a". To check this out i made an example code here: https://jsfiddle.net/y0ks9arp/3/ Hit the run and look at the console(firebug console for example) The first console.log is mediadatamap-overwritten.png(attached). The second console.log is mediadatamap-not-overwritten.png(attached). If fiddle for some reason is not accessible i attached the full code in a text file(jquery-extend-issue.txt) that can be tested for instance in firebug console.

Reproduce:

  • Jquery update with jQuery 1.10

There is a node with a body field and an inline entity reference field. Call the parent node "A" and the referenced node "B". The "A" body field has an image(added with media browser), the "B" has two images(added with media browser) in its body field. You are in "A" node and try to edit the referenced "B" node, you hit the edit button the referenced node is loaded, and now you go back to parent node("A") body field and hit the source button. You will notice that json is disappeared.

I attached a couple of screenshot about this:

  1. node-a-image.png
  2. node-a-image-json.png
  3. node-b-edit.png
  4. node-a-image-json-disappeared.png

So the problem is that the mediaDataMap settings will be overwritten.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mibfire created an issue. See original summary.

mibfire’s picture

I made a patch to fix this.

gmclelland’s picture

Status: Active » Needs review

Patch attached. Setting to NR

joseph.olstad’s picture

Note: there's an option in jQuery_update to allow using the default core jQuery for admin interfaces and specific admin themes... Thats probably why others haven't reported this issue because they have jquery_update overrides , so their front-end theme may be using jQuery 1.10.2 but their back end is using the original jQuery that comes with core.

However, if this is a backwards compatible change, as long as it doesn't break default jQuery then yes I think we should make the change. It would be good to have a confirmation on this.

joseph.olstad’s picture

is this patch still working on 7.x-2.0-beta7?

joseph.olstad’s picture

mediadatamap-not-overwritten
mediadatamap-not-overwritten

mediadatamap-overwritten
mediadatamap-overwritten

node-a-image-json-dissappeared
node-a-image-json-dissappeared

joseph.olstad’s picture

I'm not sure if this issue still exists, needs testing to see if this patch still works against older jQuery versions

Chris Matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The 2 year old patch in #2 to media_wysiwyg.filter.inc does not apply to the latest media 7.x-2.x-dev and needs a reroll.

Checking patch modules/media_wysiwyg/includes/media_wysiwyg.filter.inc...
error: while searching for:
      'view_mode' => $tag_info['view_mode'],
      'link_text' => $tag_info['link_text'],
    );
    drupal_add_js(array('mediaDataMap' => array($file->fid => $data)), 'setting');
    $element['#attributes']['data-fid'] = $file->fid;
    $element['#attributes']['data-media-element'] = '1';
    $element['#attributes']['class'][] = 'media-element';

error: patch failed: modules/media_wysiwyg/includes/media_wysiwyg.filter.inc:187
error: modules/media_wysiwyg/includes/media_wysiwyg.filter.inc: patch does not apply