From: Mikael Nordfeldth Date: Sat, 25 Jun 2016 09:50:59 +0000 (+0200) Subject: s/EmptyIdException/EmptyPkeyValueException/ X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7978cd6d5945e9ae0d590b159c5fbaecc36e3fc1;p=quix0rs-gnu-social.git s/EmptyIdException/EmptyPkeyValueException/ --- diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php index 09663ac7c2..f2c70f5452 100644 --- a/actions/apistatusesupdate.php +++ b/actions/apistatusesupdate.php @@ -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? diff --git a/classes/File.php b/classes/File.php index 1a38aefa72..b28f1373d6 100644 --- a/classes/File.php +++ b/classes/File.php @@ -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? diff --git a/classes/Managed_DataObject.php b/classes/Managed_DataObject.php index 5b22672d7b..89263ee778 100644 --- a/classes/Managed_DataObject.php +++ b/classes/Managed_DataObject.php @@ -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 diff --git a/classes/Notice.php b/classes/Notice.php index c130cccc26..96f4769af2 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -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; diff --git a/lib/emptyidexception.php b/lib/emptyidexception.php deleted file mode 100644 index ddf781b067..0000000000 --- a/lib/emptyidexception.php +++ /dev/null @@ -1,38 +0,0 @@ -. - * - * @category Exception - * @package GNUsocial - * @author Mikael Nordfeldth - * @copyright 2013 Free Software Foundation, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 - * @link http://www.gnu.org/software/social/ - */ - -if (!defined('GNUSOCIAL')) { exit(1); } - -class EmptyIdException extends ServerException -{ - public function __construct($called_class) - { - parent::__construct(sprintf(_('Empty ID value was given to query for a "%s" object'), $called_class)); - } -} diff --git a/lib/emptypkeyvalueexception.php b/lib/emptypkeyvalueexception.php new file mode 100644 index 0000000000..4470b7ba31 --- /dev/null +++ b/lib/emptypkeyvalueexception.php @@ -0,0 +1,41 @@ +. + * + * @category Exception + * @package GNUsocial + * @author Mikael Nordfeldth + * @copyright 2013 Free Software Foundation, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3 + * @link http://www.gnu.org/software/social/ + */ + +if (!defined('GNUSOCIAL')) { exit(1); } + +class EmptyPkeyValueException extends ServerException +{ + public function __construct($called_class, $key=null) + { + // 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)); + } +} diff --git a/plugins/Favorite/classes/Fave.php b/plugins/Favorite/classes/Fave.php index c9bb7a6dd2..fb5575c0d4 100644 --- a/plugins/Favorite/classes/Fave.php +++ b/plugins/Favorite/classes/Fave.php @@ -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())); }