Jump to:

1156 Posts in 2568 Topics by 408 members

Upgrading SilverStripe

SilverStripe Forums » Upgrading SilverStripe » From 2.3.1 to 2.3.2 error on URLSegment

Ask questions about upgrading SilverStripe to the latest version.

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

Page: 1
Go to End
Author Topic: 1025 Views
  • biapar
    Avatar
    Forum Moderator
    435 Posts

    From 2.3.1 to 2.3.2 error on URLSegment Link to this post

    After Upgrade from 2.3.1 to 2.3.2 I've error caused by this function in page.php of mysite:

    function GetLinkFromID($id = 1) {
    $do = DataObject::get_one('Page', '`SiteTree_Live`.ID = '.$id, true);
    return ($do->URLSegment); <-- here

    Error:
    [Notice] Trying to get property of non-object

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: From 2.3.1 to 2.3.2 error on URLSegment Link to this post

    Are you sure the upgrade caused it?

    The error means that there is no page record with the id. You should make the function safer by changing it to:

    function GetLinkFromID($id = 1) {
       $do = DataObject::get_one('Page', '`SiteTree_Live`.ID = '.$id, true);
       return $do ? $do->URLSegment : false;

    This way, if there is not page with that id, it will return false instead of trying to access a member of the nonexistent object.

  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Re: From 2.3.1 to 2.3.2 error on URLSegment Link to this post

    I've update SS production installation and there is page with ID = 1.
    Before updating, it work.

    Best Regards

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: From 2.3.1 to 2.3.2 error on URLSegment Link to this post

    Well this: "'`SiteTree_Live`.ID = '.$id" is not returning anything.

    Maybe the field SiteTree_Live changed?

  • ajshort
    Avatar
    Community Member
    244 Posts

    Re: From 2.3.1 to 2.3.2 error on URLSegment Link to this post

    You shouldn't be querying form the Live table - instead you should just do "`SiteTree`.`ID` = $ID" and your query will automatically be rewritten if you are getting data from the Live table.

    1025 Views
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.