Download & Extend

impossible to set $base_path to it's default value

Project:Drupal core
Version:5.7
Component:base system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (works as designed)

Issue Summary

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.

AttachmentSizeStatusTest resultOperations
bootstrap_5_7.patch533 bytesIgnored: Check issue status.NoneNone

Comments

#1

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

#2

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

#3

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.

#4

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:

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

change to:
<?php
   
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;
    }
?>