Problem/Motivation
WebformNodeHooks::webformSubmissionQueryAccessAlter() (webform_node) passes the result of \Drupal::routeMatch()->getRouteName() straight to preg_match(). With no route matched, for example under Drush, in queue runners or in tests, the route name is NULL, so PHP logs:
preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in WebformNodeHooks.php:92
Caught on Webform 6.3.1 with Drupal 11.4. The code is the same on the 6.3.x branch. #3431852 fixed the same deprecation in webform_form_alter(), but not here.
Steps to reproduce
Enable webform and webform_node, then run a webform submission query with access checking outside a request, as the anonymous user:
drush php:eval "\Drupal::entityTypeManager()->getStorage('webform_submission')->getQuery()->accessCheck(TRUE)->count()->execute();"
Proposed resolution
Cast the route name to a string before matching. Behaviour is unchanged: an empty string does not match the results route pattern, so the method returns early as it does for any other route.
Remaining tasks
Review the merge request.
Issue fork webform-3642413
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 #3
olena.karlova commented