Remove symlink creation. Let each path have own file

danielnolde - September 10, 2007 - 10:28
Project:Boost
Version:5.x-1.x-dev
Component:Platform support
Category:feature request
Priority:normal
Assigned:danielnolde
Status:patch (reviewed & tested by the community)
Description

Windows Servers are not supported yet by BOOST since it uses SymLinks (which do not exist for Windows) to deal with URL Aliases, as is documented in the readme.txt.

A possible "fix" for this could be to give the admin the choice to let boost write cached content for pages with url aliases too (i.e.: a choice to write the cached content to disk instead a symlink to the normal-path page content). This *could* mean higher data volume on the disk but should be a simple way to let users of windows servers also get the goods of this amazing module.

#1

danielnolde - September 11, 2007 - 13:33

What would be the best point to attack this, i.e. to store cached content files on the disk instead of symlinks for windows servers?
Changing the function _boost_symlink in boost.helpers.inc?
Or would each symlink-related code in the boost.module itself to be altered to accomplish this?

If i get a hint, i could try this fix to make boost available to windows server, too!

#2

danielnolde - September 11, 2007 - 13:33
Status:active» active (needs more info)

status: need more info

#3

Arto - September 12, 2007 - 11:56
Title:Possible Fix for Windows-Servers» Windows compatibility

Yes, a setting for whether to use symlinks, or not, does sound pretty all right in principle. The problem, however, is that Boost presently really relies on the presence of symlinks, and adding non-trivial special cases at a good number of places in the code is akin to obfuscation.

I think it would be preferable that your patch would try to abstract out the OS-specific parts somehow; for instance, you could first look through the code to find out which functions rely on symlinks, and then separate those bits out from boost.api.inc into, say, boost.unix.inc and boost.windows.inc, or something like that. Then we could make do even without an explicit setting, just checking the current operating system in order to see which file we should load into boost.api.inc.

If you do proceed on this front, please make sure to adhere to the existing coding conventions in the code, and submit your results here in the form of a patch. Also, please be aware that I don't myself have any Windows machines available for testing, so in practice you yourself would need to support and further develop the Windows bits as necessary; if you're willing to do that, I would make you a co-maintainer of the Boost project here on drupal.org so that you can take ownership of any Windows-specific issues and such.

#4

danielnolde - September 12, 2007 - 14:49

Hey Arto,

sounds reasonable and good.
I could do the code changes and provide a patch, and even maintain the windows parts.
However, i don't know the guts of BOOST very well right now, so a little hint to the spots of the code that are os-/symlink-dependent would be great!

As far as i can see, the following places in the code would have to be altered - is any other part of the code symlink-dependent?
(based on 5.x-1.x-dev from 2007-Aug-07)

~line 94:
$symlink = boost_file_path($alias);
if (is_link($symlink))
@unlink($symlink);

~line 142
// If a URL alias is defined, create that as a symlink to the actual file
if ($alias != $path) {
$symlink = boost_file_path($alias);
_boost_mkdir_p(dirname($symlink));
if (!is_link($symlink) || realpath(readlink($symlink)) != realpath($filename)) {
if (file_exists($symlink))
@unlink($symlink);
if (!_boost_symlink($filename, $symlink)) {
watchdog('boost', t('Unable to create symlink: %link to %target', array('%link' => $symlink, '%target' => $filename)), WATCHDOG_WARNING);
}
}
}

Can you explain in a few words to me what the second code fragment does, and what to keep in mind when chaning it to a windows-version?

Then i could extract the os-specific parts of the code into a boost.OS_NAME.inc file that would be automatically included for the running os, just as you suggested.

#5

danielnolde - September 12, 2007 - 16:54
Component:Miscellaneous» Code
Assigned to:Anonymous» danielnolde
Status:active (needs more info)» patch (code needs review)

Hey Arto,

windows support via os-dependent inc-files for BOOST is done (using file-copies instead symlinks in the windows version, tested on windows).
Find attached a zip with the patches and the new additional os-dependent inc-files - oh, and remove the ".txt" extension, since i added it just to be able to upload the file.

