? Release Blocker ? Pending

User tests: Successful: Unsuccessful:

avatar Denitz
Denitz
25 Feb 2022

Summary of Changes

Please check #37122 and #35776

Now, before rendering the cached module, we empty the document and WebAssetmanager data, hence the module cache contains all data added by a module.

Testing Instructions

Apply patch, enable Joomla caching, load page with cached modules

Actual result BEFORE applying this Pull Request

Module cache doesn't have own assets if they were also added before module render.

Expected result AFTER applying this Pull Request

Module cache always have own assets in cache.

Documentation Changes Required

No.

e42b799 25 Feb 2022 avatar Denitz start
avatar Denitz Denitz - open - 25 Feb 2022
avatar Denitz Denitz - change - 25 Feb 2022
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 25 Feb 2022
Category Libraries
avatar Denitz Denitz - change - 25 Feb 2022
The description was changed
avatar Denitz Denitz - edited - 25 Feb 2022
9b1e757 25 Feb 2022 avatar Denitz CS
avatar Denitz Denitz - change - 25 Feb 2022
Labels Added: ?
avatar brianteeman
brianteeman - comment - 25 Feb 2022

testing this with the same instructions as for testing #37123 and this also fixes the issue

avatar brianteeman brianteeman - test_item - 25 Feb 2022 - Tested successfully
avatar brianteeman
brianteeman - comment - 25 Feb 2022

I have tested this item successfully on 9b1e757


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

avatar alikon alikon - test_item - 25 Feb 2022 - Tested successfully
avatar alikon
alikon - comment - 25 Feb 2022

I have tested this item successfully on 9b1e757

under the same conditions of #37123


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

avatar alikon alikon - change - 25 Feb 2022
Status Pending Ready to Commit
avatar alikon alikon - change - 26 Feb 2022
Status Ready to Commit Pending
avatar nikosdion nikosdion - test_item - 1 Mar 2022 - Tested successfully
avatar nikosdion
nikosdion - comment - 1 Mar 2022

I have tested this item successfully on 434735e

I performed the test instructions on this PR and those in #37122 (where I explained why the approach we see in this here PR would be most preferable). SUCCESS IN BOTH CASES! WOOT!

Thank you so very much @Denitz for writing the code! Here's to hoping this will make it into 4.1.1 :)


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

avatar nikosdion
nikosdion - comment - 1 Mar 2022

@alikon @brianteeman Would either (of both) of you please redo the test here so it can become RTC?

avatar alikon
alikon - comment - 2 Mar 2022

I have tested this item successfully on 434735e


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

avatar alikon alikon - test_item - 2 Mar 2022 - Tested successfully
avatar alikon alikon - change - 2 Mar 2022
Status Pending Ready to Commit
avatar alikon
alikon - comment - 2 Mar 2022

RTC


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

avatar Fedik
Fedik - comment - 2 Mar 2022

Addittionaly, instead of resetting AssetManager, can create temporary instance.

public function setWebAssetManager(WebAssetManager $webAsset): self
{
$this->webAssetManager = $webAsset;
return $this;
}

else
{
$webAssetManager = new WebAssetManager(\Joomla\CMS\Factory::getContainer()->get('webassetregistry'));
$this->setWebAssetManager($webAssetManager);
}

avatar nikosdion
nikosdion - comment - 2 Mar 2022

@Fedik This is bad architecture. The web asset registry and manager should be locked in the container (set once). Otherwise any extension can break the entire frontend of the application by messing around with the WAM which completely beats the purpose of having the WAM in the first place...

avatar Fedik
Fedik - comment - 2 Mar 2022

Okay, I fine with both way, but lock should not be resetable.

avatar nikosdion
nikosdion - comment - 2 Mar 2022

@Fedik It has to be if we want caching to work correctly. The other option is overengineering WAM to keep a log of actions (what I had originally proposed in my comments to you). It's far more complicated.

Any other solution would very likely require rethinking WAM but it's way too late for that. The best time to do that would have been around 3 years ago, before the Joomla 4 betas. We're well past that. So we have to work with what we have, even if it's a sad compromise.

