Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
18 Feb 2009 at 03:50 UTC
Updated:
25 Mar 2009 at 13:03 UTC
Current standard appears to be (from discussion in IRC after seeing in code):
require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'MODULE') . '/somefile.php';
Seems to make more sense it drupal_get_path() returned a path with DRUPAL_ROOT already included.
require_once drupal_get_path('module', 'MODULE') . '/somefile.php';
Comments
Comment #1
boombatower commentedRan into following areas I am unsure about:
form.inc
locale.inc (first not only)
Stopped after that...perhaps we should use module_load_include() ?
Comment #2
dave reidYeah, module_load_include is a better choice in this situation since it automatically does the require_once for you as well.
Comment #3
boombatower commentedmodule_load_include() has the DRUPAL_ROOT already!
Comment #4
jdubbwya commentedThere is no need to define the drupal root because it should always be the current working directory and if for some reason you need to get that for php code use
but if you are trying to get the directory of a current file to do an include just use the following sample it will always retrieve the current directory of the file that is being executed
$dir =dirname( __FILE__ )Comment #5
boombatower commented#4: DRUPAL_ROOT already contains getcwd() and it seems to be the standard to place in front of all paths...although you are correct...I was not involved in that decision. I assume it was to allow the use of chdir().
Comment #6
gpk commented@5: it was to get round the issue in shutdown functions where PHP changes the cwd (to /, I think). #259623: Broken autoloader: convert includes/requires to use absolute paths