Skip to content

Commit

Permalink
properly handle cases where cache wrappers block access
Browse files Browse the repository at this point in the history
`CacheWrapper::formatCacheEntry` can return false for files that should be filtered out

Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 authored and skjnldsv committed Nov 1, 2021
1 parent 63d3931 commit 118c647
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
3 changes: 0 additions & 3 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Cache/Wrapper/CacheJail.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEnt
if ($rawEntry) {
$jailedPath = $this->getJailedPath($rawEntry->getPath());
if ($jailedPath !== null) {
return $this->formatCacheEntry(clone $rawEntry);
return $this->formatCacheEntry(clone $rawEntry) ?: null;
}
}

Expand Down
5 changes: 3 additions & 2 deletions lib/private/Files/Cache/Wrapper/CacheWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function getCache() {
* 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;
Expand Down Expand Up @@ -311,7 +311,8 @@ public function getQueryFilterForStorage(): ISearchOperator {
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;
Expand Down

0 comments on commit 118c647

Please sign in to comment.