NoResultException returns the failed object
This commit is contained in:
parent
1d8b19fe54
commit
9ddc40b6da
|
@ -549,14 +549,22 @@ class Profile extends Managed_DataObject
|
||||||
function getSubscribed($offset=0, $limit=null)
|
function getSubscribed($offset=0, $limit=null)
|
||||||
{
|
{
|
||||||
$subs = Subscription::getSubscribedIDs($this->id, $offset, $limit);
|
$subs = Subscription::getSubscribedIDs($this->id, $offset, $limit);
|
||||||
$profiles = Profile::listFind('id', $subs);
|
try {
|
||||||
|
$profiles = Profile::listFind('id', $subs);
|
||||||
|
} catch (NoResultException $e) {
|
||||||
|
return $e->obj;
|
||||||
|
}
|
||||||
return $profiles;
|
return $profiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSubscribers($offset=0, $limit=null)
|
function getSubscribers($offset=0, $limit=null)
|
||||||
{
|
{
|
||||||
$subs = Subscription::getSubscriberIDs($this->id, $offset, $limit);
|
$subs = Subscription::getSubscriberIDs($this->id, $offset, $limit);
|
||||||
$profiles = Profile::listFind('id', $subs);
|
try {
|
||||||
|
$profiles = Profile::listFind('id', $subs);
|
||||||
|
} catch (NoResultException $e) {
|
||||||
|
return $e->obj;
|
||||||
|
}
|
||||||
return $profiles;
|
return $profiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,11 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
|
|
||||||
class NoAvatarException extends NoResultException
|
class NoAvatarException extends NoResultException
|
||||||
{
|
{
|
||||||
public function __construct(Profile $target, Avatar $avatar)
|
public $target;
|
||||||
|
|
||||||
|
public function __construct(Profile $target, Avatar $obj)
|
||||||
{
|
{
|
||||||
parent::__construct($avatar);
|
$this->target = $target;
|
||||||
|
parent::__construct($obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,11 @@ if (!defined('GNUSOCIAL')) { exit(1); }
|
||||||
|
|
||||||
class NoResultException extends ServerException
|
class NoResultException extends ServerException
|
||||||
{
|
{
|
||||||
|
public $obj; // The object with query that gave no results
|
||||||
|
|
||||||
public function __construct(DB_DataObject $obj)
|
public function __construct(DB_DataObject $obj)
|
||||||
{
|
{
|
||||||
|
$this->obj = $obj;
|
||||||
// We could log an entry here with the search parameters
|
// We could log an entry here with the search parameters
|
||||||
parent::__construct(sprintf(_('No result found on %s lookup.'), get_class($obj)));
|
parent::__construct(sprintf(_('No result found on %s lookup.'), get_class($obj)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,15 +85,8 @@ class ProfileList extends Widget
|
||||||
|
|
||||||
function showProfiles()
|
function showProfiles()
|
||||||
{
|
{
|
||||||
// Note: we don't use fetchAll() because it's borked with query()
|
$cnt = $this->profile->N;
|
||||||
|
$profiles = $this->profile->fetchAll();
|
||||||
$profiles = array();
|
|
||||||
|
|
||||||
while ($this->profile->fetch()) {
|
|
||||||
$profiles[] = clone($this->profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
$cnt = count($profiles);
|
|
||||||
|
|
||||||
$max = min($cnt, $this->maxProfiles());
|
$max = min($cnt, $this->maxProfiles());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user