Fix #1085 : Feed load with a deleted publisher fails

This commit is contained in:
Romain Neutron
2013-01-31 13:46:15 +01:00
parent ec53fbd0ee
commit 0c2a4ca13a
4 changed files with 30 additions and 10 deletions

View File

@@ -224,7 +224,11 @@ class Feed_Adapter extends Feed_Abstract implements Feed_Interface, cache_cachea
{
$this->load_publishers();
return $this->owner->get_user()->get_id() === $user->get_id();
if ($this->owner) {
return $this->owner->get_user()->get_id() === $user->get_id();
}
return false;
}
/**
@@ -318,10 +322,15 @@ class Feed_Adapter extends Feed_Abstract implements Feed_Interface, cache_cachea
$stmt->closeCursor();
foreach ($rs as $row) {
$publisher = new Feed_Publisher_Adapter($this->appbox, $row['id']);
try {
$publisher = new Feed_Publisher_Adapter($this->appbox, $row['id']);
} catch (\Exception_Feed_PublisherNotFound $e) {
continue;
}
$this->publishers[$row['usr_id']] = $publisher;
if ($publisher->is_owner())
if ($publisher->is_owner()) {
$this->owner = $publisher;
}
}
return $this->publishers;

View File

@@ -373,8 +373,13 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
*/
public function get_publisher()
{
if ( ! $this->publisher instanceof Feed_Publisher_Adapter)
$this->publisher = new Feed_Publisher_Adapter($this->appbox, $this->publisher_id);
if ( ! $this->publisher instanceof Feed_Publisher_Adapter) {
try {
$this->publisher = new Feed_Publisher_Adapter($this->appbox, $this->publisher_id);
} catch (\Exception_Feed_PublisherNotFound $e) {
}
}
return $this->publisher;
}
@@ -386,7 +391,13 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
*/
public function is_publisher(User_adapter $user)
{
return $user->get_id() === $this->get_publisher()->get_user()->get_id();
$publisher = $this->get_publisher();
if ($publisher instanceof Feed_Publisher_Interface) {
return $user->get_id() === $publisher->get_user()->get_id();
}
return false;
}
/**

View File

@@ -95,7 +95,7 @@ class Feed_Publisher_Adapter implements Feed_Publisher_Interface, cache_cacheabl
$stmt->closeCursor();
if ( ! $row)
throw new Exception_Feed_PublisherNotFound();
throw new Exception_Feed_PublisherNotFound('Publisher is not Found');
$this->user = User_Adapter::getInstance($row['usr_id'], $this->appbox);
$this->owner = ! ! $row['owner'];