Jump to:

1160 Posts in 2621 Topics by 409 members

Upgrading SilverStripe

SilverStripe Forums » Upgrading SilverStripe » nestedurls - upgrade to 2.4.0 breaks old url schema - (possible bug and solution)

Ask questions about upgrading SilverStripe to the latest version.

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

Page: 1 2
Go to End
Author Topic: 2049 Views
  • mrt_r
    Avatar
    Community Member
    9 Posts

    nestedurls - upgrade to 2.4.0 breaks old url schema - (possible bug and solution) Link to this post

    i upgraded a site to 2.4.0 final and enabledSiteTree::enable_nested_urls(); in my config:
    The old 2.3.x non nested urls for nested pages stopped working. While the changelog describes there being a fallback which rewrites the old urlsegment tot the new nested link via 301 header. While in previous beta/ rc of 2.4.0 this used to work just fine.

    i traced it back to function 'find_old_page' in ModelasController.php

       if(SiteTree::nested_urls()) {
          
             $pages = DataObject::get(
                'SiteTree',
           "\"URLSegment\" = '$URLSegment'" . ((SiteTree::nested_urls()) ? ' AND "ParentID" = ' . (int)$parentID : '')
             

             );
             
             if($pages && $pages->Count() == 1) return $pages->First();
          }
          


    isn't this non functional as there's an if statement checking for SiteTree::nested_urls() while later on a ParentID is always needed as this second check is by default true based on the previous mentioned if statement?
    shouldn't the line at read

    "\"URLSegment\" = '$URLSegment'" . (($parentID) ? ' AND "ParentID" = ' . (int)$parentID : '')


    or could parentID be omitted completely?

    Is my pre 2.4.0 implementation somehow gone wrong a bit and for whatever reason not providing a valid parentid to the function here or is this a bug which crawled in at the last minute?

    hope this helps...
    as a very important sidenote: thanks for 2.4.0 - it looks way way way great!

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: nestedurls - upgrade to 2.4.0 breaks old url schema - (possible bug and solution) Link to this post

    Sam has done some fixes to branches/2.4 regarding this:
    http://open.silverstripe.org/changeset/104463
    http://open.silverstripe.org/changeset/104468

    Can you check out from subversion and see if that works for you? See http://silverstripe.org/subversion

  • mrt_r
    Avatar
    Community Member
    9 Posts

    Re: nestedurls - upgrade to 2.4.0 breaks old url schema - (possible bug and solution) Link to this post

    works like a charm! great work!
    damn, i overlooked that one in the open/closed ticketslist. sorry.
    i used the download package instead of the stable branch. will checkout svn from now on.
    thanks!

  • Stefdv
    Avatar
    Community Member
    110 Posts

    Re: nestedurls - upgrade to 2.4.0 breaks old url schema - (possible bug and solution) Link to this post

    Hi there,

    Sorry that i use your post for my own question but i'm not really sure if i have the same issue...

    'Till SS 2.3.7. i had no problems but now with 2.4 my URL's aren't working.

    This code worked fine and returned a link with my videoID eg. ..../series/1
    i was happy wit that, now it still returns the link, but can't find the page.

    ---------- code --------

    public function getIndividualVideo(){
          
          if($URLAction = Director::URLParam('Action')){

             $VideoID = Convert::raw2xml($URLAction);
          
             if(is_numeric($VideoID )){
                return DataObject::get_by_id('Video', $VideoID);
             }
          }
       
       }

    ----------------- end of code ---------

    What happend? Can someone please help me out ?
    Tx everybody

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: nestedurls - upgrade to 2.4.0 breaks old url schema - (possible bug and solution) Link to this post

    Hm, I've added a unittest for Director::urlParam(), seems to work as expected in 2.4: http://open.silverstripe.org/changeset/104711

  • Stefdv
    Avatar
    Community Member
    110 Posts

    Re: nestedurls - upgrade to 2.4.0 breaks old url schema - (possible bug and solution) Link to this post

    Yes Ingo, i'm sorry...I wasn't verry clear. The link is returned, that's not the problem. but it won't go to the right page, and it does in SS 2.3.7.0.

  • Solo
    Avatar
    Community Member
    32 Posts
  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: nestedurls - upgrade to 2.4.0 breaks old url schema - (possible bug and solution) Link to this post

    Do you have any custom director rules? If yes, please paste them here.
    You mentioned the URL "series/1" - is that connected to a SiteTree/Page record?
    E.g. "mypage/series/1" ?

    Director::URLParam('Action') is not the correct way to get this stuff any more,
    every controller has a SS_HTTPRequest object for this now.
    Use $this->request->param('Action') instead.

    To retrieve the URLSegment of a page, use $myPage->Link()/AbsoluteLink() instead.

    2049 Views
Page: 1 2
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.