? ? Pending

User tests: Successful: Unsuccessful:

avatar GeraintEdwards
GeraintEdwards
17 Nov 2021

…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

Pull Request for Issue # .

Summary of Changes

Correct Joomla\CMS\Cache 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
Joomla\CMS\Cache Cache setWorkarounds returns an array not a string

Testing Instructions

  1. On a Joomla 4-dev site install this module https://www.yoursites.net/testextensions/mod_cachetest.zip
  2. Create 2 instances of this module to display on the same page in different module positions - leave caching setting as 'global' in module settings
  3. Enable Joomla conservative caching in Joomla config
  4. Enable maximum error reporting in Joomla config#
  5. Make sure the Joomla cache is cleared
  6. Load the frontend page where modules are displayed
  7. Reload the frontend page

Actual result BEFORE applying this Pull Request

At Step 6 you get a php warning on arguments to mb_strlen and 4 javascript alert messages

See https://www.yoursites.net/testextensions/Screenshot%202021-11-17%20at%2010-05-05%20Home.png

At step 7 you get a different PHP warning from libraries/src/Document/HtmlDocument.php because it expects an array but has been given a script by Cache.php

Expected result AFTER applying this Pull Request

Page is displayed with no warning messages and module content is delivered from the cache correctly with 4 alerts

Documentation Changes Required

avatar GeraintEdwards GeraintEdwards - open - 17 Nov 2021
avatar GeraintEdwards GeraintEdwards - change - 17 Nov 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 17 Nov 2021
Category Libraries
avatar tonypartridge
tonypartridge - comment - 29 Nov 2021

@brianteeman would you have a minute some time to test?

I'll do one tomorrow.

avatar brianteeman
brianteeman - comment - 29 Nov 2021

At Step 6 you get a php warning on arguments to mb_strlen and 4 javascript alert messages

I do not get the same results as you at this step. I just get an error page with this error
mb_strlen(): Argument #1 ($string) must be of type string, array given

image

Which means that step 7 can never occur

avatar GeraintEdwards
GeraintEdwards - comment - 29 Nov 2021

@brianteeman Its the same problem the cache code is applying strlen to an array.

I had error reporting enabled but not joomla debug mode when I was testing

avatar brianteeman
brianteeman - comment - 29 Nov 2021

I enabled debug because you had it enabled in your screenshot ;)

With or without the debug I get the error page and not what you described

avatar GeraintEdwards
GeraintEdwards - comment - 29 Nov 2021

If you look at the screenshot of your debug trace notice that line 4 in the stack refers to line 694 of the file Cache.php - this is exactly where I am saying the error arises. If you are still seeing a reference to strlen error on line 694 of Cache.php then you I suspect you are seeing a cached version of the error output since line 694 no longer has a call to StringHelper::strlen in my version of the code.

If you apply the fix and clear the cache and repeat the test the error you are seeing should not appear.

avatar tonypartridge
tonypartridge - comment - 29 Nov 2021

I have tested this item successfully on 21715f3

Tested Successfully, pre-patch clearly shows the error

Warning
: mb_substr() expects parameter 1 to be string, array given in
/var/www/joomla4/libraries/vendor/joomla/string/src/phputf8/mbstring/core.php
on line

On applying patch without clearing cache we get:

Warning
: Invalid argument supplied for foreach() in
/var/www/joomla4/libraries/src/Document/HtmlDocument.php
on line
389

Clearing cache with path applied it loads without error.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36068.

avatar tonypartridge tonypartridge - test_item - 29 Nov 2021 - Tested successfully
avatar GeraintEdwards
GeraintEdwards - comment - 29 Nov 2021

Thanks @tonypartridge - forgot to emphasise that after applying the fix it is ESSENTIAL to clear the cache.

The error in HtmlDocument.php that you saw is a secondary manifestation of the same problem - Cache.php is storing the the cached data as a string but HtmlDocument.php is expecting it to be an array. My change resolves this issue (as you discovered)

avatar GeraintEdwards
GeraintEdwards - comment - 30 Nov 2021

@Fedik Would you mind taking a look at this issue and PR please - your PR ( in https://github.com/joomla/joomla-cms/commit/86a0d88e415112553ede15e989cfa1b81a32e15c) stored the scripts and styles as arrays but these changes should have been carried over to the Cache system too. This PR resolves these issues.

Thanks

avatar Fedik
Fedik - comment - 30 Nov 2021

From code review it looks good,
I try to test a bit later

avatar Fedik
Fedik - comment - 4 Dec 2021

I have tested this item successfully on 21715f3


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36068.

avatar Fedik Fedik - test_item - 4 Dec 2021 - Tested successfully
avatar Fedik Fedik - change - 4 Dec 2021
Status Pending Ready to Commit
avatar Fedik
Fedik - comment - 4 Dec 2021

r
t
c


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36068.

avatar pritam825
pritam825 - comment - 4 Dec 2021

I have tested this item successfully on 21715f3


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36068.

avatar pritam825 pritam825 - test_item - 4 Dec 2021 - Tested successfully
avatar khu5h1
khu5h1 - comment - 5 Dec 2021

I have tested this item successfully on 21715f3


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/36068.

avatar khu5h1 khu5h1 - test_item - 5 Dec 2021 - Tested successfully
avatar wilsonge wilsonge - change - 5 Jan 2022
Labels Added: ? ?
avatar wilsonge wilsonge - change - 5 Jan 2022
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2022-01-05 12:37:57
Closed_By wilsonge
avatar wilsonge wilsonge - close - 5 Jan 2022
avatar wilsonge wilsonge - merge - 5 Jan 2022
avatar wilsonge
wilsonge - comment - 5 Jan 2022

Thanks!

Add a Comment

Login with GitHub to post a comment