From: Vincent Zanotti Date: Sun, 15 Jun 2008 18:51:40 +0000 (+0200) Subject: Allows the use of 'uid' as an alias for 'user_id' in FromValues instantiation of... X-Git-Tag: xorg/0.10.0~86^2~85 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=947eec6fb168865a1b61ad041604f332c94c0392;p=platal.git Allows the use of 'uid' as an alias for 'user_id' in FromValues instantiation of PlUser. Signed-off-by: Vincent Zanotti --- 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;