]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remember result of OC_User::isLoggedIn, can be very expensive to check
authorBart Visscher <bartv@thisnet.nl>
Tue, 19 Jun 2012 15:54:19 +0000 (17:54 +0200)
committerBart Visscher <bartv@thisnet.nl>
Thu, 21 Jun 2012 18:14:53 +0000 (20:14 +0200)
lib/user.php

index 37e6dcd1435366b8c31efa0860894acf1845f924..24435eab23c8533bb7d2e93ef7f163ba364b0508 100644 (file)
@@ -240,13 +240,17 @@ class OC_User {
         * Checks if the user is logged in
         */
        public static function isLoggedIn(){
+               static $is_login_checked = null;
+               if (!is_null($is_login_checked)) {
+                       return $is_login_checked;
+               }
                if( isset($_SESSION['user_id']) AND $_SESSION['user_id']) {
                        OC_App::loadApps(array('authentication'));
                        if (self::userExists($_SESSION['user_id']) ){
-                               return true;
+                               return $is_login_checked = true;
                        }
                }
-               return false;
+               return $is_login_checked = false;
        }
 
        /**