Problem/Motivation
HandlerBase::breakString doesn't handle tokens, leading to type mismatches in calling code. For example when sending a token to the numeric argument:
Warning: Undefined variable $operator in /var/www/html/web/core/modules/views/src/Plugin/views/HandlerBase.php on line 867
The website encountered an unexpected error. Try again later.
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 75 of core/modules/views/src/Plugin/views/argument/NumericArgument.php).
Steps to reproduce
- Create a view with an argument and set it to allow multiple values
- In the preview set a token style arguments input, i.e. [token:for:something]
- Check the logs
Proposed resolution
Default the operator to a string so at least the type mismatches won't occur. We could consider setting it to a different default, but starting with a empty string feels safe.
Remaining tasks
Review
Discuss
User interface changes
None
Introduced terminology
None
API changes
None
Data model changes
None
Release notes snippet
Issue fork drupal-3546894
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:
- 3546894-handlerbasebreakstring-doesnt-handle
changes, plain diff MR !13247
Comments
Comment #2
lendudeComment #4
lendudeThis should fix the mismatches at least. Setting the default to either 'or' or 'and' feels like we would be assuming a little more than we are doing now, so an empty string feels safe.
Comment #5
perryjanssenI was able to reproduce this bug and applying the patch fixes it!
Comment #6
lendudeComment #8
smustgrave commentedRebased because something weird was going on with cspell. Seems to have been resolved
Ran the test-only
Which shows the test for the scenario described here. Nice to see additional test coverage get added!
Manually testing following the steps I do see the warning and the fix does seem to address it.
LGTM!
Comment #9
longwaveBackported down to 11.2.x as an eligible bug fix. This likely affects 10.x as well but I don't think the test is backportable, not sure this is worth the effort of making that change.
Committed and pushed 62a4821009d to 11.x and 9d5cb3f3fbe to 11.3.x and 0f18475e22d to 11.2.x. Thanks!