hope to hear from you,

daniel

AttachmentSize
boost.windows.patch.zip_.txt2.89 KB

#6

danielnolde - September 21, 2007 - 13:36
Status:patch (code needs review)» patch (reviewed & tested by the community)

Hey Arto, any news on integration of the windows-compatibility feature for Boost??

#7

Arto - September 21, 2007 - 13:47

Hi Daniel,

Currently at DrupalCon, but will try and review your patch next week when I get back home.

#8

moshe weitzman - September 27, 2007 - 13:10

windows does actually support symlinks but only for directories - not files. so one option would be for boost to produce many directories all with a single index.html inside. this is a bit less clean than the current solution but straightforward windows compatibility using same code is very nice.

we would make a wrapper around the symlink() function in php so it shells out to the 'junction' program in windows which created symlinks. see _symlink() in the comments at http://us.php.net/symlink for an example wrapper. the junction program for windows is available for free at http://www.microsoft.com/technet/sysinternals/FileAndDisk/Junction.mspx

#9

Arto - September 30, 2007 - 18:36

Moshe, that's a very interesting idea. I'd love a patch that worked the way you describe.

#10

Arto - September 30, 2007 - 18:43
Component:Code» Platform support

#11

Hetta - October 5, 2007 - 10:04

Hmmm. Caching to alias-named files instead of using symlinks would take care of the "too many files in your /node/ directory, you're killing our server" problem, here: http://drupal.org/node/171444

I think it's more elegant (it removes one level of complication), but it's possible that I think so because I'd need to get around the 171444 problem, too; I have 30+k nodes.

#12

moshe weitzman - October 11, 2007 - 16:47
Status:patch (reviewed & tested by the community)» patch (code needs work)

From bjaspan:

It seems to me that the symlink code is unnecessary complexity on Unix and extra logic to work around not having symlinks on Windows is even more unnecessary complexity. Just write the HTML out to whatever path was requested! So we end up with two copies of some pages if people go out of their way to access node/nid. So what? Disk is cheap.

I agree so I set this issue to 'needs work'. Feedback welcome.

#13

moshe weitzman - November 30, 2007 - 03:39
Title:Windows compatibility» Remove symlink creation. Let each path have own file

This fixes Windows compatibility so thats why we keep discussion in this issue.

Note that globalredirect.module is useful for assuring that noone goes to node/nid URL. I see little value in the symlinks considering how popular that module is.

#14

bjaspan - December 18, 2007 - 21:34

Here is my patch to stop using symlinks. I only stop calling _boost_symlink(), I haven't actually removed the helper function yet.

AttachmentSize
boost-no-symlinks-174380-13.patch1.38 KB

#15

justafish - January 5, 2008 - 19:25

If one were to use this patch this means i18n should now work as well, correct?

#16

Benjamin Melançon - January 22, 2008 - 16:23

#17

firebus - March 27, 2008 - 04:06
Status:patch (code needs work)» patch (reviewed & tested by the community)

fixes my issues with i18n as well.

i also feel that the problems introduced by symlinks wrt. interop with other modules outweighs the relatively minor benefits.

#18

firebus - April 5, 2008 - 16:22

i take it back, i still have an i18n issue.

let's say that default language is en
if the user requests a page like http://www.example.com/de
then boost_set_cache is called with $path=''
and drupal_get_path_alias('') returns 'de'
boost creates two cached files: index.html and de.html

now, if a user comes in with no default language setting, they will receive the cached german index.html

however, i don't think that invalidates this patch. this issue is about disabling symlinks, and the patch works perfectly for that. i18n support is a separate thing.

#19

drubage - April 21, 2008 - 20:27

Daniel,

Is this module working for windows? What changes did you have to make in regards to clean urls? We are using ISAPI mod rewrite 3 and I am not sure how to change the configuration file to make this module work on a Windows 2003 server. Help!

-Drew

#20

sinasalek - June 6, 2008 - 20:10

Hi,
Will you apply this patch if i provide you with windows and linux compatible patch?

 
 

Drupal is a registered trademark of Dries Buytaert.