In a symlink installation of Drupal, the file filemanager.config.php (which is to be included in the filemanager connector config.php) has an issue

Problem:
using relative paths to include files (../../../ etc) will result in the evaluation of the path by the operating system. This kind of evaluation results in the path being evaluated to the SOURCE directory and not the SYMLINKed directory. This results in the wrong bootstrap location (therefore the wrong settings.php and therefore the wrong database login and thus no function)

Solution:
first, we make the path absolute; we replace $drupal_path = "../../../"; with
$drupal_path = dirname(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME']))));
[ explanation:
../../../ from the current directory is the same as ../../../ from the directory where the script is running
is the same as ../../ from the directory above the directory where the script is running
and so forth.
]

then, we use the same technique to replace the other virtual parent directory calls
$drupal_path = "../.."; is one directory deeper than we had before, so we use the same line minus one dirname() call;
$drupal_path = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));

this line:$drupal_path .= "/.."; says: go to the parent directory, so we replace this with $drupal_path = dirname($drupal_path);

$depth counts the number of 'step-up's to parent directories.
We start with 3. If we can't find it there, we start with 2 and immediately walk up the ladder, so in fact we start again with 3 and incrementing every step up to a parent folder.

The included patch makes these changes and it has been tested on two independant servers, both with symlinked installations and with normal installations.

CommentFileSizeAuthor
fck2.patch820 bytesrmpel
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wwalc’s picture

Status: Needs review » Fixed

Thanks for the patch!
I have committed your code, I've changed only one thing: if the $_SERVER['SCRIPT_FILENAME'] variable isn't set, the old algorithm is executed.

rmpel’s picture

That should be a good fallback for non-Apache servers; afaik Apache servers always set this variable.

Better safe than sorry :)

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.