Problem Description
Previous to Drupal 7 (Drupal 5 and 6, at least), Drupal respected the use of symlinks.
Drupal 7 seems to break the use of symlinks with the creation of DRUPAL_ROOT
and the use of the realpath
php function to define it.
(The reason for the symlinks is to maintain more flexible version/type of Drupal multisite)
...
I did notice that a few of the files within the scripts
directory define DRUPAL_ROOT
with the php function getcwd()
. Is there a reason that getcwd()
isn't used in all the places DRUPAL_ROOT
is defined? A quick test seems to indicates that getcwd()
seems to respect the symlinks and allow DRUPAL_ROOT
to accurately reflect the root drupal directory.
Recreating the problem
* Put Drupal 7 core in a known directory: drupal-7.x
* Make a new directory somewhere else: mysite
* Within the mysite
directory, symlink Drupal's core files and directories (except the sites directory) from drupal-7.x
Behavior expected
Drupal should respect the symlinks and define DRUPAL_ROOT
as the directory mysite
... Just like it did in Drupal 5 and 6.
What Happens Instead
Drupal does not respect the symlinks and instead expands the symlinks and defines DRUPAL_ROOT
as the directory drupal-7.x
Comment | File | Size | Author |
---|---|---|---|
#14 | getcwd-symlink-test.php_.txt | 425 bytes | AmrMostafa |
#3 | 0001-stop-expanding-symlinks.patch | 1.58 KB | Anonymous (not verified) |
Comments
Comment #1
mikey_p CreditAttribution: mikey_p commentedsubscribing
Comment #2
Damien Tournoud CreditAttribution: Damien Tournoud commentedI'm not really sure I see the point of those symlinks... but I'm not opposed we use getcwd(). Please roll a patch!
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedThanks. I'm sure it might seem strange, but breaking symlink behavior is annoying.
Attempting to roll a patch...
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedChanging the status to 'patch (code needs review)' for automatic testing
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedThe patch has passed all tests at least 8 times now.
When might I expect this to be tested by others/commited to core?
I would love to start testing Drupal 7 and submitting/patching bugs, but the current expanding-symlinks behavior is a deal breaker thus far.
Comment #7
alexanderpas CreditAttribution: alexanderpas commentedin my opinion we should never break the usage of symlinks, as they might be used to create schemes we've never tought of!
#132988: Allow specifying a global directory for user pictures ($100 bounty for D5) also sprouted from the inability to use symlinks!
also, i tend to use symlinks in the sites directory for some cases.
Comment #8
Damien Tournoud CreditAttribution: Damien Tournoud commentedMakes total sense.
Don't listen nor trust the testbot.
Comment #9
webchickI grepped for "define('DRUPAL_ROOT" and see the following instances which are not part of this patch:
- /scripts/password-hash.sh
- /scripts/run-tests.sh
We should be consistent everywhere, no?
Comment #10
webchickOops. :D My mistake. :D Those already use getcwd(). Duh.
I want to make sure this comes back from testing bot clean, and then I'll commit it.
Comment #11
webchickCool. Test bot is happy, committed to HEAD. Thanks!
Comment #12
Anonymous (not verified) CreditAttribution: Anonymous commentedPerfect! Thanks for getting that into D7 core!
Comment #14
AmrMostafa CreditAttribution: AmrMostafa commentedAre you sure this is correct? According to my tests getcwd() dereferences symlinks. See: http://www.opengroup.org/onlinepubs/9699919799/functions/getcwd.html
Steps to verify this:
On my system I get:
Comment #15
thedavidmeister CreditAttribution: thedavidmeister commentedAny chance we can get #14 reworked into an actual test the bots can run?