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?
// $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?
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
public static function getAsTimestamp($id)
{
if (empty($id)) {
- throw new EmptyIdException('Notice');
+ throw new EmptyPkeyValueException('Notice', 'id');
}
$timestamp = null;
+++ /dev/null
-<?php
-/**
- * StatusNet, the distributed open-source microblogging tool
- *
- * Class for an exception when a database lookup returns no results
- *
- * PHP version 5
- *
- * LICENCE: This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * @category Exception
- * @package GNUsocial
- * @author Mikael Nordfeldth <mmn@hethane.se>
- * @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));
- }
-}
--- /dev/null
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Class for an exception when a database lookup returns no results
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Exception
+ * @package GNUsocial
+ * @author Mikael Nordfeldth <mmn@hethane.se>
+ * @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));
+ }
+}
} 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()));
}