From dd32f373a6ce0ce9782ecd4f8bf6abf59246113a Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 9 Jul 2014 18:21:08 +0200 Subject: [PATCH] show reason for mime type detection failure in setup check --- src/phorkie/Repository/Post.php | 6 +++++- src/phorkie/SetupCheck.php | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/phorkie/Repository/Post.php b/src/phorkie/Repository/Post.php index 5a450b1..09cb977 100644 --- a/src/phorkie/Repository/Post.php +++ b/src/phorkie/Repository/Post.php @@ -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); } diff --git a/src/phorkie/SetupCheck.php b/src/phorkie/SetupCheck.php index c4d365c..e06f28c 100644 --- a/src/phorkie/SetupCheck.php +++ b/src/phorkie/SetupCheck.php @@ -133,8 +133,13 @@ class SetupCheck public function checkMimeTypeDetection() { $rp = new Repository_Post(); - if ($rp->getType('') != 'php') { - $this->fail('MIME type detection fails'); + $type = $rp->getType('', true); + if ($type != 'php') { + $msg = 'MIME type detection fails'; + if ($type instanceof \PEAR_Error) { + $msg .= '. Error: ' . $type->getMessage(); + } + $this->fail($msg); } } -- 2.30.2