Permalink
Browse files

fix(files): make sure method is callable on a concrete object instance

PHP treats $this as an instance of a calling class when ElggFile::detectMimeType is called
statically.

Fixes #9010
  • Loading branch information...
hypeJunction committed Oct 10, 2015
1 parent ab3b48f commit 740d3108a30733d02a98e9aed7516f92033cd8a9
Showing with 3 additions and 2 deletions.
  1. +3 −2 engine/classes/ElggFile.php
@@ -133,7 +133,8 @@ public function setMimeType($mimetype) {
* @todo Move this out into a utility class
*/
public function detectMimeType($file = null, $default = null) {
- if (!$file && isset($this)) {
+ $class = __CLASS__;
+ if (!$file && isset($this) && $this instanceof $class) {
$file = $this->getFilenameOnFilestore();
}
@@ -156,7 +157,7 @@ public function detectMimeType($file = null, $default = null) {
$mime = mime_content_type($file);
}
- $original_filename = isset($this) ? $this->originalfilename : basename($file);
+ $original_filename = isset($this) && $this instanceof $class ? $this->originalfilename : basename($file);
$params = array(
'filename' => $file,
'original_filename' => $original_filename, // @see file upload action

0 comments on commit 740d310

Please sign in to comment.