From 04fea3d9dcb1bc4a7aa2deb6f0092010b474b64b Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Fri, 28 Oct 2011 20:07:19 +0300 Subject: [PATCH] fix GetObjectOr404 shortcut --- ipf/shortcuts.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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 +} -- 2.49.0