Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-4542

bin/* scripts do not fire hooks

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 2.0
    • Fix Version/s: 3.2
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      For scripts in the bin directory Drupal (and I'm assuming the same for Joomla) does not get bootstrapped. This means that when a hook gets fired, there are no implementations of the hook to call (because no modules have been loaded).

      I got around this with this really dirty hack to the beginning of UpdateMembershipRecord.php . But there's got to be a better way, perhaps by reworking civicrm.config.php .

      // Boostrap Drupal
      $drupal_root = realpath($config->templateDir .'../../../../..');
      $current_working_directory = getcwd();
      ini_set('include_path', ini_get('include_path') .':'. $drupal_root);
      chdir($drupal_root);
      $drupal_base_url = parse_url($_SERVER['REQUEST_URI']);
      $_SERVER['PHP_SELF'] = '/index.php';
      $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'];
      $_SERVER['REMOTE_ADDR'] = NULL;
      $_SERVER['REQUEST_METHOD'] = NULL;

      require_once 'includes/bootstrap.inc';
      drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

      //require_once '../civicrm.config.php';
      include_once './'. conf_path() . '/civicrm.settings.php';
      chdir($current_working_directory);

      global $user;
      $name = trim($_REQUEST['name']);
      $user = user_load(array('name' => $name));

        Attachments

          Activity

            People

            • Assignee:
              rahulbile Rahul Bile
              Reporter:
              dalin dave hansen-lange
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: