CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Enabling any Extension stops cli.php job invoking Hooks
Pages: [1]

Author Topic: Enabling any Extension stops cli.php job invoking Hooks  (Read 1496 times)

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Enabling any Extension stops cli.php job invoking Hooks
October 31, 2012, 11:14:32 pm
UPDATE: see Reply #2 for an analysis of this serious problem

I'm using the CiviMobile extension and a Drupal module that implements the CiviCRM alterMailParams() hook. I use cli.php to invoke the Scheduled Mailing job. I'm using CiviCRM 4.2.2.

Normally, when I send a CivMail mailing, the alterMailParams() hook gets called, as one would expect.

If I enable CiviMobile, the hook is not invoked. The problem only occurs for cli.php: it all works as expected when I run the Scheduled Mailing job from within CiviCRM's administrator menu.

This suggests some interplay between cli.php, the Extension mechanism, and the Hook mechanism. (CiviMobile and my module are both simple implementations, so I doubt the issue is there.)

As I dig into this, does anyone know of similar issues?

Thanks!

Ken
« Last Edit: November 03, 2012, 12:07:28 am by ken »

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Extension stops cli.php job invoking a hook
November 02, 2012, 07:44:55 pm
I get the same behaviour when I enable/disable the Optimized Autocomplete extension, which suggests it is a general issue rather than extension-specific.

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Enabling any Extension stops cli.php job invoking Hooks
November 03, 2012, 12:52:55 am
Enabling any Extension will stop cli.php from invoking any CiviCRM Hooks implemented by modules. If no Extensions are enabled, Hooks are invoked correctly.

This happens since cli.php runs CiviCRM code before the CMS is bootstrapped.

Thus, civicrm_cli::_bootstrap() makes the following calls ...
  • CRM_Core_Config::singleton()
  • CRM_Utils_System::loadBootstrap()

The first call invokes the Config hook. The second call bootstraps the CMS. The problem is that the Config hook assumes the CMS has already been bootstrapped ...
  • The Config hook calls CRM_Utils_Hook_Drupal::invoke() (I assume the hooks in other CMS's behave similarly)
  • The logic of invoke() is: if this is the first call to invoke(), or if the list of all modules is empty, build a list of modules from the CMS and from the CiviCRM extensions
  • Since the CMS has not yet bootstrapped, the list is built , but only contains the enabled CiviCRM extensions
  • This means that subsequent hook calls will only look for hook implementations among the extensions and not the CMS modules

If no Extensions are enabled, the problem is masked, because the next call to invoke() will find the module list empty, and it will build the list of modules including the CMS modules.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Enabling any Extension stops cli.php job invoking Hooks
November 03, 2012, 01:16:15 am
Hi ken good hunting

This is this issue:
http://issues.civicrm.org/jira/browse/CRM-11212

That was spotted by colby too:
http://forum.civicrm.org/index.php/topic,26540.msg113192.html
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Enabling any Extension stops cli.php job invoking Hooks
November 03, 2012, 02:23:04 am
Cool. I don't need to write a patch now.

Is this going to be an issue for the other CMS's? A cursory glance suggets Joomla and WordPress are fine, but Drupal6 will need the same fix.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Enabling any Extension stops cli.php job invoking Hooks

This forum was archived on 2017-11-26.