For about a year I have had an issue with a drupal 8 site that uses the Business Rules Module. Randomly actions are not triggered on events that had previously been firing off fine. I have noticed that clearing the cache tends to knock things back into an operational state. I am unable to replicate this manually and it seems to happen intermitently (I have seen no pattern). I did come accross an identical issue in the "Rules" module https://www.drupal.org/project/rules/issues/2893958 that seems to illustrate my exact case. I am not sure how much of the code is similar, but I thought I would bring it to your attention.

My current work around is cronning the clear cache action every hour.

Thanks for a great module. I hope this helps.

Comments

CProfessionals created an issue. See original summary.

lexsoft00’s picture

I do have a similar issue and it seems clearing the cache fix things.

The only way to replicate every time was to use Drush8:

1. Install Drupal8 and Business Rules with composer file provided. COMPOSER FILE
2. drush en business_rules token admin_toolbar admin_toolbar_tools adminimal_admin_toolbar -y
3. Go to /admin/config/workflow/business_rules/action/collection and add the action Show a message
4. Go to /admin/config/workflow/business_rules/collection and add a rule On CRON runs and attach the action Show a message
5. Clear the cache and run cron manually from UI > You should be able to see the action triggered and get displayed the mesage
6. Run drush cron and run cron manually from UI > You will not see the action triggered until clearing the cache

I wonder if it's related to the:

file: business_rules/src/EventSubscriber/BusinessRulesListener.php
line: 70
 // If there is no container service there is not possible to load any event.
    // As this method can be called before the container is ready, it might not
    // be available.
    // To avoid the necessity to manually clear all caches via user interface,
    // we are getting the plugin definition using this ugly way.
    if (!\Drupal::hasContainer() || !\Drupal::hasService('plugin.manager.business_rules.reacts_on')) {
      $query = Database::getConnection()
        ->query('SELECT value FROM {key_value} WHERE collection = :collection AND name = :name', [
          ':collection' => 'state',
          ':name'       => 'system.module.files',
        ])
        ->fetchCol();
lexsoft00’s picture

Priority: Normal » Major
lexsoft00’s picture

Big Thanks to @CProfessionals for pointing me in the right directions. I was able to refactor the patch from https://www.drupal.org/project/rules/issues/2893958.

It works now for me.

patch -p1 < actions-intermitently-stop-firing-until-cache-is-cleared-3093597-4.patch
patching file business_rules.drush.inc
patching file business_rules.services.yml
patching file src/EventSubscriber/BusinessRulesListener.php
patching file src/Events/BusinessRulesDrushEvent.php
lexsoft00’s picture

Status: Active » Needs review
Coops_’s picture

This is great, #4 working for me.

lexsoft00’s picture

Status: Needs review » Reviewed & tested by the community

  • colan committed 5c45357 on 8.x-1.x authored by lexsoft
    Issue #3093597 by lexsoft: Actions Intermitently stop firing until cache...
colan’s picture

Status: Reviewed & tested by the community » Fixed

Code looks great; thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.