Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <[email protected]>
  • Loading branch information
icewind1991 authored and skjnldsv committed Nov 1, 2021
commit 118c647f61c2e84ed0fe55375f4063a6a6f8756c
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