show reason for mime type detection failure in setup check
[phorkie.git] / src / phorkie / Repository / Post.php
index 5a450b1aa0b446f63c82de95ae568fd09864583d..09cb977e2ac4eed1e7bd6894c5fd44e0bace25dc 100644 (file)
@@ -232,13 +232,17 @@ class Repository_Post
         return $prefix . $num;
     }
 
-    public function getType($content)
+    public function getType($content, $returnError = false)
     {
         $tmp = tempnam(sys_get_temp_dir(), 'phorkie-autodetect-');
         file_put_contents($tmp, $content);
         $type = Tool_MIME_Type_PlainDetect::autoDetect($tmp);
         unlink($tmp);
 
+        if ($returnError && $type instanceof \PEAR_Error) {
+            return $type;
+        }
+
         return $this->findExtForType($type);
     }