1043 Posts in 379 Topics by 373 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 928 Views |
-
From 2.3.1 to 2.3.2 error on URLSegment

24 June 2009 at 1:31am
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); <-- hereError:
[Notice] Trying to get property of non-object -
Re: From 2.3.1 to 2.3.2 error on URLSegment

24 June 2009 at 9:01am
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.
-
Re: From 2.3.1 to 2.3.2 error on URLSegment

24 June 2009 at 8:55pm
I've update SS production installation and there is page with ID = 1.
Before updating, it work.Best Regards
-
Re: From 2.3.1 to 2.3.2 error on URLSegment

25 June 2009 at 9:20am
Well this: "'`SiteTree_Live`.ID = '.$id" is not returning anything.
Maybe the field SiteTree_Live changed?
-
Re: From 2.3.1 to 2.3.2 error on URLSegment

25 June 2009 at 9:22am
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.
| 928 Views | ||
|
Page:
1
|
Go to Top |


