mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
FIX Nicer fallback if Parent is not set correctly.
This commit is contained in:
parent
cc0ec9b224
commit
567c2236db
@ -135,9 +135,11 @@ class Comment extends DataObject {
|
||||
* @return DataObject
|
||||
*/
|
||||
public function getParent() {
|
||||
if(!$this->BaseClass) $this->BaseClass = "SiteTree";
|
||||
if(!$this->BaseClass) {
|
||||
$this->BaseClass = "SiteTree";
|
||||
}
|
||||
|
||||
return DataObject::get_by_id($this->BaseClass, $this->ParentID);
|
||||
return ($this->ParentID) ? DataObject::get_by_id($this->BaseClass, $this->ParentID) : null;
|
||||
}
|
||||
|
||||
|
||||
@ -149,7 +151,7 @@ class Comment extends DataObject {
|
||||
public function getParentTitle(){
|
||||
$parent = $this->getParent();
|
||||
|
||||
return ($parent->Title) ? $parent->Title : $parent->ClassName . " #" . $parent->ID;
|
||||
return ($parent && $parent->Title) ? $parent->Title : $parent->ClassName . " #" . $parent->ID;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user