Some of our custom code is using $_SERVER['DOCUMENT_ROOT'] to figure out where the drupal base directory is at; and I've seen it commented around drupal.org as a way of doing that.

When using drush, i quickly ran into problems whenever some of that code needed to be used, because DOCUMENT_ROOT is empty when using the cli.

Using $_SERVER['PWD'], drush could set $_SERVER['DOCUMENT_ROOT'] to emulate this behaviour.

Comments

jonhattan’s picture

I think what you need is one of those:

drush_get_context('DRUSH_DRUPAL_ROOT');
drush_get_context('DRUSH_DRUPAL_SITE_ROOT');
Carl Johan’s picture

Status: Active » Closed (fixed)

Thanks, works better now!

mikeytown2’s picture

Version: All-Versions-2.0 » All-versions-4.1
Component: Code » PM (dl, en, up ...)
Status: Closed (fixed) » Active

Would like to reopen this. imageapi's imagemagick's _imageapi_imagemagick_convert_exec uses $_SERVER['DOCUMENT_ROOT']. This is a problem with this patch for imagecache.
http://drupal.org/node/587086#comment-3777818

I've modified the above patch to not do an http request.
http://drupal.org/node/587086#comment-4013532

Sorta side stepped the issue here, but would like a better solution to the problem.

moshe weitzman’s picture

Status: Active » Closed (won't fix)

Any module or theme file in Drupal can figure out its path below root with drupal_get_path('module', 'imageapi'); imageapi needs a patch.