Hi team,

I am getting this error when I attempt to embed a video with the Media browser on a clean install:

The specified file oembed://http%3A//youtu.be/YJIevQNgQGw could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.
EntityMalformedException: Missing bundle property on entity of type file. in entity_extract_ids() (line 7766 of /var/www/html/test/includes/common.inc).

Using:
File Entity 7.x-2.0-beta1+21-dev
Media 7.x-2.0-alpha4+0-dev
Media WYSIWYG 7.x-2.0-alpha4+0-dev

Has anyone seen this before? I'll take a look too, I believe it only occurs with the most recent 3 commits to File Entity. Thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DanzDance’s picture

Assigned: Unassigned » DanzDance
Status: Active » Needs review
FileSize
849 bytes

Isolated the issue down to a call to file_move() on pages.inc line 471; this section of the code attempts to move the file to a new directory offset specified by the user. However, there is no check to make sure the file exists before it's moved, so the call throws an error and returns false, which causes entity_form_submit_build_entity() to get a null as the input for the $file parameter.

I wrote a patch that uses file_destination to check to see if the file exists before it's moved. Let me know if this looks like a good solution!

broeker’s picture

We are suddenly seeing this same error, after recent updates to File Entity, Entity, Media, etc. The patch solves the first error, but seems to introduce a new one for us:

1. Attempt to embed a Youtube video using Media browser/Web option (paste in a direct Youtube URL)

2. By default our setup is set to use "media" as the destination directory -- if this is in place we get the following error on upload:

Fatal error: Unsupported operand types in /srv/bindings/4a27d457e38b44169d67b4ad6a3fddc6/code/includes/path.inc on line 434

3. If we remove "media" as the desitnation directory and simply upload to the default public "files" folder, it works but with this PHP notice:

Notice: Uninitialized string offset: 0 in path_file_update() (line 2403 of /srv/bindings/4a27d457e38b44169d67b4ad6a3fddc6/code/sites/all/modules/file_entity/file_entity.module).

We haven't had a chance to look beyond this but will post if we can figure out a solution -- glad to know we aren't the only ones seeing this bug.

DanzDance’s picture

I'm having trouble replicating this, I'm able to upload videos on a new basic page on a fresh install using:

Media -> Web -> [entering /videos for upload path] -> http://youtu.be/rF1X12PE6PY -> ... -> save

What version of file entity are you patching? What Youtube link exactly are you using? That PHP notice looks like it's being generated on a call to:

path_delete($path['fid']);

in hook path_file_update(), file_entity.module it looks like line 2398 is checking that there's a path in $file->path before running that code but it uses in PHP isset(), which will return true if something is the empty string; maybe try changing that to use empty() to validate instead or in addition to? like

if (!empty($file->path) {
...
}

broeker’s picture

Do you have the core "Path" module enabled? That seems to be key to the second portion of this, but for reca,p and hopefully as a way to re-produce:

1. We are running the very latest DEV snapshots of all relevant modules (Media, File Entity, Entity, Ctools, etc.)

2. With no patches of any kind, with or without Path module enabled, we cannot upload a new Youtube video into Media without producing the error from OP:

The specified file oembed://http%3A//youtu.be/YJIevQNgQGw could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.
EntityMalformedException: Missing bundle property on entity of type file. in entity_extract_ids() (line 7766 of /var/www/html/test/includes/common.inc).

3. When we apply the attached patch, this error goes away completely. Note that there is a competing patch here that solves the same issue:

https://www.drupal.org/node/2454823#comment-9735479

Slightly different, but either of these patches seem to solve the original error.

4. However, we then get a second set of errors, depending on whether or not the core Path module is enabled. Note that we have also disabled all other potential conflicting path modules (Pathauto, Pathologic, etc.):

Path module ENABLED

a. Media > Web -- Upload path is set by default to "media" (or whatever, it does not matter)

b. Paste Youtube URL -- File URL or media resource: http://youtu.be/rF1X12PE6PY (or whatever, it does not matter)

c. Click "Next" and it produces this error:

Fatal error: Unsupported operand types in /Users/broeker/dev/cob/includes/path.inc on line 434

If we re-attempt these same exact steps, but remove everything from the "Upload path" field, then the upload will work except it will throw this PHP notice:

Notice: Uninitialized string offset: 0 in path_file_update() (line 2403 of /srv/bindings/4a27d457e38b44169d67b4ad6a3fddc6/code/sites/all/modules/file_entity/file_entity.module).

5. To fix this, I tried your suggestion of changing isset() to !empty() on line 2401 of file_entity.module -- this fixed the PHP Notice problem.

6. In summary to upload a Youtube:

a. Apply this patch, or the linked competing patch

b. Patch file_entity.module to use !empty() instead of isset()

c. Ensure that there is nothing in the Upload path field -- it must be empty

Path module DISABLED

1. Media > Web -- Upload path is set by default to "media" (or whatever, it does not matter)

2. Paste Youtube URL -- File URL or media resource: http://youtu.be/rF1X12PE6PY (or whatever, it does not matter)

3. Click "Next" and everything is golden.

** Note that the !empty() fix needs to be applied in both cases, with or without Path to avoid PHP Notice error.

Devin Carlson’s picture

LoneWolfPR’s picture

So I'm confused now. After it's been reverted what do I need to do to fix this error. Do I need to apply one of these patches?

lias’s picture

Ditto what LoneWolfPR has asked. There are two patches but neither have been committed or have been reverted. I am experiencing this issue with the latest versions - as of April 10, 2015:

File Entity 7x-2x-dev
Media 7x-2x-dev
Media Youtube 7x-2-rc5
Media Internet Sources 7x-2x-dev

Before the update the Youtube urls like this https://youtu.be/okdh-hPouHo were displaying correctly and the preview files were in the sites/default/files/media-youtube directory.

Now I'm getting the:
File /tmp/test_-videoname (C:\tmp\test_-4871_-videoname) could not be deleted because it is not a valid URI. This may be caused by improper use of file_delete() or a missing stream wrapper.

Christopher Riley’s picture

Has anyone gotten anywhere with this issue? I am running the latest git pull of everything and not getting anywhere and have some irritated customers.

kenorb’s picture

Assigned: DanzDance » Unassigned