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.

Upgrading SilverStripe

Ask questions about upgrading SilverStripe to the latest version.

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

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

Go to End

12 Posts   2074 Views


11 May 2010 at 7:16am (Last edited: 11 May 2010 7:19am), Community Member, 9 Posts

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(
       "\"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!


11 May 2010 at 8:49pm Forum Moderator, 801 Posts

Sam has done some fixes to branches/2.4 regarding this:

Can you check out from subversion and see if that works for you? See


11 May 2010 at 9:00pm Community Member, 9 Posts

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.


13 May 2010 at 12:22am Community Member, 110 Posts

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


13 May 2010 at 8:33am Forum Moderator, 801 Posts

Hm, I've added a unittest for Director::urlParam(), seems to work as expected in 2.4:


14 May 2010 at 2:57am Community Member, 110 Posts

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


14 May 2010 at 11:32am Community Member, 32 Posts

Stefdv i have the same problem


14 May 2010 at 2:05pm Forum Moderator, 801 Posts

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.

Go to Top