From: Andrey Kutejko Date: Fri, 28 Oct 2011 17:07:19 +0000 (+0300) Subject: fix GetObjectOr404 shortcut X-Git-Tag: 0.5~324 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=04fea3d9dcb1bc4a7aa2deb6f0092010b474b64b;p=ipf.git fix GetObjectOr404 shortcut --- diff --git a/ipf/shortcuts.php b/ipf/shortcuts.php index a5236dc..2e4415d 100644 --- a/ipf/shortcuts.php +++ b/ipf/shortcuts.php @@ -4,10 +4,9 @@ final class IPF_Shortcuts{ static function GetObjectOr404($object, $id) { - $item = new $object($id); - if ((int)$id > 0 && $item->id == $id) { - return $item; - } + $obj = IPF_ORM::getTable($object)->findOneById($id); + if ($obj) + return $obj; throw new IPF_HTTP_Error404(); } @@ -30,4 +29,4 @@ final class IPF_Shortcuts{ $extra['model'] = $model; return new IPF_Form_Model($data, $extra, $label_suffix); } -} \ No newline at end of file +}