From 72e745be26647b1ce1ca3240cb2ffbe20cfe91dc Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 21 Feb 2018 21:09:08 +0100 Subject: [PATCH] Handle strict typing in Checker and fix tests Signed-off-by: Roeland Jago Douma --- lib/private/IntegrityCheck/Checker.php | 7 ++++++- tests/lib/IntegrityCheck/CheckerTest.php | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/private/IntegrityCheck/Checker.php b/lib/private/IntegrityCheck/Checker.php index f1a04d0eac40d..44544b6770ed7 100644 --- a/lib/private/IntegrityCheck/Checker.php +++ b/lib/private/IntegrityCheck/Checker.php @@ -333,7 +333,12 @@ private function verify(string $signaturePath, string $basePath, string $certifi return []; } - $signatureData = json_decode($this->fileAccessHelper->file_get_contents($signaturePath), true); + $content = $this->fileAccessHelper->file_get_contents($signaturePath); + $signatureData = null; + + if (\is_string($content)) { + $signatureData = json_decode($content, true); + } if(!\is_array($signatureData)) { throw new InvalidSignatureException('Signature data not found.'); } diff --git a/tests/lib/IntegrityCheck/CheckerTest.php b/tests/lib/IntegrityCheck/CheckerTest.php index 09e6990a0f386..71a9935008b62 100644 --- a/tests/lib/IntegrityCheck/CheckerTest.php +++ b/tests/lib/IntegrityCheck/CheckerTest.php @@ -58,6 +58,9 @@ public function setUp() { $this->cacheFactory = $this->createMock(ICacheFactory::class); $this->appManager = $this->createMock(IAppManager::class); + $this->config->method('getAppValue') + ->will($this->returnArgument(2)); + $this->cacheFactory ->expects($this->any()) ->method('createDistributed')