We have a "caption" field on our image files and after upgrading from beta2 to beta3, any image added does not display the caption value. I verified on a different environment that was still running beta2 that they do display correctly in beta two. This seems to affect images that already existed in the WYSIWYG when editing them and submitting a caption that wasn't previously there.

The source in beta2 looks like:
[[{"fid":"30552","view_mode":"downpage_art","fields":{"format":"downpage_art","field_file_image_alt_text[und][0][value]":false,"field_file_image_title_text[und][0][value]":false,"field_caption[und][0][value]":"This is a test that the ampersand & issue is fixed"},"type":"media","attributes":{"height":"387","width":"700","class":"media-element file-downpage-art"}}]]

The source in beta3 looks like:
[[{"fid":"30552","view_mode":"downpage_art","fields":{"height":"387","width":"700","class":"media-element file-downpage-art"},"type":"media","attributes":{"height":"387","width":"700","class":"media-element file-downpage-art"}}]]

It appears there are several things missing from the source in beta3 compared to beta2 including the caption value.

I am seeing these errors when a page is saved (with new images as well):

Warning: Missing argument 2 for media_wysiwyg_filter(), called in /docroot/sites/all/modules/contrib/metatag/metatag.inc on line 168 and defined in media_wysiwyg_filter() (line 15 of /docroot/sites/all/modules/contrib/media/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc).

I see an error for arguments 3, 4, 5, and 6 as well on that same line.

I also see this:
Notice: Undefined variable: langcode in media_wysiwyg_filter() (line 23 of /docroot/sites/all/modules/contrib/media/modules/media_wysiwyg/includes/media_wysiwyg.filter.inc).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

shelane created an issue. See original summary.

joseph.olstad’s picture

Status: Active » Needs review
FileSize
5.64 KB

Shot in the dark here, came up with a possible solution.

Here's a patch you can test out, can you kindly please apply it to your 7-x-2.0-beta-3 version of media and please re-test?

apply it like this:

cd media
wget https://www.drupal.org/files/issues/undefined_variable_langcode-2822662-4.patch
patch -p1 --dry-run < undefined_variable_langcode-2822662-4.patch
echo 'is there an error message on --dry-run?, if not, run next command'
patch -p1 < undefined_variable_langcode-2822662-4.patch

if you do not have the wget command you can supplement with curl as follows.
curl https://www.drupal.org/files/issues/undefined_variable_langcode-2822662-4.patch > undefined_variable_langcode-2822662-4.patch

the reason for the patch, is your environment appears to not use the i18n module and langcode was not defined, this patch hopefully will deal with this. If it works, I'll commit it and tag a new release.

Thanks,

Status: Needs review » Needs work

The last submitted patch, 2: undefined_variable_langcode-2822662-2.patch, failed testing.

joseph.olstad’s picture

Status: Needs work » Needs review
FileSize
6.44 KB
joseph.olstad’s picture

hi @shelane please try patch 4 , updated steps are described in comment #2

sylus’s picture

I think all that is needed is to update the function signature? For instance I had this problem with metatag which was calling media with:

$value = media_wysiwyg_filter($value);

But I patched it to use full form:

$value = media_wysiwyg_filter($value, NULL, NULL, NULL, NULL, NULL);

However we shouldn't have to do this and the original method should still work. We just need to update media's token function.

The best solution is to just update the function signature for the params and set them to NULL as defaults which will prevent all warnings. I don't think any additional checks are necessary.

joseph.olstad’s picture

OK makes sense and thanks, @shelane, instead of patch 4, please try patch 6,

I tried to contact shelane but looks like her profile does not accept contact and thus she is likely not seeing our responses

  • joseph.olstad committed 8ef2613 on 7.x-2.x authored by sylus
    Issue #2822662 by joseph.olstad, sylus: Media items added or edited no...
joseph.olstad’s picture

I tested the scenario as best I could according to the explanation left by @shelane
I freshly installed Drupal 7.51 vanilla (french install, but monolingual, meaning there was only one language, no i18n and I did not install l10n)
installed prerequisites /dependencies for media
then installed the media version 7.x-2.0-beta3 and tested adding a new content type , then added an image field and assigned the media widget
added new content, did not see a problem

then I added a caption field (text field?) to the image file entity , added another piece of content, no problem

I could not reproduce the problem

Tested the same scenario with patch #6 applied, it works the same way, so either way it works.

I committed the patch by @sylus to 7.x-2.x dev as it didn't seem to have any issues and might help @shelane

Thanks.

joseph.olstad’s picture

Status: Needs review » Fixed

need more precise steps to reproduce. Marking this as fixed, unless someone else can prove otherwise.

joseph.olstad’s picture

I tested again for good measure, this time an english d7 vanilla configuration, similar test case as I mentioned above.

Could not reproduce and works as designed. The use case scenario would have to be verbosely explained.

shelane’s picture

Thanks for the patches. I will test and apply first thing in the morning. I'm knee deep in finishing something else up at the moment that I must do first, but I will make this my next priority.

shelane’s picture

@joseph.olstad I saw that there were two more updates since I had the issue in beta3. I can confirm that with beta5, it is no longer an issue. Thanks for fixing. (I never did try the patch once I saw the updated beta). Thanks for the quick response!

joseph.olstad’s picture

hi @shelane, thanks for the followup and thanks to @sylus for his patch.

Status: Fixed » Closed (fixed)

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