I get a fatal error when installing rules via drush

-sh-4.1$ drush dl rules
Project rules (7.x-2.6) downloaded to sites/all/modules/rules.       [success]
Project rules contains 4 modules: rules_admin, rules_i18n, rules_scheduler, rules.
-sh-4.1$ drush en rules
The following extensions will be enabled: rules
Do you really want to continue? (y/n): y
PHP Fatal error:  Call to undefined function rules_invoke_event() in /home/.../public_html/sites/all/modules/rules/modules/events.inc on line 180
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: Call to undefined function rules_invoke_event() in
/home/.../public_html/sites/all/modules/rules/modules/events.inc,
line 180


All the site is broken when I try to access it, and I see such errors in the log

[Sat Dec 28 20:04:42 2013] [warn] [client 91.120.170.116] mod_fcgid: stderr: PHP Notice:  Undefined index: event_info in /home/.../public_html/sites/all/modules/rules/rules.module on line 227
[Sat Dec 28 20:04:42 2013] [warn] [client 91.120.170.116] mod_fcgid: stderr: PHP Fatal error:  Unsupported operand types in /home/.../public_html/sites/all/modules/rules/rules.module on line 227
L
CommentFileSizeAuthor
#6 rules--call_to_undefined-2163971-6.patch412 bytespescetti
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

giorgio79’s picture

Project: Ubercart » Rules
Version: 7.x-3.6 » 7.x-2.6
Component: Code » Rules Core

Right project...

aangel’s picture

I too am getting this error. Going to try 2.5.

aangel’s picture

2.5 worked for me atop a Panopoly + Kalatheme distribution.

Ronino’s picture

Version: 7.x-2.6 » 7.x-2.7

I can confirm this for rules-7.x-2.7, but it only happens when trying to enable the module with drush. It works without any errors when enabling it via the modules page or with module_enable() in an update hook which can be triggered with drush updb.

giorgio79’s picture

Ah, I did use drush as well...

pescetti’s picture

Status: Active » Needs review
FileSize
412 bytes

Issue is due to Rules implementing hook_watchdog and Drupal (when the module is enabled via Drush) invoking that hook, and Rules' implementation of it, before the module is actually fully enabled and the functions defined in rules.module are actually visible.

This happens when Drupal tries to write "Rules module installed" and "Rules module enabled" into watchdog.

The attached patch works around the problem by calling rules_invoke_event() only when the function is actually visible. It is a minimal workaround with no effects on the ordinary module operations.

JeremyFrench’s picture

This patch looks ok and resolves the issue for me.

JeremyFrench’s picture

Status: Needs review » Reviewed & tested by the community
fago’s picture

Version: 7.x-2.7 » 7.x-2.x-dev
Status: Reviewed & tested by the community » Needs work

I do not see how it can happen that events.inc is included, but the module file not. If so, that's maybe some misbehaviour of drush?

I also tested it with the recent dev version and drush 6.4 and was not able to reproduce it.

However, there seems to be some general issues related firing Rules events too early - see #2324587: Rules might be triggered too early in the bootstrap. So let's make that more bullet-proof over there, which should help with problems like that also. I leave the issue open for now, in case more people run into it. If so, please try to reproduce it with the latest dev version.

TR’s picture

Status: Needs work » Closed (outdated)

As @fago said in #9, it's unclear why this would happen in events.inc and not in rules.module (rules.module gets loaded first, after all..). There have been no reports of this problem re-occurring in the past 4 years, so it's likely it no longer happens in the current versions of Rules and drupal.

Again, as @fago said, let's work on the more basic issue over in #2163971: Call to undefined function rules_invoke_event() in on line 180 and Unsupported operand types inrules.module on line 227

If this problem still happens, please open a NEW issue with current information and details for how to reproduce the error.