Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently there is no support to handle array in the query parameters.
Example String like 'foo[]=1&foo[]=2&foo[]=3' will just give an
array('foo' => 3)
The proper way is to use parse_str(). #1597784: [Performance]: drupal_get_query_array should be replaced with parse_str
Comment | File | Size | Author |
---|---|---|---|
#15 | interdiff.txt | 1.39 KB | rafaolf |
#15 | 2023815-15.patch | 811 bytes | rafaolf |
#6 | drupal_get_query_array_support-2023815-6.patch | 804 bytes | junedkazi |
#4 | drupal_get_query_array_support-2023815-4.patch | 846 bytes | junedkazi |
drupal_get_query_array_support.patch | 849 bytes | junedkazi | |
Comments
Comment #1
junedkazi CreditAttribution: junedkazi commentedComment #2
junedkazi CreditAttribution: junedkazi commentedComment #4
junedkazi CreditAttribution: junedkazi commentedComment #6
junedkazi CreditAttribution: junedkazi commentedComment #7
junedkazi CreditAttribution: junedkazi commentedComment #8
junedkazi CreditAttribution: junedkazi commentedComment #9
dlu CreditAttribution: dlu commentedMoved to database system per #2050763-16: Refine "base system" component (notes on refactoring of "base system" category here: https://docs.google.com/a/acquia.com/spreadsheet/ccc?key=0AusehVccVSq2dF...).
Comment #10
xjm6: drupal_get_query_array_support-2023815-6.patch queued for re-testing.
Comment #12
cilefen CreditAttribution: cilefen commentedOk, but the suggestion in the change record is for processing URL query parameters. max_input_vars defaults to 1000 on my system. It doesn't seem like a real problem in this case so I don't think this is a real-world problem.
Furthermore, parse_str() works in this case, so this issue is effectively solved:
Output:
And, #1597784: [Performance]: drupal_get_query_array should be replaced with parse_str eliminated drupal_get_query_array().
Comment #13
cilefen CreditAttribution: cilefen commentedOops.
Comment #14
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedI think this is still valid for Drupal 7.
Comment #15
rafaolf CreditAttribution: rafaolf at CI&T commentedI did not consider nested arrays for that solution, as we are talking about a query parameter. Also, the regex quantifier is a lazy one instead of greedy for the same reason.