From 21715f374274b42358bedf5ddabf6734b8d9b87f Mon Sep 17 00:00:00 2001 From: Geraint Edwards Date: Wed, 17 Nov 2021 10:11:36 +0000 Subject: [PATCH] Correct Cache setWorkarounds to take account of multiple script or style declarations being used that mean that we have an array of scripts or stylesheets to be cached and not just a string Cache setWorkarounds returns an array not a string --- libraries/src/Cache/Cache.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/src/Cache/Cache.php b/libraries/src/Cache/Cache.php index 900f7ce481a97..7c418c82df695 100644 --- a/libraries/src/Cache/Cache.php +++ b/libraries/src/Cache/Cache.php @@ -595,7 +595,7 @@ public static function getWorkarounds($data, $options = array()) * @param string $data Cached data * @param array $options Array of options * - * @return string Data to be cached + * @return array Data to be cached * * @since 1.7.0 */ @@ -688,9 +688,13 @@ public static function setWorkarounds($data, $options = array()) { $oldScriptStr = $options['headerbefore'][$now][strtolower($type)]; - if ($oldScriptStr != $currentScriptStr) + // Save only the appended declaration. + if (\is_array($oldScriptStr) && \is_array($currentScriptStr)) + { + $newvalue[strtolower($type)] = array_diff_key($currentScriptStr, $oldScriptStr); + } + else { - // Save only the appended declaration. $newvalue[strtolower($type)] = StringHelper::substr($currentScriptStr, StringHelper::strlen($oldScriptStr)); } }