Permalink
Browse files

fix(files): now uses filename on filestore to detect mime

For ElggFile instances ElggFile::detectMimeType was using filename metadata,
which was not a readable file. Now normalizes filename to a filestore path,
and ensures that the file is readable before calling finfo_* and mime_*

Fixes #8846
  • Loading branch information...
hypeJunction committed Aug 24, 2015
1 parent 96c60df commit ab8086a61feb87eb0c8d3a89fc6649c7e603a4b4
Showing with 6 additions and 6 deletions.
  1. +6 −6 engine/classes/ElggFile.php
@@ -131,12 +131,12 @@ public function setMimeType($mimetype) {
* @todo Move this out into a utility class
*/
public function detectMimeType($file = null, $default = null) {
- if (!$file) {
- if (isset($this) && $this->filename) {
- $file = $this->filename;
- } else {
- return false;
- }
+ if (!$file && isset($this)) {
+ $file = $this->getFilenameOnFilestore();
+ }
+
+ if (!is_readable($file)) {
+ return false;
}
$mime = $default;

0 comments on commit ab8086a

Please sign in to comment.