If you run drupal from command line (p.e. cron.php) $base_path is not set to it's default value "/" in conf_init(), because dirname() always returns a value that's interpreted as TRUE.

If $_SERVER['SCRIPT_NAME'] doesn't contain a directory the return value of dirname($_SERVER['SCRIPT_NAME']) is ".". So in the current implementation $base_path is set to "/./" instead of "/" if you run cron.php. I attached a patch that solves the issue.

CommentFileSizeAuthor
bootstrap_5_7.patch533 bytesmkalkbrenner

Comments

cmsproducer’s picture

Status: Needs review » Reviewed & tested by the community

I have tested the code on 5.7x and it generates an IF error even if the syntax structure is verified to be correct.
Parse error: syntax error, unexpected T_IF in /home/xxxxxxxxxxx/public_html/_ngreens/includes/bootstrap.inc on line 266

mkalkbrenner’s picture

We are running drupal 5.7 on our linux servers with bootstrap_5_7.patch applied without any errors.

drumm’s picture

Status: Reviewed & tested by the community » Closed (works as designed)

cron.php is not actually designed to be run from the command line.

In Drupal 6 and above, there is scripts/drupal.sh which does make this possible and handles $base_path in all situations, including sites installed subdirectories. drupal.sh does work the same on Drupal 5.x.

murz’s picture

Many hostings runs cron task from command line and have no permission to change method to http.
And Drupal in this state can't get $_SERVER['HTTP_HOST'] value and other.
For setting correct $base_url I do this changes:

      $base_url = $base_root .= '://'. preg_replace('/[^a-z0-9-:._]/i', '', $_SERVER['HTTP_HOST']);

change to:

    if($_SERVER['HTTP_HOST'])
      $base_url = $base_root .= '://'. preg_replace('/[^a-z0-9-:._]/i', '', $_SERVER['HTTP_HOST']);
    else {
      global $cookie_domain;
      $base_url = $base_root .= '://'. $cookie_domain;
    }