After a recent upgrade to Media 7.x-2.0-alpha3+80-dev and File Entity 7.x-2.0-alpha3+18-dev its impossible to insert a Document in Wysiwyg.
The popup displays an error and if we dive into the logs its these errors:

EntityMalformedException: Missing bundle in object of type file. i entity_extract_ids() (line 7721 in /MYPATH/includes/common.inc).

Creating default object from empty value i media_file_displays_alter() (line 1036 in /MYPATH/sites/all/modules/media/media.module).

Trying to get property of non-object i file_view_file() (line 226 in /MYPATH/sites/all/modules/file_entity/file_entity.file_api.inc).

Undefined index: #entity i media_wysiwyg_view_mode_form_alter() (line 98 in /MYPATH/sites/all/modules/media/modules/media_wysiwyg_view_mode/media_wysiwyg_view_mode.module).

This does not happen with Images, only with Documents (and possibly other types, I don't know).

This is what the form options look like that get passed into the function:

Array
(
    [#type] => fieldset
    [#title] => options
    [format] => Array
        (
            [#type] => select
            [#title] => Display as
            [#options] => Array
                (
                    [default] => Förvald
                    [teaser] => Förhandstitt
                    [preview] => Förhandsgranska
                    [wysiwyg] => WYSIWYG
                )

            [#default_value] => default
            [#description] => Choose the type of display you would like for this
      file. Please be aware that files may display differently than they do when
      they are inserted into an editor.
        )

    [fields] => Array
        (
            [#parents] => Array
                (
                )

            [#pre_render] => Array
                (
                    [0] => _field_extra_fields_pre_render
                )

            [#entity_type] => file
            [#bundle] => testtype
        )

)

Comments

cato’s picture

Patch from #18 in https://drupal.org/node/2223455 did the trick!
Someone can go ahead and close this issue.

devin carlson’s picture

Status: Active » Closed (duplicate)
Issue tags: -wysiwyg, -ui, -document, -entity
Related issues: +#2223455: Broken Media WYSIWYG integration

Closing as a duplicate of #2223455: Broken Media WYSIWYG integration per #1.

rikki_iki’s picture

Status: Closed (duplicate) » Needs review
StatusFileSize
new702 bytes

Not sure if this the right place, but I'm getting a similar problem only related to documents, but mine's a javascript error.
I can upload document but the final submit button throws this JS error:

Uncaught TypeError: Cannot read property 'tagName' of undefined media_wysiwyg.filter.js line 131

I have Media 7.x-2.0-alpha3+108-dev and File Entity 7.x-2.0-alpha3+31-dev
The patch referred to in #1 has already been committed to this version of media_wysiwyg so this is possibly a new bug.

I was able to resolve the issue with the attached patch.

Status: Needs review » Needs work

The last submitted patch, 3: media-brokendocument-2262107-3.patch, failed testing.

rikki_iki’s picture

Status: Needs work » Needs review
StatusFileSize
new644 bytes

Better patch.

dave reid’s picture

Component: Media WYSIWYG View Mode » Media WYSIWYG
dshields’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #5 works for me.

dshields’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new644 bytes

Here's the same patch, rolled against the latest dev branch.

dshields’s picture

broeker’s picture

Oddly, we were having the same issue as #3 and this patch does in fact solve that problem:

Uncaught TypeError: Cannot read property 'tagName' of undefined

There are several other issues/patches out there for that specific issue, but we had a unique situation in that the error was ONLY triggered in the context of an IPE modal dialog. Everything worked fine on a normal textarea field on a node edit etc. Nonetheless it would be great to have this committed.

For reference, the patch in this issue fixes the issue referenced below (whereas the recommended patch did not):

https://www.drupal.org/node/2317519

Again this is only for IPE/modal dialogs in our case, but now working.

broeker’s picture

Status: Needs review » Reviewed & tested by the community
marty2081’s picture

I can also confirm that the patch in #8 works in our case (the "Uncaught TypeError: Cannot read property 'tagName' of undefined" error popping up using IPE).

izmeez’s picture

dshields’s picture

it looks like this is fixed in the latest stable release.

joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed

@dshields, thansk for the followup
btw, latest recipe: https://www.drupal.org/node/2843391

Status: Fixed » Closed (fixed)

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