Permalink
Browse files

fix(files): $file is not always an object with originalfilename property

$file can be a string in ElggFile::detectMimetype, which was producing log errors.
Now using actual ElggFile instance to get the originalfilename metadata, or
basename() to get the filename from a path.

Refs #8846
  • Loading branch information...
hypeJunction committed Aug 24, 2015
1 parent ab8086a commit cf0929c243b69f4018e77640e1e175f8d93670ea
Showing with 2 additions and 1 deletion.
  1. +2 −1 engine/classes/ElggFile.php
@@ -154,9 +154,10 @@ public function detectMimeType($file = null, $default = null) {
$mime = mime_content_type($file);
}
$original_filename = isset($this) ? $this->originalfilename : basename($file);
$params = array(
'filename' => $file,
'original_filename' => $file->originalfilename, // @see file upload action
'original_filename' => $original_filename, // @see file upload action
'default' => $default,
);
return _elgg_services()->hooks->trigger('mime_type', 'file', $params, $mime);

0 comments on commit cf0929c

Please sign in to comment.