s/EmptyIdException/EmptyPkeyValueException/
This commit is contained in:
parent
d7a4098b56
commit
7978cd6d59
|
@ -174,7 +174,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction
|
|||
foreach (array_unique($matches[0]) as $match) {
|
||||
try {
|
||||
$this->media_ids[$match] = File::getByID($match);
|
||||
} catch (EmptyIdException $e) {
|
||||
} catch (EmptyPkeyValueException $e) {
|
||||
// got a zero from the client, at least Twidere does this on occasion
|
||||
} catch (NoResultException $e) {
|
||||
// File ID was not found. Do we abort and report to the client?
|
||||
|
|
|
@ -120,7 +120,7 @@ class File extends Managed_DataObject
|
|||
// $args['attachment'] should always be set if action===attachment, given our routing rules
|
||||
$file = File::getByID($args['attachment']);
|
||||
return $file;
|
||||
} catch (EmptyIdException $e) {
|
||||
} catch (EmptyPkeyValueException $e) {
|
||||
// ...but $args['attachment'] can also be 0...
|
||||
} catch (NoResultException $e) {
|
||||
// apparently this link goes to us, but is _not_ an existing attachment (File) ID?
|
||||
|
|
|
@ -384,7 +384,7 @@ abstract class Managed_DataObject extends Memcached_DataObject
|
|||
static function getByID($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
throw new EmptyIdException(get_called_class());
|
||||
throw new EmptyPkeyValueException(get_called_class(), 'id');
|
||||
}
|
||||
// getByPK throws exception if id is null
|
||||
// or if the class does not have a single 'id' column as primary key
|
||||
|
|
|
@ -2683,7 +2683,7 @@ class Notice extends Managed_DataObject
|
|||
public static function getAsTimestamp($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
throw new EmptyIdException('Notice');
|
||||
throw new EmptyPkeyValueException('Notice', 'id');
|
||||
}
|
||||
|
||||
$timestamp = null;
|
||||
|
|
|
@ -29,10 +29,13 @@
|
|||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class EmptyIdException extends ServerException
|
||||
class EmptyPkeyValueException extends ServerException
|
||||
{
|
||||
public function __construct($called_class)
|
||||
public function __construct($called_class, $key=null)
|
||||
{
|
||||
parent::__construct(sprintf(_('Empty ID value was given to query for a "%s" object'), $called_class));
|
||||
// FIXME: translate the 'not specified' case?
|
||||
parent::__construct(sprintf(_('Empty primary key (%1$s) value was given to query for a "%2$s" object'),
|
||||
is_null($key) ? 'not specified' : _ve($key),
|
||||
$called_class));
|
||||
}
|
||||
}
|
|
@ -132,7 +132,7 @@ class Fave extends Managed_DataObject
|
|||
} catch (NoResultException $e) {
|
||||
// In case there's some inconsistency where the profile or notice was deleted without losing the fave db entry
|
||||
common_log(LOG_INFO, '"'.get_class($e->obj).'" with id=='.var_export($e->obj->id, true).' object not found when deleting favorite, ignoring...');
|
||||
} catch (EmptyIdException $e) {
|
||||
} catch (EmptyPkeyValueException $e) {
|
||||
// Some buggy instances of GNU social have had favorites with notice id==0 stored in the database
|
||||
common_log(LOG_INFO, _ve($e->getMessage()));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user