I get the following notices when I attempt to run civicrm_cron:

Notice: Use of undefined constant CIVICRM_SITE_KEY - assumed 'CIVICRM_SITE_KEY' in civicrm_cron_admin_settings() (line 33 of civicrm_cron.module).

and

Notice: Undefined variable: status in civicrm_cron_admin_settings() (line 51 of civicrm_cron.module).

Comments

Patricia_W’s picture

I realize that the above was a warning which I got rid of by adding quotes.

But the problem is more serious ... and there are two issues:

1) I am using a multi-site configuration and the module assumes that the root is the domain name from which I am running it even though it is a different domain, I had to override the $conf variable in civicrm.config.php because otherwise cron that I am using the default directory. How do I get it to use the correct directory.

2) When I manually change the URL to use the correct domain name I get this error:

"Sorry, could not able to load drupal bootstrap."

It was this error that I originally got when I tried to invoke cron from URL.

Patricia_W’s picture

I hacked the code a bit to see what would happen if I used the correct domain name and then it failed on accessing $result->data. I changed that to $result->code and the code returned was -1002.

You may guess from all of this that I do not really know Drupal coding but I would like to get the module to work because without it working I am unable to mail CiviEvent reminders.

Patricia_W’s picture

I managed to remove the bootstrap error by removing a blank line at the end of Drupal.php (at least that is what I think caused it.) Still do not appear to have sent scheduled mail which is why I wanted to get cron to work.

Patricia_W’s picture

I was not correct when I said that I got rid of the bootstrap error. I still don't get an error in the drupal log but when I attempt to execute the cron via the URL I get the bootstrap error. From what I can determine so far the error is generated in Drupal.php when it executes the function module_exists ('civicrm')
There are hints that the module list does not get loaded with all of the modules (only "vital" modules) until later in the process. Not sure how this can be circumvented.

kreynen’s picture

Status: Active » Needs review

CIVICRM_SITE_KEY should be defined in your civicrm.settings.php file for each Drupal instance. It is only used to set the default variable in the /admin/config/civicrm/civicrm_cron form. Once the admin form is configured, the value you set is used. This is just to save people time in looking that value up.

The status variable was being set to show the results of attempting to run cron once the variables are set. I've reworked the way the admin form is processed to removed those notices and added the URL to the status.

http://drupal.org/commitlog/commit/40470/8b4b3b984d4aea413bd8178d8e44ded...

I am using drupal_get_path('module', 'civicrm') and then some clean up of the URL to get the path to CiviCRM's bin scripts. This should always return the correct path to the CiviCRM cron file regardless of whether the site is a multisite of not, but can result in a response from CiviCRM that is can't find it's configuration direction...

'CiviCRM Error: Could not find valid configuration dir, best guess: ...'

One way to solve this in earlier versions of CiviCRM is by adding a settings_location.php as described in the CiviCRM Multisite Configuration Documentation

<?php
// the following (/home/lobo/public_html/drupal/sites/)
// should be changed to your sites directory
define( 'CIVICRM_CONFDIR', '/home/lobo/public_html/drupal/sites/' );

It looks like the Multisite Configuration has changed in 4.2.

I'm not sure there is anyway this module can resolve this issue. If you go to the URL the module is trying to access (which is now displayed in any error) and get an error, civicrm_cron will also get that error. The error needs to be addressed in your CiviCRM configuration.

If there is something I can add to make the module work better for a multisite configuration, please open a new issue as a feature request.

kreynen’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

sonicthoughts’s picture

Version: 7.x-1.0-beta1 » 7.x-1.0-beta2

Same error in beta2

quiethero’s picture

Status: Closed (fixed) » Active

Hello Kreynan:

I am getting the same message from running CiviCron on CiviCRM 4.33:

Trying to get the mail settings to send mass mailings to my membership. I am using SMTP settings and all checks out as being correctly configured however, when I send the test mail its goes smoothly and correctly but sending the actual mailing simply goes to "Scheduled Mail" and is never sent. When I use Cron I get the following message:

Notice: Use of undefined constant CIVICRM_SITE_KEY - assumed 'CIVICRM_SITE_KEY' in civicrm_cron_cron() (line 105 of /home/mysite/public_html/sites/all/modules/civicrm_cron/civicrm_cron.module).

Line 105: $cron_values['key'] = variable_get('civicrm_cron_sitekey', CIVICRM_SITE_KEY);

I have checked the sitekey and it is correct. Also, I will soon be configuring the multi-site elements with 4 sites as soon as I get past these problems.

Also, on each FRESH install of Drupal 7.22 and CiviCRM 4.33 (all modules up-to-date), I get the following 3 errors without any import of files, contacts, etc. or adjustments made to the servers, databases or anything else: (I am using a vps on Apache with the latest php installed)

Notice: Undefined offset: 0 in /home/mysite/public_html/includes/errors.inc on line 271

$call = $backtrace[0];

Notice: Undefined index: file in /home/mysite/public_html/includes/errors.inc on line 72

'%file' => $caller['file'],

Notice: Undefined index: line in /home/mysite/public_html/includes/errors.inc on line 73

'%line' => $caller['line'],

I have been searching for days and found your explanation(s) on multi-site configuration to be the most applicable however, because I am not yet an expert I am uncertain what changes you made or what or how?

NOTE: I am not yet using Multi-Site and am eager to get started.

Please advise...

kreynen’s picture

Does CiviCRM's cron run when you go to http:///sites/all/modules/civicrm/bin/cron.php?name=&pass=
&key=

As I've explained before (#5), the CIVICRM_SITE_KEY constant is normally set in the civicrm_settings.php and available to the civicrm_cron module. If you are getting an error that the CIVICRM_SITE_KEY is not set for that Drupal environment, it seems unlikely that CiviCRM's cron will ever run.

This module is not the only or even recommended way to run CiviCRM's cron. It's a shortcut or workaround for people who either can't add an additional cron process because of the environment they work in or don't want to take the time.

I'm willing to review patches to make this work in a mutlisite environment for free or do the work required to make this work with a multisite environment if someone is willing to pay for it, but this is not an itch I need to scratch. If this module doesn't work in your environment, configure CiviCRM's using the documentation found at http://wiki.civicrm.org/confluence/display/CRMDOC43/Running+Command-line...

quiethero’s picture

Assigned: Unassigned » quiethero
Status: Active » Fixed
kreynen’s picture

Assigned: quiethero » Unassigned
Status: Fixed » Closed (works as designed)

That is a patch for civicrm, not Civicrm_cron. I you really want to see this fixed, submit the patch to http://issues.civicrm.org/jira/browse/CRM

kreynen’s picture

That is a patch for civicrm, not Civicrm_cron. I you really want to see this fixed, submit the patch to http://issues.civicrm.org/jira/browse/CRM

kreynen’s picture

That is a patch for civicrm, not Civicrm_cron. I you really want to see this fixed, submit the patch to http://issues.civicrm.org/jira/browse/CRM

kreynen’s picture

That is a patch for civicrm, not Civicrm_cron. I you really want to see this fixed, submit the patch to http://issues.civicrm.org/jira/browse/CRM

kreynen’s picture

WTF drupal? Mobile posting fail.

kreynen’s picture

The 2.x branch has been restructured so only the site key is needed. The form has been updated so that notices about the CIVICRM_SITE_KEY constant shouldn't happen. Please test.