Problem/Motivation
The get_arguments_tokens() function uses a while loop to iterate over argument handlers:
while ($this->view->display_handler->get_handlers('argument')) { ... }
This results in an infinite loop because get_handlers() returns a cached array of handlers that is never modified inside the loop.
The change was introduced as part of cleanup in issue #3386717, but was likely not intended.
---
Steps to reproduce
1. Create a view with at least one contextual filter (argument).
2. Set "Link display" to "Custom URL"
3. Observe the request hanging or exhausting memory due to an infinite loop.
---
Proposed resolution
Replace the while loop with a for loop to properly iterate over the static list of argument handlers. For example:
$arguments = $this->view->display_handler->get_handlers('argument') ?? [];
$num_arguments = count($arguments);
for ($i = 0; $i < $num_arguments; $i++) {
...
}
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | views--infinite-loop-3517834-2.patch | 1.33 KB | xlin1003 |
Comments
Comment #2
xlin1003 commentedPatch attached to switch to for loop
Comment #3
jose reyero commentedThanks, it works.
Not sure about php requirements though, it will be PHP7.4 for this code... (?)