We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit e274f696 authored by mattl's avatar mattl

Notice->getParent function fixes

NoResultException was the wrong choice in this case, because it was
not a DB_DataObject instance that performed the search, but a static
call to the Notice class.
parent b46c1746
...@@ -2530,19 +2530,15 @@ class Notice extends Managed_DataObject ...@@ -2530,19 +2530,15 @@ class Notice extends Managed_DataObject
return $groups; return $groups;
} }
protected $_parent = -1; protected $_parent = -1; // local object cache
public function getParent() public function getParent()
{ {
if (empty($this->reply_to)) { if (!empty($this->reply_to) && $this->_parent === -1) {
// Should this also be NoResultException? I don't think so.
throw new Exception('Notice has no parent');
} elseif ($this->_parent === -1) { // local object cache
$this->_parent = Notice::getKV('id', $this->reply_to); $this->_parent = Notice::getKV('id', $this->reply_to);
} }
if (!($this->_parent instanceof Notice)) { if (!($this->_parent instanceof Notice)) {
throw new NoResultException($this->_parent); throw new ServerException('Notice has no parent');
} }
return $this->_parent; return $this->_parent;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment