Kaynağa Gözat

Merge pull request #1491 from Alkarex/check_fileinfo

Check for fileinfo
Alexandre Alapetite 9 yıl önce
ebeveyn
işleme
c5e9fee5a7
4 değiştirilmiş dosya ile 12 ekleme ve 7 silme
  1. 1 0
      CHANGELOG.md
  2. 1 1
      app/install.php
  3. 9 5
      lib/Favicon/Favicon.php
  4. 1 1
      lib/lib_install.php

+ 1 - 0
CHANGELOG.md

@@ -14,6 +14,7 @@
 * Bug fixing
 	* Fix SQL uniqueness bug with PostgreSQL [#1476](https://github.com/FreshRSS/FreshRSS/pull/1476)
 		* (Require manual update for existing installations)
+	* Do not require PHP extension `fileinfo` for favicons [#1461](https://github.com/FreshRSS/FreshRSS/issues/1461)
 	* Fix UI lowest subscription popup hidden [#1479](https://github.com/FreshRSS/FreshRSS/issues/1479)
 * I18n
 	* Improve English [#1465](https://github.com/FreshRSS/FreshRSS/pull/1465)

+ 1 - 1
app/install.php

@@ -465,7 +465,7 @@ function printStep1() {
 	<?php if ($res['fileinfo'] == 'ok') { ?>
 	<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.fileinfo.ok'); ?></p>
 	<?php } else { ?>
-	<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.fileinfo.nok'); ?></p>
+	<p class="alert alert-warn"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.fileinfo.nok'); ?></p>
 	<?php } ?>
 
 	<?php if ($res['data'] == 'ok') { ?>

+ 9 - 5
lib/Favicon/Favicon.php

@@ -179,7 +179,7 @@ class Favicon
         // Sometimes people lie, so check the status.
         // And sometimes, it's not even an image. Sneaky bastards!
         // If cacheDir isn't writable, that's not our problem
-        if ($favicon && is_writable($this->cacheDir) && !$this->checkImageMType($favicon)) {
+        if ($favicon && is_writable($this->cacheDir) && extension_loaded('fileinfo') && !$this->checkImageMType($favicon)) {
             $favicon = false;
         }
 
@@ -229,10 +229,14 @@ class Favicon
         $fileContent = $this->dataAccess->retrieveUrl($url);
         $this->dataAccess->saveCache($tmpFile, $fileContent);
         
-        $finfo = finfo_open(FILEINFO_MIME_TYPE);
-        $isImage = strpos(finfo_file($finfo, $tmpFile), 'image') !== false;
-        finfo_close($finfo);
-        
+        $isImage = true;
+        try {
+            $finfo = finfo_open(FILEINFO_MIME_TYPE);
+            $isImage = strpos(finfo_file($finfo, $tmpFile), 'image') !== false;
+            finfo_close($finfo);
+        } catch (Exception $e) {
+        }
+
         unlink($tmpFile);
         
         return $isImage;

+ 1 - 1
lib/lib_install.php

@@ -67,7 +67,7 @@ function checkRequirements($dbType = '') {
 		'favicons' => $favicons ? 'ok' : 'ko',
 		'http_referer' => $http_referer ? 'ok' : 'ko',
 		'message' => $message ?: 'ok',
-		'all' => $php && $minz && $curl && $pdo && $pcre && $ctype && $fileinfo && $dom && $xml &&
+		'all' => $php && $minz && $curl && $pdo && $pcre && $ctype && $dom && $xml &&
 		         $data && $cache && $users && $favicons && $http_referer && $message == '' ?
 		         'ok' : 'ko'
 	);