Problem/Motivation
Views that generate requests with a huge amount of arguments (more than 3500) give WSOD.
The issue was reproduced on commerce order view with the amount of order items more than 3500.
Steps to reproduce
It was reproduced on commerce order view with a number of order items of more than 3500, so
1. Install commerce module
2. Create an order with the number of order items more than 3500.
3. Go to the order view page.
Expected result
Page (view) opened.
Actual result
The website encountered an unexpected error. Please try again later.
Error in the watchdog: TypeError: Cannot assign null to property Drupal\views\Plugin\views\argument\ArgumentPluginBase::$operator of type string in Drupal\views\Plugin\views\argument\NumericArgument->title() (line 63 of /usr/www/users/cbefce/web/core/modules/views/src/Plugin/views/argument/NumericArgument.php).
Root cause of issue
web/core/modules/views/src/Plugin/views/HandlerBase::breakString gives unexpected results in case of using a string with a huge amount of filter parameters, like "N1+N2+N3....+N3500" (it breaks somewhere at a number of filters ~ 3500).
The reason for that is preg_match can't handle a long string: For the longer string, the issue could be related to the length of the string causing a problem in PHP's regex engine. PHP has a limit on the size of the string it can process with regular expressions, and very long strings can lead to unexpected behavior, such as failing to match.
Proposed resolution
Fix web/core/modules/views/src/Plugin/views/HandlerBase::breakString to avoid using preg_match.
| Comment | File | Size | Author |
|---|---|---|---|
| #36 | views-handlerbase-breakstring-3409401-36.patch | 5.63 KB | grapefruitjuice |
Issue fork drupal-3409401
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
Ihor Ukhan commentedHere is the path to replace preg_match in the Drupal\views\Plugin\views/HandlerBase::breakString
All the tests Drupal\Tests\views\Functional\HandlerHandlerTest::testBreakString passed
Comment #3
Ihor Ukhan commentedHere is the updated patch that passed all the tests
Comment #4
Ihor Ukhan commentedComment #8
naveenvalechaI have used #3 and it worked like a charm for me. It also fixed the issue for filtering a string containing '':" in it.
Example - topic:sci-fi+topic:fantasy
I have converted #3 patch to a PR https://git.drupalcode.org/project/drupal/-/merge_requests/8417
Comment #9
naveenvalechaSetting it to RTBC as the work in #8 is not mine
Comment #10
catchThis could use some test coverage if possible.
Comment #11
smustgrave commentedFor the test coverage
Comment #13
akhil babuAdded tests.
Comment #14
lendudeLooks good, one more test case would be nice.
Can we come up with other cases that the regex might have missed like in #8 and make sure we are ok with that?
Comment #16
bharath-kondeti commentedComment #17
smustgrave commentedbelieve feedback for additional test coverage has been addressed.
Comment #18
quietone commentedTrying for an easier to read title
Comment #19
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #21
shalini_jha commentedI reviewed the merge request and found some conflicts, so I rebased and resolved them. The pipeline has also passed successfully, so I’m moving it back to "Needs Review."
Comment #22
smustgrave commentedRebase seems fine.
Comment #23
quietone commentedI left some comments in the MR. I also updated credit.
Comment #24
shalini_jha commentedI have reviewed all the feedback and implemented the necessary changes accordingly. After applying the updates, I re-ran the pipeline, and it is working as expected. I have also verified the empty string case, and it is functioning correctly without any issues. Moving this forward for your review. Kindly review.
Comment #25
smustgrave commentedFeedback appears to be addressed
Comment #26
alexpottMade a suggestion to change the code on the MR.
Comment #27
shalini_jha commentedI have updated the if condition to handle the scenario, and after testing, the test is now passing successfully. I am moving this for review. Please take a look and let me know if it makes sense to you.
Comment #28
smustgrave commentedFor the scenario you saw a failure in can we add test coverage for that one too please.
If you are another contributor eager to jump in, please allow the previous poster at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!
Comment #29
shalini_jha commentedThank you @smustgrave for the review & feedback. the scenario i have mentioned is the existing test that is failing after the code change
Comment #30
shalini_jha commentedI am moving this for review. Please take a look and let me know if it makes sense, or if any additional tests need to be added?
Comment #31
smustgrave commentedNope think that should be good.
Comment #32
longwaveSome nits about comments.
Comment #33
shalini_jha commentedI have addressed all the feedback, including updating the comment for the single-word condition to improve clarity. Please let me know if we need to assert the single word in the test for further clarification.
Moving this to NR , Kindly review.
Comment #34
smustgrave commentedBelieve feedback has been addressed
Comment #35
quietone commentedhttps://git.drupalcode.org/project/drupal/-/merge_requests/8417/diffs#note_442553 @alexpott pointed out cases where the new code and the old produce different results. I don't see those test cases. If they are the, add a comment in the code.
To test that the results have not change I removed the changes from breakString and all the long string test cases from testBreakString. I expected the test to pass, it did not. These are the cases that failed.
How will this change of behavior affects sites?
Comment #36
grapefruitjuice commentedUntil we are waiting for upgrading to D11, on the 10.4.x branch(we tested it on the 10.4.7 version) we have an error when we're trying to apply patches from this topic:
So, I've updated the patch to the particular 10.4.x branch, coz we really need it and could not wait until we move to 11 version (I took the code from the pull request).
If anybody has the same problem with patching 10.4.x core, feel free to use the updated patch.