From 028687d3d35166028e7b74bfbddbbd239f03dcc5 Mon Sep 17 00:00:00 2001 From: Nicolaas / Sunn Side Up Date: Thu, 2 Dec 2021 10:00:08 +1300 Subject: [PATCH] Update DataObject.php PATCH: cleanup --- src/ORM/DataObject.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ORM/DataObject.php b/src/ORM/DataObject.php index fb1986fa257..5693e922b3c 100644 --- a/src/ORM/DataObject.php +++ b/src/ORM/DataObject.php @@ -81,11 +81,11 @@ * static $api_access = true; * * function canView($member = false) { - * if(!$member) $member = Security::getCurrentUser(); + * if (!$member) $member = Security::getCurrentUser(); * return $member->inGroup('Subscribers'); * } * function canEdit($member = false) { - * if(!$member) $member = Security::getCurrentUser(); + * if (!$member) $member = Security::getCurrentUser(); * return $member->inGroup('Editors'); * } * @@ -3051,7 +3051,7 @@ public function can($perm, $member = null, $context = []) * * * $extended = $this->extendedCan('canDoSomething', $member); - * if($extended !== null) return $extended; + * if ($extended !== null) return $extended; * else return $normalValue; * * @@ -3481,14 +3481,17 @@ public static function reset() * @param int|bool $idOrCache The id of the element, or cache if called on target class * @param boolean $cache See {@link get_one()} * - * @return static The element + * @return static|null The element */ public static function get_by_id($classOrID, $idOrCache = null, $cache = true) { // Shift arguments if passing id in first or second argument list ($class, $id, $cached) = is_numeric($classOrID) - ? [get_called_class(), $classOrID, isset($idOrCache) ? $idOrCache : $cache] - : [$classOrID, $idOrCache, $cache]; + ? [get_called_class(), (int) $classOrID, isset($idOrCache) ? $idOrCache : $cache] + : [$classOrID, (int) $idOrCache, $cache]; + if ($id < 1) { + return null; + } // Validate class if ($class === self::class) {