-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix broken caching system when array of allowed parameters used #6410
Fix broken caching system when array of allowed parameters used #6410
Conversation
…judge if validation fields have asterisk
Co-authored-by: kenjis <[email protected]>
…ion used Cache Include Query String in the /Config/Cache.php (line 73) suggest to the user 3 options to choose from: false = Disabled true = Enabled, take all query parameters into account. Please be aware that this may result in numerous cache files generated for the same page over and over again. array('q') = Enabled, but only take into account the specified list of query parameters. However, last option with array of important parameters just doesn't work. We were using third option, because we had one important parameter (color) on the site, and content were dynamic based on this parameter. But then we`ve seen huge amount of cache files on our server, thousands and thousands. Turned out, even when using array of parameters in Config/Cache $cacheQueryString option - CodeIgniter was creating new cache file for any requests just like it was set to 'true'. Cache fles generated for the same page over and over again, performance were slow. Since Google Ads, Bing, Yahoo and all marketing platforms always adding dynamic parameters like 'click_id' for example, 'utm_source', 'utm_medium' and other, cache file was creating for all requests from the paid traffic. It was almost impossible to catch, but we saw weird amount of caching files, and that helped us to see the problem. I`ve made testing on the clean CodeIgniter 4 installations, latest version. Happened there too. So I`ve checked the source code, and I saw there there is no difference between true/array options, theyjust work same. I believe this is very missleading, because Config/Cache showing 'array' option and suggest to use it. This fixes should help, and take into the account array option. Thank you
docs : fix typo in "General Topics » Managing your Applications"
…tom-error-asterisk-field Fix validation custom error asterisk field
Exclude non-monolithic files from CS
CodeIgniter4/app/Config/Cache.php Lines 55 to 71 in 9546098
|
Thank you for sending a PR!
|
It is better to use dedicated database for testing.
Sure thing :) I am going to write a test, but method that generating cache name (and having the bug) is protected. What is the best practice in CodeIgniter 4, to create a test for protected methods? Should I change it to public to run a test, or do something else? Thanks! |
Sorry, it is difficult to write test code for it.
It is fine in this case, Or integration test like this: CodeIgniter4/tests/system/CodeIgniterTest.php Line 569 in 9546098
No. We cannot change public APIs for bug fixes (as much as possible). |
Three new tests, for all suggested options of $cacheQueryString in the Config/Cache.php cacheQueryString = true cacheQueryString = false cacheQueryString = array('q')
Okay, I`ve created three new tests, for all possible values of the $cacheQueryString in Config/Cache.php Also the bug is fixed in CodeIgniter.php, and now when $cacheQueryString is set to array of important parameters - it works how it should. If you run tests in the current dev/master branch, you`ll see that testPageCacheWithCacheQueryStringArray() test is failling, because CodeIgniter creating 5 cache files instead of 3 expected. Thats pretty critical bug, because its generating thousands of cache files in the production server, and showing not cached version of the pages for all users with unique not important parameters like utm_source/click_id/etc In my branch its fixed |
Can you rebase? |
…espace docs: add about controllers namespace in routing
locale Is a BCP 47 compliant language tag. See https://www.php.net/manual/en/locale.setdefault.php
docs: update PHPDoc in Entity
…ales test: restore changed locale in Time tests
…ion used Cache Include Query String in the /Config/Cache.php (line 73) suggest to the user 3 options to choose from: false = Disabled true = Enabled, take all query parameters into account. Please be aware that this may result in numerous cache files generated for the same page over and over again. array('q') = Enabled, but only take into account the specified list of query parameters. However, last option with array of important parameters just doesn't work. We were using third option, because we had one important parameter (color) on the site, and content were dynamic based on this parameter. But then we`ve seen huge amount of cache files on our server, thousands and thousands. Turned out, even when using array of parameters in Config/Cache $cacheQueryString option - CodeIgniter was creating new cache file for any requests just like it was set to 'true'. Cache fles generated for the same page over and over again, performance were slow. Since Google Ads, Bing, Yahoo and all marketing platforms always adding dynamic parameters like 'click_id' for example, 'utm_source', 'utm_medium' and other, cache file was creating for all requests from the paid traffic. It was almost impossible to catch, but we saw weird amount of caching files, and that helped us to see the problem. I`ve made testing on the clean CodeIgniter 4 installations, latest version. Happened there too. So I`ve checked the source code, and I saw there there is no difference between true/array options, theyjust work same. I believe this is very missleading, because Config/Cache showing 'array' option and suggest to use it. This fixes should help, and take into the account array option. Thank you
Three new tests, for all suggested options of $cacheQueryString in the Config/Cache.php cacheQueryString = true cacheQueryString = false cacheQueryString = array('q')
Using data provider for 1 cache test instead of 3 different tests. https://phpunit.readthedocs.io/en/9.5/writing-tests-for-phpunit.html#writing-tests-for-phpunit-data-providers
…type to strict type for the
Sure, rebased branch, now all commits should be verified |
Oh, now this PR has 108 commits! How to rebase: |
Not sure what went wrong, I copied commands from instructions, see the snapshot. As I understand, its merged all existing commits from upstream/develop to this branch in last 10 days, and then added mine commits over it. Want to me create new branch and open another PR instead of this one? |
Yes. |
I have checked the latest $ vendor/bin/phpstan
Note: Using configuration file /Users/kenji/work/codeigniter/CodeIgniter4/phpstan.neon.dist.
434/434 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
[OK] No errors Your |
If you don't update Composer dependencies, run |
Worked like a charm, thank you! Please check new PR: |
Cache Include Query String in the /Config/Cache.php (line 73) suggest to the user 3 options to choose from:
However, last option with array of important parameters just doesn't work. We were using third option, because we had one important parameter (color) on the site, and content were dynamic based on this parameter.
But then we`ve seen huge amount of cache files on our server, thousands and thousands. Turned out, even when using array of parameters in Config/Cache $cacheQueryString option - CodeIgniter was creating new cache file for any requests just like it was set to 'true'. Cache fles generated for the same page over and over again, performance were slow.
Since Google Ads, Bing, Yahoo and all marketing platforms always adding dynamic parameters like 'click_id' for example, 'utm_source', 'utm_medium' and other, cache file was creating for all requests from the paid traffic. It was almost impossible to catch, but we saw weird amount of caching files, and that helped us to see the problem.
I`ve made testing on the clean CodeIgniter 4 installations, latest version. Happened there too.
So I`ve checked the source code, and I saw there there is no difference between true/array options, they just work same. I believe this is very missleading, because Config/Cache showing 'array' option and suggest to use it.
This fixes should help, and take into the account array option.
Thank you
Checklist: