Overview

I get a fatal error when running features revert on a module with rules defined.

Error

<b>Fatal error</b>:  Unsupported operand types in <b>/.../sites/all/modules/contrib/rules/includes/rules.plugins.inc</b> on line <b>495</b><br />
Drush command terminated abnormally due to an unrecoverable error.                                                               [error]
Error: Unsupported operand types in
/.../sites/all/modules/contrib/rules/includes/rules.plugins.inc, line 495

(Possibly) Steps to reproduce

  1. Create a feature module with a rule
  2. Run "drush fr [module]"

Note that it's unclear if my features module has something special about it that is causing it to run into the error.

Fix

I'll add a patch but the fix is to initialize the array:

$export = array();
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Kristen Pol’s picture

Status: Active » Needs review
FileSize
815 bytes

Here's the patch.

Kristen Pol’s picture

Priority: Normal » Major

Since this is a fatal error, I think it should be bumped in priority.

dkane’s picture

Thank you Kristen! I was getting the same error and your patch solved my issue!

cuppensh’s picture

I get the same error in version 7.x-2.9. The patch from Kristen resolves the problem.

Arne Slabbinck’s picture

The patch #1 from Kristen solved the fatal error (Thanks!), but I still had warnings cause apparently my $export was empty. This happens when creating a feature.

Warning: reset() expects parameter 1 to be array, null given in RulesReactionRule->importChildren() (line 502 of rules.plugins.inc
Warning: array_keys() expects parameter 1 to be array, null given in RulesReactionRule->importChildren() (line 506 of rules.plugins.inc
Warning: array_filter() expects parameter 1 to be array, null given in RulesReactionRule->importChildren() (line 507 of rules.plugins.inc

(Using D 7.4 , PHP 5.5.46, Rules 7.x-2.9)

So adjusted the patch to check if $export has a value.

Daniel Wentsch’s picture

Thanks a lot, should be committed.

dandaman’s picture

I also found this fixed an issue with a Feature and Rules that was created years ago and it wouldn't let me view Feature status or recreate the Feature until I applied patch #5.

lathan’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
371.53 KB

This bug completely wrecked our site. To the point the point where we had massive amounts of dead locks happening, I assume because system clean up could not happen on cron.

Attached is screen shot of how this effected us.

The attached patch is live on our production site.
+1 RTBC

tanmayk’s picture

Patch in #5 works fine. +1 for RTBC.

AlfTheCat’s picture

Patch in #5 works, thanks!

fago’s picture

Status: Reviewed & tested by the community » Needs work

Is this still necessary? Also the patch has some coding style issues (whitespace after if missing)

ShaneOnABike’s picture

This is still happening to me when I attempt to export a schedule rules event.

TR’s picture

Version: 7.x-2.6 » 7.x-2.x-dev
Priority: Major » Normal
Status: Needs work » Needs review
FileSize
1.34 KB

I don't see anything disruptive in the proposed fix - this shouldn't affect any existing code. There's probably a better place to fix this issue, but there's no harm in adding a little defensive coding in Rules ...

Here's a new patch against the current HEAD, with the coding standards issues fixed. Can someone review this patch and confirm that it works to prevent the problem?

TR’s picture

Component: Rules Core » Features module integration
TR’s picture

Status: Needs review » Fixed

A virtually identical patch was committed in #2191425: Exceptions in Features UI if Rule lacks event configuration to solve a different issue. It should solve this one too.

Status: Fixed » Closed (fixed)

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

q11q11’s picture

Rerolled #13 against 7.x-2.12, same code, just with offsets.