Between the two evils, having reset() is the lesser evil. It's something that cannot be refactored out of Joomla without seeing it's used in the caching code which will (or SHOULD) trigger an alert in whoever is refactoring the code, find these issues and find a solution (or leave it alone). Setting a new WAM instance in the container would be refactored out without a second thought (it's such an obvious architectural mistake nobody will think twice) and we'd have a regression.

There is a way to have our pie and eat it too. We can rig the reset() method to only be callable by Cache descendants by using debug_backtrace and making sure one of the callers is a class which is identical to or extends Cache. This would make the method public but inaccessible to unauthorised callers. It should also be marked as @internal in the docblock to note that. This is a trick I am using in my security software after I saw a lot of third party software trying to abuse my .htaccess Maker model to add exceptions for themselves without asking the user.

avatar Fedik
Fedik - comment - 2 Mar 2022

It has to be if we want caching to work correctly.

I mean you can still use reset() if you like, but if manager is locked then it should not be possible to reset.
Even more, it should throw an exception when someone tries to reset "locked" manager.

Like in useAsset()

public function useAsset(string $type, string $name): WebAssetManagerInterface
{
if ($this->locked)
{
throw new InvalidActionException('WebAssetManager is locked, you came late');
}

The reason I wrote a some comments ago

avatar bembelimen
bembelimen - comment - 3 Mar 2022

Any opinions on @Fedik comment?

avatar nikosdion
nikosdion - comment - 3 Mar 2022

@bembelimen You can do that, but we'd have to reset all tests and retest yet again. At this point besides me, a party affected by the Joomla caching bug and who has the technical experience to test patches like that, nobody else would test, this would never be fixed and Joomla would forever remain broken (and vulnerable!) when caching is enabled. That would be unacceptable.

Instead, why don't we merge this as-is and @Fedik can make a new PR to add the lock check in reset()? If you ping me I can provide the test for it. Between the three of us and possibly four (if @alikon is still interested in this saga) we can find a second test and merge his PR. This way all of us can have our pie and eat it too. Fair?

avatar bembelimen
bembelimen - comment - 9 Mar 2022

I thought about it and (yeah I hear y'all laughing in context of Joomla) we should not try to merge anything which has that obvious an issue we can resolve.

So I set this to an release blocker to show that I really intent to have this in 4.1.1. but only with the fix.

Additionally the following promise: if the fix is there till the 15th of march I will do everything so we get two proper and valid tests and it will be part in 4.1.1.

If after the 15th I still will try to get tests but can't guaranteed anymore.

Deal?

avatar richard67
richard67 - comment - 11 Mar 2022

I thought about it and (yeah I hear y'all laughing in context of Joomla) we should not try to merge anything which has that obvious an issue we can resolve.

So I set this to an release blocker to show that I really intent to have this in 4.1.1. but only with the fix.

Additionally the following promise: if the fix is there till the 15th of march I will do everything so we get two proper and valid tests and it will be part in 4.1.1.

If after the 15th I still will try to get tests but can't guaranteed anymore.

Deal?

@Denitz Could you implement the changes suggested here #37139 (comment) ? Thanks in advance.

avatar Denitz Denitz - change - 12 Mar 2022
Labels Added: ? Release Blocker ?
avatar Denitz
Denitz - comment - 12 Mar 2022

@richard67 Changes applied.

avatar richard67 richard67 - change - 12 Mar 2022
Status Ready to Commit Pending
avatar richard67
richard67 - comment - 12 Mar 2022

Back to pending.


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

avatar richard67
richard67 - comment - 12 Mar 2022

@bembelimen Is is ok now?

@brianteeman @alikon @nikosdion Could you test again? Thanks in advance.

avatar richard67
richard67 - comment - 13 Mar 2022

I have tested this item successfully on c5e26ed

I've tested with the test instructions on this PR as well as with those in #37122 .


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

avatar richard67 richard67 - test_item - 13 Mar 2022 - Tested successfully
avatar richard67
richard67 - comment - 13 Mar 2022

@brianteeman @alikon @nikosdion One more test needed.

c59a414 14 Mar 2022 avatar Denitz fix
avatar Denitz Denitz - change - 14 Mar 2022
Labels Removed: ? ?
avatar richard67
richard67 - comment - 14 Mar 2022

I have tested this item successfully on c59a414


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

avatar richard67 richard67 - test_item - 14 Mar 2022 - Tested successfully
avatar richard67
richard67 - comment - 14 Mar 2022

@brianteeman @alikon @nikosdion Am still begging for a 2nd test.

avatar alikon
alikon - comment - 14 Mar 2022

I have tested this item successfully on c59a414


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

avatar alikon alikon - test_item - 14 Mar 2022 - Tested successfully
avatar alikon alikon - change - 14 Mar 2022
Status Pending Ready to Commit
avatar alikon
alikon - comment - 14 Mar 2022

RTC


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

avatar bembelimen
bembelimen - comment - 15 Mar 2022

@nikosdion could you please quick check if you're still happy with the PR, then I would merge! Thanks.

avatar nikosdion
nikosdion - comment - 15 Mar 2022

I’m happy with this. Please merge. Thank you!

avatar bembelimen bembelimen - change - 15 Mar 2022
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2022-03-15 07:55:27
Closed_By bembelimen
Labels Added: ?
avatar bembelimen bembelimen - close - 15 Mar 2022
avatar bembelimen bembelimen - merge - 15 Mar 2022
avatar bembelimen
bembelimen - comment - 15 Mar 2022

Thank you all!

Add a Comment

Login with GitHub to post a comment