User tests: Successful: Unsuccessful:
After adding some options added for URI exclusions by @OctavianC in the cache plugin (#7767), this PR adds some other improvements:
With a fresh Joomla install with sample items, turn on cache plugin and exclude some SEF or Non-SEF page URI in "Exclude Pages" field, for instance:
Should be ok.
Since i'm not expert in Joomla code, if there are betters ways to do this, improvements are welcome.
Status | New | ⇒ | Pending |
Labels |
Added:
?
?
|
@brianteeman Thanks. Done
I haven't tested the code, but there are two things I've noticed:
%<input type="hidden" name="[A-Za-z0-9]+" value="1"\s+/>%
will incorrectly replace these as well:<input type="hidden" name="agree" value="1" />
<input type="hidden" name="id" value="1" />
<input type="hidden" name="catid" value="1" />
Basically all hidden fields that contain numbers and characters (that's a big range) will get replaced by the plugin and break functionality for the respective extensions.
This expression
%<input type="hidden" name="[A-Za-z0-9]+" value="1"\s+/>%
will incorrectly replace these as well: [...] Basically all hidden fields that contain numbers and characters (that's a big range) will get replaced by the plugin and break functionality for the respective extensions.
The problem is when you cache a page with a form token, that form token will be cached too. So it will be served to all users. This code was to try to correct that.
And yes, you are right, my mistake.
Any suggestions how to do this without breaking functionality?
I'm not really fond of the % regex delimiter. PHP examples use the forward slash and if you search on the web, almost everyone uses it as well.
In PHP preg expressions you can use any character as delimiter. Since URI use a lot of slashes i thing is more suitable and more user friendly for this case using another character, that is why i used %
instead of /
as regex delimiter.
A delimiter can be any non-alphanumeric, non-backslash, non-whitespace character.
I'm not arguing about the purpose of the expression, I understand what it's trying to do, I was just saying that it doesn't work well.
Ok. I will see if i can get some way to replace the token without breaking something.
If not i will remove it from the code.
Update:
From the code i discover the token is a 32 md5 hash character generated by the "md5" PHP function.
https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/session/session.php#L268-L274
https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/application/helper.php#L67-L70
Returns the hash as a 32-character hexadecimal number.
http://php.net/manual/en/function.md5.php
So i can fix the regex to find only a a-f0-9
string with 32 characters ([a-f0-9]{32}
).
That way none of your examples will match.
Looking at the code it seems JCache::getWorkarounds() already does what you're looking for, although I'm not sure where it's used. See 10b1f57
I didn't saw that. Will test.
Update:
Ok. I tested in an earlier version that didn't do that replacement. That is already being done in Joomla.
So i will remove that from this commit code when i have time.
Thanks @OctavianC
Ok. done and some minor otimizations
@OctavianC can you check?
Category | ⇒ | Plugins |
Labels |
Sorry for the long vacation :) Will test and report.
Took a look at the code and I'm not really fond of the part where the SEF URL and the non-SEF URL are concatenated:
if (preg_match('/' . preg_quote($exclusion, '/') . '/i', $this->_cache_key . ' ' . $internal_uri, $match))
There must be a cleaner way to do that. Why is it preg_quoted()
? This means that regular expressions won't work, which is the point of having that feature.
Also, if matching components is a feature, why don't we add a list of all components installed and have the user select them instead of typing them in?
Took a look at the code and I'm not really fond of the part where the SEF URL and the non-SEF URL are concatenated: There must be a cleaner way to do that.
This is for performance. Why do two preg_match
operations when we can do only one?
Why is it preg_quoted()? This means that regular expressions won't work, which is the point of having that feature.
I don't like it too. i will change.
Also, if matching components is a feature, why don't we add a list of all components installed and have the user select them instead of typing them in?
Yes a field for that could also be added.
Updated the code. Made some code improvements, comments and a small change to show the debug even if read from cache.
Didn't make the components select field part. Will not do it in this PR.
Please test.
Labels |
Category | Plugins | ⇒ | Language & Strings Plugins |
Can you extend your test scenario with the information how people can see if things are being cached.
Then we can let some people test this PR, improvements within the cache feature are very welcome
Can you extend your test scenario with the information how people can see if things are being cached.
Then we can let some people test this PR, improvements within the cache feature are very welcome
you can look at the generated files in the /cache directory to see if the page cache is generated or not
I have tested this item
Items added through the menu-item or via the advanced exclude field are not cached while others are. While site is offline no items are cached.
Category | Plugins Language & Strings | ⇒ | Administration Language & Strings Front End Plugins |
I have tested this item
Tested:
Site offline testing:
Tested:
Without patch:
Cached version gets loaded.
With patch:
Site is loaded as offline.
@euismod2336 can you please retest?
I have tested this item
After the site was turned offline, the sites were still cached.
After the site was turned offline, the site showed the preset offline message.
Tested @icampus
Status | Pending | ⇒ | Ready to Commit |
RTC after two successful tests.
This has merge conflicts so cant be merged as is. Not sure if @andrepereiradasilva is around to fix them
@andrepereiradasilva can you please resolve conflicting Files?
Status | Ready to Commit | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-07-07 16:59:00 |
Closed_By | ⇒ | mbabker | |
Labels |
Added:
Conflicting Files
?
|
First time travis free in one go!