From e70375b7fb3bc63dad38f63dd204273759235d46 Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 23 Feb 2024 12:55:58 -0500 Subject: [PATCH] fix(Files): Change how scanner diffs for changed metadata Fixes #43408 Signed-off-by: Josh --- lib/private/Files/Cache/Scanner.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php index 0c82e21e30d47..b48493c13532e 100644 --- a/lib/private/Files/Cache/Scanner.php +++ b/lib/private/Files/Cache/Scanner.php @@ -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;