No Code Attached Yet
avatar liuvz
liuvz
6 Dec 2023

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.

avatar liuvz liuvz - open - 6 Dec 2023
avatar liuvz liuvz - change - 6 Dec 2023
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 6 Dec 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 6 Dec 2023
avatar joomdonation joomdonation - close - 24 Feb 2024
avatar joomdonation
joomdonation - comment - 24 Feb 2024

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 !

avatar joomdonation joomdonation - change - 24 Feb 2024
Status New Closed
Closed_Date 0000-00-00 00:00:00 2024-02-24 08:23:39
Closed_By joomdonation

Add a Comment

Login with GitHub to post a comment