Skip to content

Commit

Permalink
fix(Files): Change how scanner diffs for changed metadata
Browse files Browse the repository at this point in the history
Fixes #43408 

Signed-off-by: Josh <josh.t.richards@gmail.com>
  • Loading branch information
joshtrichards authored Feb 23, 2024
1 parent b0b4c7e commit ecd52e6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/private/Files/Cache/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,17 @@ public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData =
}

// Only update metadata that has changed
$newData = array_diff_assoc($data, $cacheData->getData());

// i.e. get all the values in $data that are not present in the cache already
// NOTE: we serialize then unserialize here because array_diff_assoc() doesn't
// support multidimensional arrays on its own (and otherwise internally casts any
// embedded array elements to attempt to compare them - not only generating warnings
// like "Array to string conversion" but also, as a resut, overlooking real differences)
$newData = array_diff_assoc(
array_map('serialize', $data),
array_map('serialize', $cacheData->getData())
);
$newData = array_map('unserialize', $newData);

// make it known to the caller that etag has been changed and needs propagation
if (isset($newData['etag'])) {
$data['etag_changed'] = true;
Expand Down

0 comments on commit ecd52e6

Please sign in to comment.