fix(core) null safe on metadata

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
This commit is contained in:
Maxence Lange 2024-03-11 10:44:01 -01:00
parent 9b6424e5ca
commit 681498a050
2 changed files with 10 additions and 7 deletions

View file

@ -2139,6 +2139,14 @@
<code>$file</code>
</MoreSpecificImplementedParamType>
</file>
<file src="lib/private/Files/Cache/Scanner.php">
<RedundantCondition>
<code>$metadataQuery?->extractMetadata($data)->asArray() ?? []</code>
</RedundantCondition>
<TypeDoesNotContainNull>
<code>$metadataQuery?->extractMetadata($data)->asArray() ?? []</code>
</TypeDoesNotContainNull>
</file>
<file src="lib/private/Files/Cache/Scanner.php">
<InvalidArgument>
<code>self::SCAN_RECURSIVE_INCOMPLETE</code>

View file

@ -194,13 +194,8 @@ class QuerySearchHelper {
$result = $query->execute();
$files = $result->fetchAll();
$rawEntries = array_map(function (array $data) use ($metadataQuery) {
// migrate to null safe ...
if ($metadataQuery === null) {
$data['metadata'] = [];
} else {
$data['metadata'] = $metadataQuery->extractMetadata($data)->asArray();
}
$rawEntries = array_map(function (array $data) use ($metadataQuery): CacheEntry {
$data['metadata'] = $metadataQuery?->extractMetadata($data)->asArray() ?? [];
return Cache::cacheEntryFromData($data, $this->mimetypeLoader);
}, $files);