On some environments $_SERVER['DOCUMEN_ROOT'] can contain rubbish which has nothing to do with where Drupal is installed. For example, Apache with mod_vhost.
Some modules (eg: search_files) want a full system path for file operations they need to perform and currently use $_SERVER['DOCUMENT_ROOT']. However, this can fail.
Rather than solve this in each module that needs an absolute path reference, it would be good if Drupal contained an API call that reliably returns the actual document root for the current Drupal instance.
The attached patch does just that. It obtains the full path to system.module via __FILE__ and essentially subtracts the value of drupal_get_path() for the system module (and the trailing slash), making it available for all modules via the system_path() call, similar to base_path().
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 515358-system-path.patch | 886 bytes | cafuego |
| system-path.patch | 885 bytes | cafuego |
Comments
Comment #2
cafuego commentedFixed missing semicolon (d'oh).
Comment #3
rsaddington commentedPatch works fine for me.
Comment #5
cafuego commentedgetcwd() for the win