0

I drupal 7 site that I did not build but now maintain has developed an odd error. About a month ago the site lost the ability to add an image to a Media field inside a new addition of field collection. Looking into it, this is what I find: enter image description here

The first few warnings are nothing that I can see would harm things. The media.popup.js error is nonsense:

dialogOptions.buttons[ok] = function () {
  alert('hell yeah');
  return "poo";

  var formattedMedia = this.contentWindow.Drupal.media.formatForm.getFormattedMedia();
  if (!formattedMedia) {

I have yet to see that code be reached, though it looks a little unprofessional to have such things in a contrib module.

When I scroll down the node edit form I see see the next segment. The Bulletin error has to do with Google Syndication code linked in, and can be ignored for now.

The piece of the screenshot after that is when I try to trigger the field collection's "Add Additional Item" button from the console. Nothing happens. I am not sure if I did it right, but I included it in this screenshot in case it helps identify anything.

The final segment shows the messages that appear when I click the Add Additional Item button. A new field collection instance is actually added to the form, and if the console was not open I would not know that something was wrong yet. I get from 2 to 5 instances of that "object is undefined" error any time I do this. The "too much recursion" error occurs about 1 in 15 tries, so I do not know if it is relevant. I have all cache and compression turned off, and this is a local virtual box copy of the live site so I do not have to worry about killing it in the investigation.

The problem is these "object is undefined" errors block the use of the Media module's Select Media button for a field on the node. First time this problem was noticed was when a new slide show entry was being added to an Article node. The Add collection button causes the error, and the Media button then does not respond but throws some "this.hoverable" error. I went over to another content type that has a field collection that contains only text, but also has a Media field on the node itself. The field collection generates the same error, I switch vertical tabs to get to the Media field and it behaves the same as the media field inside the collection. JQuery Update is used to keep the admin screens on jquery v1.5 because it is needed for the Media module.

Modules involved:

  • Drupal 7.38
  • Field collection (field_collection) Module Enabled 7.x-1.0-beta8
  • Chaos tools (ctools) Module Enabled 7.x-1.7
  • jQuery Update (jquery_update) Module Enabled 7.x-2.4
  • Media (media) Module Enabled 7.x-1.5
  • 2
    Hey, DW. That's a heck of a lot to process. Maybe if you present your issue one small hurdle at a time? You might get more responses. Cheers - – othermachines Aug 18 '15 at 6:30
  • I was trying to follow the asking rules for best results. "Tell us what you found and why it didn’t meet your needs." and "But if you give us details and context, we can provide a useful answer." So yes, it is a lot. I have been banging my head on this problem for awhile... I appreciate you commenting though. +1 for being first response – DeveloperWeeks Aug 18 '15 at 15:20
  • No worries! Maybe it's just a matter of adding a TL;DR. Wondering: had you updated or added any modules when this started? What about the admin theme? Change the jQuery version? Since something would have to change to cause this the obvious first course of action is to try and pin down what that was. I'm sure you've already done this, but I'm asking the annoying questions because it isn't noted in your post. :) – othermachines Aug 18 '15 at 18:13
  • 1
    Regarding the media.popups.js alert, you'll be interested in this commit: Removed inappropriate JS code. This also tells me that the file is much older than that packaged with Media 7.x-1.5. Maybe it was a sloppy update somewhere along the way. Did you try replacing that file with the latest version in the 7.x-1.x branch? – othermachines Aug 18 '15 at 18:24
  • @othermachines, you are a gentleman and a scholar. There was a second Media module in the site, one in /sites/all/modules and one in /profiles/custom/modules – DeveloperWeeks Aug 18 '15 at 19:24
1

OK, this was sort of entertaining.

The trail begins with this silliness in media.popups.js:

dialogOptions.buttons[ok] = function () {
  alert('hell yeah');
  return "poo";

Just as it stuck out for @DeveloperWeeks, it stuck out for me because I'm familiar with the work of Media module's primary maintainer, and I know him (by reputation) to be pretty meticulous. So in checking it out I discovered that it was removed long ago (like, in 2013) in this commit: Removed inappropriate JS code.

(I am sure he would be thrilled, by the way, to know that this bit of code will now live forever after on StackExchange. :-P)

Since the OP lists as part of his installation the latest production release of Media (7.x-1.5), this didn't mesh. The errors were originating from a two-year-old file.

With this compelling clue in hand, @DeveloperWeeks was able to locate an extra copy of the Media module hidden away in his installation. That's when the sun rose, the flowers bloomed, and things just generally started to make more sense.

As for those pesky errors, well...

"This is why "duplication of data" is such a horrible thing." - @DeveloperWeeks

Hell, yeah. ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.