From da6c554acb845ef36a3a58a9fd2380e6f3fd8b45 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 12 May 2015 16:41:31 +1200 Subject: [PATCH] Check file existence in for_file() finfo() will silently fail the whole request (at least on my PHP 5.4 install) if invoked on a file that doesn't exist, so fail early here. --- code/extractors/FileTextExtractor.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/extractors/FileTextExtractor.php b/code/extractors/FileTextExtractor.php index 208dd47..a5a2e33 100644 --- a/code/extractors/FileTextExtractor.php +++ b/code/extractors/FileTextExtractor.php @@ -72,9 +72,13 @@ abstract class FileTextExtractor extends Object { /** * @param string $path - * @return FileTextExtractor + * @return FileTextExtractor|null */ static function for_file($path) { + if(!file_exists($path) || is_dir($path)) { + return; + } + $extension = pathinfo($path, PATHINFO_EXTENSION); $mime = self::get_mime($path); foreach(self::get_extractor_classes() as $className) {