Exception throwing and proper db retrieval

ActivityModeration plugin and its Deleted_notice class.
This commit is contained in:
Mikael Nordfeldth
2015-12-31 12:41:30 +01:00
parent 6606781916
commit fab745c6d6
2 changed files with 22 additions and 14 deletions

View File

@@ -96,7 +96,7 @@ class Deleted_notice extends Managed_DataObject
static public function fromStored(Notice $stored)
{
$class = get_called_class();
return self::getByPK(array('uri' => $stored->getUri()));
return self::getByKeys( ['uri' => $stored->getUri()] );
}
// The one who deleted the notice, not the notice's author
@@ -206,4 +206,14 @@ class Deleted_notice extends Managed_DataObject
print "Resuming core schema upgrade...";
}
function insert()
{
$result = parent::insert();
if ($result === false) {
common_log_db_error($this, 'INSERT', __FILE__);
// TRANS: Server exception thrown when a stored object entry cannot be saved.
throw new ServerException('Could not save Deleted_notice');
}
}
}