Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 cf0929c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion engine/classes/ElggFile.php
Expand Up @@ -154,9 +154,10 @@ public function detectMimeType($file = null, $default = null) {
$mime = mime_content_type($file); $mime = mime_content_type($file);
} }


$original_filename = isset($this) ? $this->originalfilename : basename($file);
$params = array( $params = array(
'filename' => $file, 'filename' => $file,
'original_filename' => $file->originalfilename, // @see file upload action 'original_filename' => $original_filename, // @see file upload action
'default' => $default, 'default' => $default,
); );
return _elgg_services()->hooks->trigger('mime_type', 'file', $params, $mime); return _elgg_services()->hooks->trigger('mime_type', 'file', $params, $mime);
Expand Down

0 comments on commit cf0929c

Please sign in to comment.