Since upgraded to Rules 7.x-2.1+2-dev (2012-Apr-02), I constantly got PHP warnings like following

Warning: array_diff_key() [function.array-diff-key]: Argument #1 is not an array in RulesEventSet::rebuildEventCache() (line 750 of sites/all/modules/rules/includes/rules.plugins.inc).
Warning: array_keys() [function.array-keys]: The first argument should be an array in RulesEventSet::rebuildEventCache() (line 750 of sites/all/modules/rules/includes/rules.plugins.inc).
Warning: array_flip() [function.array-flip]: The argument should be an array in RulesEventSet::rebuildEventCache() (line 751 of sites/all/modules/rules/includes/rules.plugins.inc).

This module is used by module Entity tokens and Entity API on my sites.

The first argument is $events, which is initialized by calling "$events = rules_fetch_data('event_info');". What I'm thinking is, in case variable $events is initialized with a NULL value (or a non-array value that indicates there no data for it), and there is no rules set up, function call "array_diff_key($events, $sets)" on line 750 won't work. I don't know much about this module, so this is just my guess.

Anyway, since the bug annoy me a lot, I'm going to downgrade to 7.x-2.1.

Thanks

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ridgek’s picture

I have the same issue on 7.x-2.1? Interestingly, this didn't appear until after I migrated my Drupal install to a new server (which has an identical configuration).

pixelsweatshop’s picture

Just had the similar situation to ridgekuhn. Moved servers, started throwing errors.

Flushing cache once cleared it up.

ridgek’s picture

Sorry, forgot to update! The errors went away for me, I believe flushing the cache as nicoz recommends is what did the trick, but it's been a few days.

pixelsweatshop’s picture

Status: Active » Fixed

Going to close. Reopen if issue persists.

deminy’s picture

Component: Rules Engine » Rules Core
Status: Fixed » Active

Well, I don't think you should close this issue out. I flush caches pretty often and I know the issue could gone for a while once cache was flushed; however, the same issue happens again later on.

Flushing cache could be just a temporary solution, but we can't just sit in front of our PCs and click the 'clear cache' from time to time.

Set ticket status to active.

pixelsweatshop’s picture

Since clearing cache, the issue has not returned for me. If it still doesn't work for you, then, as per my previous post. Reopen it. I don't need the lecture. thanks.

Tribal’s picture

We had also been experiencing this problem.

We discovered that if the Rules cache was empty we were unable to clear the cache. We had the following error:
Error: Class 'RulesEventSet' not found in sites/all/modules/contrib/rules/rules.module, line 257

After commenting out this line clearing the cache was successful.

We then tested clearing the cache with this line uncommented again and it was successful, suggesting that after the rules cache had been "filled" we were able to clear the caches.

Clearing the cache isn't fixing this issue, just hiding it.

specky_rum’s picture

Have just seen the error mentioned in #7 from a fresh D7.14 install. I installed a whole load of modules all at the same time and got that error and wasn't able to recover from it. Commenting the offending line just moved the error to further down the code.

I have since followed exactly the same procedure again and had no problem however. Perhaps not much help but I wonder if it may be to do with the order in which the modules are enabled? The complete list of modules enabled was as follows:

Administration menu, Administration menu Toolbar style, CCK, Field UI, Field, Field SQL storage, Chaos tools, Custom content panes, Date, Date API, Date All Day, Date Popup, Date Repeat API, Date Repeat Field, Date Validation, Date Views, Views, Display suite, Extras, Forms, Entity API, Entity tokens, Features, Field Validation, Libraries, Module filter, Page manager, Panels, Panels In-Place Editor, Mini panels, Panel nodes, Pathauto, Path, Token, Rules, Rules UI, Rules Scheduler, Search API, Views Bulk Operations, Views content panes, Views UI

hefox’s picture

hefox’s picture

Status: Active » Needs review
FileSize
441 bytes

rules_watchdog is what causing the error. Considering how watchdog can be called very early due to errors, it seems reasonable it's been called before the file RulesEventSet is in has been added, and better to just skip rebuilding cache than causing this error imo.

raghu125coorg’s picture

fago’s picture

rules_watchdog is what causing the error. Considering how watchdog can be called very early due to errors, it seems reasonable it's been called before the file RulesEventSet is in has been added, and better to just skip rebuilding cache than causing this error imo.

Sounds reasonable, but the hunk right now makes that very difficult to see. Can we detect this in hook_watchdog instead and bail out if rules is not fully loaded yet?

SocialNicheGuru’s picture

patch no longer applies

strawman’s picture

Issue summary: View changes

Well it still applies apparently as I just had to use it on my fresh install for Rules 2.7
So thank you for the patch :)

davidrobinson_pw’s picture

I've rerolled Hefox's Patch against the current state of the 7.x-2.x branch

I've also added a version which applies against the 7.x-2.7 release.

jerry’s picture

The patch for 2.7 resolved this problem for me, which appeared when I installed the References Integrity sandbox module.

sfyn’s picture

Status: Needs review » Reviewed & tested by the community

I am now running this patch on our production site with rules 2.7

Flagging rtbc

klausi’s picture

Status: Reviewed & tested by the community » Needs work

Looks like fago's comment has not been addressed from #12.

TheBarnacle’s picture

Are there any plans to add this patch to the main branch? The current dev branch doesn't seem to have it.

Michael-IDA’s picture

2015, still coming up :(

Warning: Illegal offset type in isset or empty in RulesEventSet::rebuildEventCache() (line 716 of sites/all/modules/rules/includes/rules.plugins.inc).

Rules (rules) Module Enabled 7.x-2.3

:Edit 01:

Maybe it's significantly worse now . ? . ? .

Went to the Rules config page (/admin/config/workflow/rules) and got this:

Warning: Illegal offset type in RulesReactionRule->dependencies() (line 410 of sites/all/modules/rules/includes/rules.plugins.inc).
Warning: Illegal offset type in RulesReactionRule->dependencies() (line 410 of sites/all/modules/rules/includes/rules.plugins.inc).
Notice: Array to string conversion in format_string() (line 1550 of includes/bootstrap.inc).
Warning: Illegal offset type in RulesUIController->overviewTableRow() (line 260 of sites/all/modules/rules/ui/ui.controller.inc).
Warning: Illegal offset type in RulesUIController->overviewTableRow() (line 261 of sites/all/modules/rules/ui/ui.controller.inc).

:Edit 02:

Seems caused by Commerce License Billing, https://www.drupal.org/node/2631008

But should rules crash and burn because of bad data being passed to it?

stranger27’s picture

Solution #15 works! Thanks!

Michael-IDA’s picture

#15 doesn't address #12.

Does suck that this bug has been open 4 years.

Pimmy’s picture

#15 worked for 7.x-2.9, although the line numbers were different.

ckng’s picture

Status: Needs work » Needs review
FileSize
501 bytes

Reroll #15 for dev.

TR’s picture

Status: Needs review » Needs work

@fago's concern from #12 has still not been addressed.

MiroslavBanov’s picture

Patch number #25 doesn't fix the problem for me. I also agree with #12 and #26, and seem to have the same problem.