Should avoid the user object to be rebuild on each page.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 20 Mar 2010 15:57:16 +0000 (16:57 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sat, 20 Mar 2010 15:57:16 +0000 (16:57 +0100)
Warning: not sure at all this is a good idea: you have to invalidate the
object stored in the session (if any) if you want to reload a parameter
(like the display name).

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/s.php

index 0ee548e..346f3be 100644 (file)
@@ -119,7 +119,11 @@ class S
     public static function &user()
     {
         if (self::$user == null && class_exists('User')) {
-            self::$user = User::getSilentWithValues(S::i('uid'), $_SESSION);
+            if (S::has('user') && S::v('user') instanceof User) {
+                self::$user = S::v('user');
+            } else {
+                self::$user = User::getSilentWithValues(S::i('uid'), $_SESSION);
+            }
         }
         return self::$user;
     }