Better Multisite Directories

arnabdotorg - January 23, 2006 - 00:20
Project:Drupal
Version:7.x-dev
Component:base system
Category:feature request
Priority:normal
Assigned:arnabdotorg
Status:needs work
Description

The current system:

The current algorithm for looking for settings.php in the "sites" directory is:

1. Given a PATH(/path/to/file), and SERVERNAME(www.example.com:port)
2. Check SERVERNAME.PATH, replacing / with .
3. At every iteration, drop last part of PATH, and first part of SERVERNAME

So we have

port.www.example.com.path.to.file
www.example.com.path.to.file
example.com.path.to.file
com.path.to.file

("file" is removed)

port.www.example.com.path.to
www.example.com.path.to
example.com.path.to
com.path.to

("to" is removed)

port.www.example.com.path
www.example.com.path
example.com.path
com.path

("path" is removed)

port.www.example.com
www.example.com
example.com
com

While this heuristic is fairly usable, it has the following

Problems:

1. Loss of granularity: By dropping the rightmost elements, we lose the most important part of the information. For example, filesystem paths on large multiuser systems might be of the form /bighome/user/a/arnab/. Now there is no way to specify subdirectories unless we specify the WHOLE .bighome.user.a.arnab part. This can get very long and redundant with a large number of users. There's no way we can just use arnab or something as small as the directory name.

2. Clean URLs: I've encountered some servers, where using clean URLs produces a $_SERVER['PHP_SELF'] as /bighome/user/a/arnab/drupalA. However, when we use the ?q= methods to access these pages, this $_SERVER['PHP_SELF'] now becomes ~arnab/drupalA. Say I wanted to have two websites ~arnab/drupalA and ~arnab/drupalB, the current config_init does not let me do this, because I cannot set up an accessible directory pair like "drupalA" and "drupalB". I'll have to do "~arnab.drupalA" and "~arnab.drupalB". Now recall that during clean urls, this is "bighome.user.a.arnab.drupalA" instead! This makes it impossible to have consistency.

What this patch does:

Changes the logic so that the new algo is:

1. Given a PATH(/path/to/file), and SERVERNAME(www.example.com:port)
2. Check SERVERNAME.PATH, replacing / with .
3. At every iteration, first part of PATH, and first part of SERVERNAME

So we have

port.www.example.com.path.to.file
www.example.com.path.to.file
example.com.path.to.file
com.path.to.file

("path" is removed)

port.www.example.com.to.file
www.example.com.to.file
example.com.to.file
com.to.file

("to" is removed)

port.www.example.com.file
www.example.com.file
example.com.file
com.file


("file" is removed)

port.www.example.com
www.example.com
example.com
com

Problems with this patch:

1. This will break the current convention of moving "up" the filesystem path. However, the reason behind breaking this convention is because:
a) I don't see how multisite users can take advantage of this (would appreciate counter examples!)
b) code is more elegant without backward support logic

Advantages with this patch:

1. There are fewer array_implodes, array_pop & string concatenation is used to save redundant implode calls. This makes bootstrapping faster.
2. The ordering of the search is made so that the simpler (smaller) directory names are searched first. This is more intuitive, imho.
3. By changing the separator from "." to "/", and using a simple symlink like "com/bighome" -> "/bighome", we can allow each user to set up a settings.php in their homedir, giving them a drupal site automatically. This is not possible with the current set up, since there will be extra words in the path that would need to be removed inefficiently.
4. Many filesystems have a limit to the number of files in a directory. This allows us to have a more flexible directory / settings.php structure (assuming you use "/").

AttachmentSize
bootstrap.config.init.patch1.13 KB

#1

drewish - January 23, 2006 - 00:50

+1, that seems pretty logical to me. I wasn't a fan of the exsiting method though.

#2

chx - January 23, 2006 - 00:58

Indeed there is some saving. For more savings, do a $n = count($server) outside of the loops.

As for the change, I am neutral. jhriggs? adrian? you two have written the original, what say you?

#3

arnabdotorg - January 24, 2006 - 03:48
Priority:normal» critical

#4

arnabdotorg - January 25, 2006 - 01:41
Category:feature request» bug report

#5

moshe weitzman - January 25, 2006 - 04:15
Category:bug report» feature request
Priority:critical» normal

#6

Jaza - January 18, 2007 - 05:37
Version:x.y.z» 6.x-dev
Status:needs review» needs work

#7

catch - November 6, 2007 - 10:47
Version:6.x-dev» 7.x-dev

#8

roychri - June 18, 2008 - 01:11
Status:needs work» needs review

I changed it as per comment #2 (chx)

AttachmentSize
45938.patch 1.35 KB
Testbed results
45938.patchfailedFailed: Failed to apply patch. Detailed results

#9

Crell - June 18, 2008 - 02:13

#10

Anonymous (not verified) - November 11, 2008 - 08:05
Status:needs review» needs work

The last submitted patch failed testing.

 
 

Drupal is a registered trademark of Dries Buytaert.