Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Patch of patch for removal of /home (against daily builds)

Go to End

4 Posts   5515 Views


Community Member, 4 Posts

23 May 2007 at 9:35am



As elijahlofgren noticed applied patch to daily is not fully functional
so i'm creating new one with few adjustments:
simplification of some functions as in silverstripe/sapphire/core/control/Director.php you can see that i replaced few lines with one :)
static function getControllerForURL($url) {
if(isset($_GET['debug_profile'])) Profiler::mark("Director","getControllerForURL");
- $url = str_replace('//','/',$url);
- if($url[0] == '/') $url = substr($url,1);
- if($url[strlen($url)-1] == '/') $url = substr($url,0,-1);
+ $url = preg_replace( array( '/\/+/','/^\//', '/\/$/'),array('/','',''),$url);
$urlParts = split('/+', $url);

and so on...
What i would say that i did test speed of str_replace and
preg_replace and get to conclusion that str_replace IS FASTER :)
but in our case i don't think so it is important
because my test case was 200MB Sent mail file (on /dev/shm so no disk usage at all ) and i used 2 cases with next code
$handle = @fopen("/dev/shm/Sent", "r");
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
preg_replace('/mailto:/','something', $buffer);
#str_replace('mailto:','something', $buffer);

and situation is that difference is 2-3 seconds with running time of
13+ seconds for both of them (200 MB :) ).


Google Summer of Code Hacker, 222 Posts

24 May 2007 at 2:49pm

It seems that /home removal patch breaks forms that do processing in the HomePage_Controller because it redirects the forms submission and loses the contents that were submitted.

In order to get the Browser Poll example explained in Tutorial 3: ( ) I had to apply the following patch:

That patch makes the redirection happen only if $_GET and $_POST are empty.

Hope this helps,

Elijah Lofgren


Community Member, 4 Posts

24 May 2007 at 10:25pm

Edited: 24/05/2007 11:48pm

Yes you are definitely correct in that regard. I have noticed that regression (comments did not work on specified page)
but could not find elegant solution, and your is definitely good - best one :)
Your patch does have a small bug. You introduced check for _GET but it always have minimum one value - 'url' param that is created from mod_rewrite rule
so i changed your patch to check if _GET == 1.

and once more thanks for idea :)



Community Member, 231 Posts

28 May 2007 at 2:13pm

Good team work guys! :D Everything should be applied.