The Joomla System Plugin "Page Cache" provides 2 options for excluding pages from caching: Exclude Menu Items and Exclude URLs. Both work very well in Joomla 3. But since Joomla 4 and Joomla 5 the option "Exclude URLs" stops working.
Let's take a look at the file /plugins/system/cache/src/Extension/Cache.php
-> private function isExcluded()
-> from line 334:
-> the callback function for array_reduce: $reduceCallback
Apparently (from my view) there is a logic error here:
The initial $carry for the callback function is false, false [AND] anything equals false, next $carry can only be again false... that means, no matter how our regular expression matches the rule, the result is always false. The URLs, which we enter in the excluding list, will never be excluded from caching.
The solution: [OR] instead of [AND] should be used in the callback function:
return $carry || preg_match(...
The error exists also in the current Joomla 5 version.
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-02-24 08:23:39 |
Closed_By | ⇒ | joomdonation |
Thanks @liuvz for reporting the issue and code analyst. The solution you suggested is valid, too, but I think the current code is harder to read and also a bit slower (because it has too loop through all array elements for checking), so I made PR #42871 to address the issue use the same code as we used in Joomla 3. Please help testing, thanks !