Blocks give an error when edited when the Rules module is not installed

Created on 23 January 2024, 11 months ago

In Drupal 10.2.2 blocks can no longer be edited (ex. /admin/structure/block/manage/claro_page_title) and give an error Error: Class "Drupal\rules\Core\RulesConditionBase" not found in include() (regel 28 van /public_html/modules/contrib/civicrm_entity/src/Plugin/Condition/DrupalUserExist.php) when the Rules module is not installed.

πŸ› Bug report
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium hansrossel

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

Comments & Activities

  • Issue created by @hansrossel
  • πŸ‡ΊπŸ‡ΈUnited States markusa

    I tested on a local setup of Drupal 10.2.2 and CiviCRM 5.69

    I uninstalled the Rules module for this test, after uninstalling, removing Rules code, and clearing caches, I am still able to edit custom blocks

    I see in the error message you documented, that it is a CiviCRM Entity Rules Condition plugin that is not finding the base class from Rules. That is a plugin, and should be able to be in the codebase without Rules installed. Rules during its plugin discovery would look for modules that implement plugins

    Being unable to replicate, I wonder if there is something cache in your case, that may need a reset.

    Perhaps there is some other reason other than Rules being uninstalled that maybe the cause.

  • πŸ‡¨πŸ‡¦Canada paulrooney

    I tested with Drupal 10.2.2, CiviCRM 5.67.3, and CiviCRM Entity 4.0.0-beta1.

    If Rules is not installed, attempting to edit a block results in this error:

    Error: Class "Drupal\rules\Core\RulesConditionBase" not found in include() (line 28 of /PATH/httpdocs/modules/contrib/civicrm_entity/src/Plugin/Condition/DrupalUserExist.php).

    If Rules 8.x-3.0-alpha8 is installed, blocks are editable.

    It looks like CiviCRM Entity uses RulesConditionBase, which is defined in the Rules module to extend ConditionPluginBase from Drupal core.

    CiviCRM Entity module:

    "use Drupal\rules\Core\RulesConditionBase;" is referenced in these three files:

    https://git.drupalcode.org/project/civicrm_entity/-/blob/4.0.x/src/Plugi...
    https://git.drupalcode.org/project/civicrm_entity/-/blob/4.0.x/src/Plugi...
    https://git.drupalcode.org/project/civicrm_entity/-/blob/4.0.x/src/Plugi...

    ---

    Rules module:

    "abstract class RulesConditionBase extends ConditionPluginBase implements RulesConditionInterface"
    https://git.drupalcode.org/project/rules/-/blob/8.x-3.x/src/Core/RulesCo...

    ---

    Drupal core

    "abstract class ConditionPluginBase extends ExecutablePluginBase implements ConditionInterface"
    https://git.drupalcode.org/project/drupal/-/blob/10.2.x/core/lib/Drupal/...

  • Status changed to Needs review 11 months ago
  • πŸ‡ΊπŸ‡ΈUnited States markusa

    I've got at least 5 production sites with Drupal 10 that don't have the Rules module, and do have the CiviCRM Entity module, running without error.

    There's got to be some other reason.

    Was Rules installed for some time, but has been recently uninstalled?

    Perhaps there is another module that is discovering the plugin, that I don't have.

    Regardless, it is not hard to move anything Rules related to a submodule

    Here is a PR which you can use to patch with: https://github.com/eileenmcnaughton/civicrm_entity/pull/462
    https://patch-diff.githubusercontent.com/raw/eileenmcnaughton/civicrm_en...

  • Status changed to Active 11 months ago
  • πŸ‡¨πŸ‡¦Canada paulrooney

    Thank you! Moving Rules integration to a submodule solves the problem I was having, and the site works as expected without Rules installed.

    I'm not aware of Rules ever having been installed there previously. I agree there must be some other reason, as I tested the original issue on a different site with Drupal 10.2.2, CiviCRM 5.68.1, and CiviCRM Entity 4.0.0-beta1, without Rules installed and the issue did not occur there.

    I'm not sure what the cause was in this case but the submodule does solve the problem. Thanks again.

Production build 0.71.5 2024