Media browser plus attempts to move files into the created media root directory when it is enabled, but it does this by creating a new path using the file_managed "filename" value. This value is not guaranteed to be unique, so this method causes duplicate file URIs to be created; as this is enforced as unique with a DB constraint, enabling the module fails and the filesystem and file_managed table are both left in an inconsistent state.

Flagged as major due to the potential damage to file_managed data and to the files themselves.

Comments

elyobo’s picture

Simply calling file_move() with the destination directory, rather than directory + a file name, avoids the problem.

jhnbrnn’s picture

Status: Active » Needs review
StatusFileSize
new545 bytes

Here's a one-line fix as per #1's recommendation.

camdarley’s picture

If you remove this line, $destination is not declared anymore...
If think it should be better like this:

-   $destination = $path . '/' . $media->filename;
-  file_move($media, $destination, $replace);
+  file_move($media, $path, $replace);

Isn't it?

jhnbrnn’s picture

Ah, you're totally right. Re-rolled with changes.

das-peter’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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