From: Roland Häder Date: Wed, 10 Mar 2010 01:30:50 +0000 (+0000) Subject: Some more speed hacks X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2a0d398a479e2a1dc039cc27e59eba93385ced92;p=mailer.git Some more speed hacks --- diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 4a07785f7d..881b7c94e6 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -706,17 +706,14 @@ function setUsername ($userName) { // Get username function getUsername () { - // default is guest - $username = getMessage('USERNAME_GUEST'); - // User name set? - if (isset($GLOBALS['username'])) { - // Use the set name - $username = $GLOBALS['username']; + if (!isset($GLOBALS['username'])) { + // No, so it has to be a guest + $GLOBALS['username'] = getMessage('USERNAME_GUEST'); } // END - if // Return it - return $username; + return $GLOBALS['username']; } // Wrapper function for installation phase @@ -815,8 +812,14 @@ function isUserDataValid () { // User id should not be zero so abort here if (!isCurrentUserIdSet()) return false; - // Is the array there and filled? - return ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1)); + // Is it cached? + if (!isset($GLOBALS['is_userdata_valid'][getCurrentUserId()])) { + // Determine it + $GLOBALS['is_userdata_valid'][getCurrentUserId()] = ((isset($GLOBALS['user_data'][getCurrentUserId()])) && (count($GLOBALS['user_data'][getCurrentUserId()]) > 1)); + } // END - if + + // Return the result + return $GLOBALS['is_userdata_valid'][getCurrentUserId()]; } // Setter for current userid @@ -848,17 +851,23 @@ function isDebuggingTemplateCache () { // Wrapper for fetchUserData() and getUserData() calls function getFetchedUserData ($keyColumn, $userId, $valueColumn) { - // Default is 'guest' - $data = getMessage('USERNAME_GUEST'); - - // Can we fetch the user data? - if (($userId > 0) && (fetchUserData($userId, $keyColumn))) { - // Now get the data back - $data = getUserData($valueColumn); + // Is it cached? + if (!isset($GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn])) { + // Default is 'guest' + $data = getMessage('USERNAME_GUEST'); + + // Can we fetch the user data? + if (($userId > 0) && (fetchUserData($userId, $keyColumn))) { + // Now get the data back + $data = getUserData($valueColumn); + } // END - if + + // Cache it + $GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn] = $data; } // END - if // Return it - return $data; + return $GLOBALS['user_data_cache'][$userid][$keyColumn][$valueColumn]; } // Wrapper for strpos() to ease porting from deprecated ereg() function