Skip to content

Commit

Permalink
Correct Cache setWorkarounds to take account of multiple script or st…
Browse files Browse the repository at this point in the history
…yle 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
  • Loading branch information
Geraint2 committed Nov 17, 2021
1 parent 79ac1e1 commit 21715f3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions libraries/src/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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));
}
}
Expand Down

0 comments on commit 21715f3

Please sign in to comment.