From 11a7f97fe72791baa36983242e56397f56d6132a Mon Sep 17 00:00:00 2001
From: Philipp Holzer <admin@philipp.info>
Date: Sat, 16 Feb 2019 22:13:19 +0100
Subject: [PATCH] friendica-6667 Installer needs to check fileinfo module

---
 src/Core/Installer.php           |  8 ++++++++
 tests/src/Core/InstallerTest.php | 16 +++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/Core/Installer.php b/src/Core/Installer.php
index 4a287a885f..fdeb940a25 100644
--- a/src/Core/Installer.php
+++ b/src/Core/Installer.php
@@ -357,6 +357,7 @@ class Installer
 	 * - mb_string
 	 * - XML
 	 * - iconv
+	 * - fileinfo
 	 * - POSIX
 	 *
 	 * @return bool false if something required failed
@@ -452,6 +453,13 @@ class Installer
 		);
 		$returnVal = $returnVal ? $status : false;
 
+		$status = $this->checkFunction('finfo_open',
+			L10n::t('File Information PHP module'),
+			L10n::t('Error: File Information PHP module required but not installed.'),
+			true
+		);
+		$returnVal = $returnVal ? $status : false;
+
 		return $returnVal;
 	}
 
diff --git a/tests/src/Core/InstallerTest.php b/tests/src/Core/InstallerTest.php
index f7f8f5c7d4..c1a003bade 100644
--- a/tests/src/Core/InstallerTest.php
+++ b/tests/src/Core/InstallerTest.php
@@ -45,6 +45,8 @@ class InstallerTest extends MockedTest
 		$this->mockL10nT('Error: POSIX PHP module required but not installed.', 1);
 		$this->mockL10nT('JSON PHP module', 1);
 		$this->mockL10nT('Error: JSON PHP module required but not installed.', 1);
+		$this->mockL10nT('File Information PHP module', 1);
+		$this->mockL10nT('Error: File Information PHP module required but not installed.', 1);
 	}
 
 	private function assertCheckExist($position, $title, $help, $status, $required, $assertionArray)
@@ -192,6 +194,17 @@ class InstallerTest extends MockedTest
 			true,
 			$install->getChecks());
 
+		$this->mockFunctionL10TCalls();
+		$this->setFunctions(['finfo_open' => false]);
+		$install = new Installer();
+		$this->assertFalse($install->checkFunctions());
+		$this->assertCheckExist(10,
+			'File Information PHP module',
+			'Error: File Information PHP module required but not installed.',
+			false,
+			true,
+			$install->getChecks());
+
 		$this->mockFunctionL10TCalls();
 		$this->setFunctions([
 			'curl_init' => true,
@@ -200,7 +213,8 @@ class InstallerTest extends MockedTest
 			'mb_strlen' => true,
 			'iconv_strlen' => true,
 			'posix_kill' => true,
-			'json_encode' => true
+			'json_encode' => true,
+			'finfo_open' => true,
 		]);
 		$install = new Installer();
 		$this->assertTrue($install->checkFunctions());