aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-08-11 17:35:37 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2021-11-01 11:48:01 +0100
commit118c647f61c2e84ed0fe55375f4063a6a6f8756c (patch)
tree1b199502c72396c5d24576014c7632937f837fd4
parent63d3931e8063e1923c2e79416f426b5f3c896ab1 (diff)
downloadnextcloud-server-118c647f61c2e84ed0fe55375f4063a6a6f8756c.tar.gz
nextcloud-server-118c647f61c2e84ed0fe55375f4063a6a6f8756c.zip
properly handle cases where cache wrappers block access
`CacheWrapper::formatCacheEntry` can return false for files that should be filtered out Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r--build/psalm-baseline.xml3
-rw-r--r--lib/private/Files/Cache/Wrapper/CacheJail.php2
-rw-r--r--lib/private/Files/Cache/Wrapper/CacheWrapper.php5
3 files changed, 4 insertions, 6 deletions
diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml
index 7a36e88eca3..156599e8b41 100644
--- a/build/psalm-baseline.xml
+++ b/build/psalm-baseline.xml
@@ -3509,9 +3509,6 @@
<code>string</code>
<code>string</code>
</InvalidReturnType>
- <NullableReturnStatement occurrences="1">
- <code>$this-&gt;view-&gt;hash($type, $this-&gt;path, $raw)</code>
- </NullableReturnStatement>
<UndefinedThisPropertyAssignment occurrences="1">
<code>$this-&gt;exists</code>
</UndefinedThisPropertyAssignment>
diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php
index 540b6f7b8c3..7183a6c0d2a 100644
--- a/lib/private/Files/Cache/Wrapper/CacheJail.php
+++ b/lib/private/Files/Cache/Wrapper/CacheJail.php
@@ -328,7 +328,7 @@ class CacheJail extends CacheWrapper {
if ($rawEntry) {
$jailedPath = $this->getJailedPath($rawEntry->getPath());
if ($jailedPath !== null) {
- return $this->formatCacheEntry(clone $rawEntry);
+ return $this->formatCacheEntry(clone $rawEntry) ?: null;
}
}
diff --git a/lib/private/Files/Cache/Wrapper/CacheWrapper.php b/lib/private/Files/Cache/Wrapper/CacheWrapper.php
index 8b8b4b6af80..e5300dc75f5 100644
--- a/lib/private/Files/Cache/Wrapper/CacheWrapper.php
+++ b/lib/private/Files/Cache/Wrapper/CacheWrapper.php
@@ -60,7 +60,7 @@ class CacheWrapper extends Cache {
* Make it easy for wrappers to modify every returned cache entry
*
* @param ICacheEntry $entry
- * @return ICacheEntry
+ * @return ICacheEntry|false
*/
protected function formatCacheEntry($entry) {
return $entry;
@@ -311,7 +311,8 @@ class CacheWrapper extends Cache {
public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry {
$rawEntry = $this->getCache()->getCacheEntryFromSearchResult($rawEntry);
if ($rawEntry) {
- return $this->formatCacheEntry(clone $rawEntry);
+ $entry = $this->formatCacheEntry(clone $rawEntry);
+ return $entry ?: null;
}
return null;