Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Patch of patch for removal of /home (against daily builds)

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

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

Page: 1
Go to End
Author Topic: 5033 Views
  • steki
    Community Member
    4 Posts

    Patch of patch for removal of /home (against daily builds) Link to this post



    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 ).

  • elijahlofgren
    Google Summer of Code Hacker
    222 Posts

    Re: Patch of patch for removal of /home (against daily builds) Link to this post

    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:

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

    Hope this helps,

    Elijah Lofgren

  • steki
    Community Member
    4 Posts

    Re: Patch of patch for removal of /home (against daily builds) Link to this post

    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


  • Andy
    230 Posts

    Re: Patch of patch for removal of /home (against daily builds) Link to this post

    Good team work guys! Everything should be applied.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.