17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 3893 Views |
-
Patch of patch for removal of /home (against daily builds)

23 May 2007 at 9:35am
URL:http://www.steki.net/code/download/silverstripe/
patch_against_daily_fix_home_redir.diff
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
------------------------------------------
<?php
$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);
}
fclose($handle);
}
?>
------------------------------------------and situation is that difference is 2-3 seconds with running time of
13+ seconds for both of them (200 MB
). -
Re: Patch of patch for removal of /home (against daily builds)

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: ( http://doc.silverstripe.com/doku.php?id=tutorial:3-forms ) I had to apply the following patch:
http://www.elijahlofgren.com/silverstripe/patches/Fix-tutorial-3-dont-redirect-if-url-params-silverstripe.2.0.DailyBuild.2007-05-23.patchThat patch makes the redirection happen only if $_GET and $_POST are empty.
Hope this helps,
Elijah Lofgren
-
Re: Patch of patch for removal of /home (against daily builds)

24 May 2007 at 10:25pm Last edited: 24 May 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.http://www.steki.net/code/download/silverstripe/
patch_20070524_against_Elijah_Lofgren.diffand once more thanks for idea
Boris
-
Re: Patch of patch for removal of /home (against daily builds)

28 May 2007 at 2:13pm
Good team work guys!
Everything should be applied.
| 3893 Views | ||
|
Page:
1
|
Go to Top |



