Batch is dependent on the order of query string parameters

Created on 17 May 2017, about 7 years ago
Updated 12 September 2023, 9 months ago

We are going through CloudFlare and we enabled their feature "Query String Sort". It's very useful, mostly for the search, because the query string parameters are always sorted alphabetically and you keep the number of combinations of the query string parameters to minimum. So for example the following requests:

?a=value&c=value&d=value&b=value
?b=value&d=value&c=value&a=value
?d=value&c=value&b=value&a=value
...

Will become one particular request

?a=value&b=value&c=value&d=value

So what happens with batch processing, if the query string sorting is enabled? Let's use real batch request:

/batch?id=18&op=do_nojs&op=do&_format=json

When sorting query string parameters, the request is turned to:

/batch?_format=json&id=18&op=do&op=do_nojs

And this results in error:

{"message":"Not acceptable format: json"}

Your larger batches are not fully processed. Why is this caused? The problem is that by reordering query string parameters Drupal thinks that operation is suddenly "do_nojs" and not "do", since it is now last one in the query string. So in the _batch_page() function in the switch it goes to "do_nojs" case and thus it ends up throwing exception in:

web/core/lib/Drupal/Core/EventSubscriber/AcceptNegotiation406.php:32

Full error message:

Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException: Not acceptable format: json in Drupal\Core\EventSubscriber\AcceptNegotiation406->onViewDetect406() (Line 32 in /web/core/lib/Drupal/Core/EventSubscriber/AcceptNegotiation406.php).

Sooooo, that's it. It would be really really amazing to making Batch to be not dependent on the order of query string parameters. Because currently with specific server configuration (or by using some external services), which reorders query string parameters, your batch processing won't work anymore.

✨ Feature request
Status

Needs work

Version

11.0 πŸ”₯

Component
BatchΒ  β†’

Last updated 4 days ago

Created by

πŸ‡ΈπŸ‡°Slovakia hideaway

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024