Allows the use of 'uid' as an alias for 'user_id' in FromValues instantiation of...
authorVincent Zanotti <vincent.zanotti@polytechnique.org>
Sun, 15 Jun 2008 18:51:40 +0000 (20:51 +0200)
committerVincent Zanotti <vincent.zanotti@polytechnique.org>
Sun, 15 Jun 2008 18:51:40 +0000 (20:51 +0200)
Signed-off-by: Vincent Zanotti <vincent.zanotti@polytechnique.org>
classes/pluser.php

index 070d289..4beee0a 100644 (file)
@@ -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;