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) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Alpha and Beta Release Testing »
  • 4.2 Release Testing »
  • Batch script is failing
Pages: [1]

Author Topic: Batch script is failing  (Read 2146 times)

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Batch script is failing
June 30, 2012, 08:05:34 pm
I am getting the following error message when running a batch script:

Fatal error: Class 'CRM_Core_Config_Variables' not found in /home/dev9/public_html/sites/all/modules/civicrm/CRM/Core/Config.php on line 43

The code in my batch script just above the issue:
Code: [Select]
global $civicrm_root;

    $civicrm_root = $client_home_dir.'/public_html/sites/all/modules/civicrm/';


       $tmp_config = $civicrm_root.'civicrm.config.php';
        require_once $tmp_config;
       
        require_once 'CRM/Core/Config.php';
        $config =& CRM_Core_Config::singleton();
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

robinhood

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 6
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.1.56
  • PHP version: 5.3.5
Re: Batch script is failing
July 12, 2012, 06:29:14 pm
Yeah, me too.  I am finding that 4.2 has had several require_once() calls removed, and my scripts fail when tested against this code, whereas they work with 4.1.

For example this particular error you hit seems to be related to these lines which have gone missing from the top of CRM/Core/Config.php.
Code: [Select]
require_once 'CRM/Core/DAO.php';
require_once 'CRM/Utils/System.php';
require_once 'CRM/Utils/File.php';
require_once 'CRM/Core/Session.php';
require_once 'CRM/Core/Config/Variables.php';
Once these lines are restored, the script continues but fails again in another place where a require_once() call is missing.  I did not follow the rabbit trail all the way to the end, but maybe this will be enough of a clue for someone to figure out what is happening. 

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Batch script is failing
July 12, 2012, 08:29:53 pm

4.2 now uses a class loader and hence does not have the require_once calls. You'll need to add code like:

Code: [Select]
  require_once dirname(__FILE__) . '/../CRM/Core/ClassLoader.php';
  $classLoader = new CRM_Core_ClassLoader();
  $classLoader->register();

to initialize the class loader.

We'll think about how we can generalize this and include it as part of the config script for a future release

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

robinhood

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 6
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.1.56
  • PHP version: 5.3.5
Re: Batch script is failing
July 13, 2012, 04:16:08 am
Ah, that explains it.  Would that code go after the standard
Code: [Select]
$config = CRM_Core_Config::singleton();?

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Batch script is failing
July 16, 2012, 03:57:59 pm
Just as a quick follow-up, this is being worked on at http://issues.civicrm.org/jira/browse/CRM-10532

Note that the convention described in lobo's post works for 4.2 alpha1 through beta1, but it will break in the next release (beta2?). For running scripts in the next release, one should omit the ClassLoader statement entirely (just like you did in previous versions).

If you encounter some oddball situation which really requires loading the class-loader explicitly in 4.2.beta2+, then use:

Code: [Select]
require_once '/path/to/CRM/Core/ClassLoader.php';
CRM_Core_ClassLoader::singleton()->register();

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Alpha and Beta Release Testing »
  • 4.2 Release Testing »
  • Batch script is failing

This forum was archived on 2017-11-26.