From 53fb05e2d0973264e93f4fe3fa1dfae88bc15399 Mon Sep 17 00:00:00 2001 From: Daniel Kesselberg Date: Wed, 25 Jun 2025 14:37:39 +0200 Subject: [PATCH] fix(nullcache): make get compliant with the interface The interface defines ICacheEntry|false, thus we should not return null. Signed-off-by: Daniel Kesselberg --- build/psalm-baseline.xml | 19 ------------ lib/private/Lockdown/Filesystem/NullCache.php | 31 ++++++++++--------- .../lib/Lockdown/Filesystem/NullCacheTest.php | 2 +- 3 files changed, 18 insertions(+), 34 deletions(-) diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index dc32bcaa4de..26ee47735ad 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -4112,31 +4112,12 @@ - - - - - -1, - 'parent' => -1, - 'name' => '', - 'path' => '', - 'size' => '0', - 'mtime' => time(), - 'storage_mtime' => time(), - 'etag' => '', - 'mimetype' => FileInfo::MIMETYPE_FOLDER, - 'mimepart' => 'httpd', - 'permissions' => Constants::PERMISSION_READ - ])]]> - diff --git a/lib/private/Lockdown/Filesystem/NullCache.php b/lib/private/Lockdown/Filesystem/NullCache.php index e84ff40e00c..fcd9e7f1340 100644 --- a/lib/private/Lockdown/Filesystem/NullCache.php +++ b/lib/private/Lockdown/Filesystem/NullCache.php @@ -21,20 +21,23 @@ class NullCache implements ICache { } public function get($file) { - return $file !== '' ? null : - new CacheEntry([ - 'fileid' => -1, - 'parent' => -1, - 'name' => '', - 'path' => '', - 'size' => '0', - 'mtime' => time(), - 'storage_mtime' => time(), - 'etag' => '', - 'mimetype' => FileInfo::MIMETYPE_FOLDER, - 'mimepart' => 'httpd', - 'permissions' => Constants::PERMISSION_READ - ]); + if ($file !== '') { + return false; + } + + return new CacheEntry([ + 'fileid' => -1, + 'parent' => -1, + 'name' => '', + 'path' => '', + 'size' => '0', + 'mtime' => time(), + 'storage_mtime' => time(), + 'etag' => '', + 'mimetype' => FileInfo::MIMETYPE_FOLDER, + 'mimepart' => 'httpd', + 'permissions' => Constants::PERMISSION_READ + ]); } public function getFolderContents($folder) { diff --git a/tests/lib/Lockdown/Filesystem/NullCacheTest.php b/tests/lib/Lockdown/Filesystem/NullCacheTest.php index 5e120e9bdc7..cc105494823 100644 --- a/tests/lib/Lockdown/Filesystem/NullCacheTest.php +++ b/tests/lib/Lockdown/Filesystem/NullCacheTest.php @@ -27,7 +27,7 @@ class NulLCacheTest extends \Test\TestCase { } public function testGetEmpty(): void { - $this->assertNull($this->cache->get('foo')); + $this->assertFalse($this->cache->get('foo')); } public function testGet(): void {