From 947eec6fb168865a1b61ad041604f332c94c0392 Mon Sep 17 00:00:00 2001 From: Vincent Zanotti Date: Sun, 15 Jun 2008 20:51:40 +0200 Subject: [PATCH] Allows the use of 'uid' as an alias for 'user_id' in FromValues instantiation of PlUser. Signed-off-by: Vincent Zanotti --- classes/pluser.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/classes/pluser.php b/classes/pluser.php index 070d289..4beee0a 100644 --- a/classes/pluser.php +++ b/classes/pluser.php @@ -74,6 +74,13 @@ abstract class PlUser // The use case is for arrays got directly from anoter SQL request. protected function fillFromArray(array $values) { + // It might happen that the 'user_id' field is called uid in some places + // (eg. in sessions), so we hard link uid to user_id to prevent useless + // SQL requests. + if (!isset($values['user_id']) && isset($values['uid'])) { + $values['user_id'] = $values['uid']; + } + foreach ($values as $key => $value) { if (property_exists($this, $key) && !isset($this->$key)) { $this->$key = $value; -- 2.1.4