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.
This commit is contained in:
Ingo Schommer 2015-05-12 16:41:31 +12:00
parent 15f9647bca
commit da6c554acb

View File

@ -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) {