When previewing a node that has media elements, we get a fatal error because of the media_field_widget_form() function trying to use a class as a string. There's lots of odd stuff going on in there.

Comments

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new1.36 KB

I have no freaking clue what this unserialize is doing here. It doesn't seem to matter at all, which is ironic because the function media_field_widget_value() is not invoked at all which is the function doing the serialize().

I tested this and uploading and displaying a media element worked just fine.

effulgentsia’s picture

Title: Fatal errors in media_field_widget_form when previewing node with media elements » WSOD when previewing node with multi-valued media field
Status: Needs review » Needs work
StatusFileSize
new2.46 KB

#1 is a logical cleanup, but we need to verify it with a module that uses the 'data' column. There's some legacy cruft in there that we shouldn't need any more, but I don't want to rush its removal. So, I committed this instead, which equally fixes the ability to preview a node with a single-valued media field.

In the meantime, neither #1, nor this, fixes the fatal errors when previewing a multi-valued media field. But fixing that is a little trickier. The @todo in this patch explains.

effulgentsia’s picture

Marked #982180: $items in formatters are objects while core provides arrays a duplicate. Noting it here to remind anyone working on this that the solution really does need to be a complete fix to not use objects for $items[$delta] anywhere.

effulgentsia’s picture

Title: WSOD when previewing node with multi-valued media field » $items[$delta] is sometimes an object when Field API requires array. Causes WSOD when previewing multi-valued media field.
effulgentsia’s picture

Status: Needs work » Active

There's no patch yet posted for this (#2 was committed, but doesn't address this larger problem), so status = "active".

R.Muilwijk’s picture

subscr

slashrsm’s picture

subscribe

sherakama’s picture

subscribe

sherakama’s picture

StatusFileSize
new0 bytes

For those who are needing a temporary fix just to get the preview to not WSOD here is a bandaid that casts the bad object into an array. Its working but definitely not a fix.

patches file media.fields.inc

* Ignore this upload patch and go to the comment below. Something wrong with file upload. *

sherakama’s picture

StatusFileSize
new510 bytes

Something funky with the last upload.

* BROKEN - Do not use *

sherakama’s picture

StatusFileSize
new532 bytes

Sorry for flooding the comments. Last item broke node_view but worked in preview. Added another condition to the statement so that it only casts the array temporary fix on preview.

Jackinloadup’s picture

The patch in #11 uses a method similar to the method I used to patch field_slideshow. Worked pretty great.

http://drupal.org/node/1030606#comment-3962638

becw’s picture

Status: Active » Fixed

The fix to this was committed in commit 481128.

effulgentsia’s picture

Status: Fixed » Needs work

#13 refers to #2 being committed to fix the special case of a single-valued media field. The larger issue here still needs work. See #2-#5.

effulgentsia’s picture

Status: Needs work » Closed (duplicate)

There's now a patch for this in #1064502: Fatal error: Cannot use object of type stdClass as array in modules/field/field.form.inc on line 193, so marking this one a duplicate. If you're able to test out that issue's patch and comment about your experience, that would help a lot. Thanks.