Call to a member function id() on string in UserHasRole.php

Created on 9 March 2023, over 1 year ago
Updated 8 August 2023, 11 months ago

Similar to issue # 3088481 (https://www.drupal.org/project/rules/issues/3088481) β†’ , I've found that the same issue exists in UserHasRole.php and can be fixed with the same fix as that described in issue # 3088481.

I found issue # 2824360 (Error "Call to a member function id() on string" for condition 'user has role(s)') β†’ which should have fixed the issue, but unfortunately it had no effect and has been marked closed, so I'm opening a new issue in the hopes of providing it with more visibility.

Problem/Motivation

A rule with the "User has role(s)" condition will crash with the following error:
Error: Call to a member function id() on string in Drupal\rules\Plugin\Condition\UserHasRole->Drupal\rules\Plugin\Condition\{closure}() (line 58 of modules/contrib/rules/src/Plugin/Condition/UserHasRole.php).

In my case, this occurred on Drupal 9.5.4 with Rules 8.x-3.0-alpha7.

Steps to reproduce

  1. Create a rule with the "User has role(s)" condition.
  2. Trigger the rule.
  3. The site will crash with the error message described in the Problem/Motivation.

Proposed resolution

I'll attach a patch to the issue as soon as it's been created.

πŸ’¬ Support request
Status

Postponed: needs info

Version

3.0

Component

Rules Core

Created by

πŸ‡ΊπŸ‡ΈUnited States jsutta United States

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024