]> git.mxchange.org Git - mailer.git/blobdiff - inc/wrapper-functions.php
This 'caching' thing is sometimes anoying, but basicly it shortcuts call trees to...
[mailer.git] / inc / wrapper-functions.php
index 3dbbfa8dc3e3b8ae5c0f11f6777ce0e2ccf867b7..2adbd0968ceb67d5f4016c5990ae4be3649ffef5 100644 (file)
@@ -972,6 +972,10 @@ function getUserDataArray () {
 function isUserDataValid () {
        // User id should not be zero so abort here
        if (!isCurrentUserIdSet()) {
+               // Debug message
+               /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'isCurrentUserIdSet()=false - ABORTING!');
+
+               // Abort here
                return false;
        } // END - if
 
@@ -987,18 +991,25 @@ function isUserDataValid () {
 
 // Setter for current userid
 function setCurrentUserId ($userid) {
-       // Set userid
-       $GLOBALS['current_userid'] = bigintval($userid);
-
-       // Unset it to re-determine the actual state
-       unset($GLOBALS['is_userdata_valid'][$userid]);
+       // Debug message
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - ENTERED!');
 
        // Is the cache from below functions different?
-       if ((isset($GLOBALS['getCurrentUserId'])) && ($GLOBALS['getCurrentUserId'] != $userid)) {
+       if (((isset($GLOBALS['getCurrentUserId'])) && ($GLOBALS['getCurrentUserId'] != $userid)) || ((!isset($GLOBALS['current_userid'])) && (isset($GLOBALS['isCurrentUserIdSet'])))) {
                // Then unset both
                unset($GLOBALS['getCurrentUserId']);
                unset($GLOBALS['isCurrentUserIdSet']);
+               unset($GLOBALS['isValidUserId'][$userid]);
        } // END - if
+
+       // Set userid
+       $GLOBALS['current_userid'] = bigintval($userid);
+
+       // Unset it to re-determine the actual state
+       unset($GLOBALS['is_userdata_valid'][$userid]);
+
+       // Debug message
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid . ' - EXIT!');
 }
 
 // Getter for current userid
@@ -1249,12 +1260,6 @@ function isValidUserId ($userid) {
        // Debug message
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid[' . gettype($userid) . ']=' . $userid);
 
-       // Handle NULL
-       if (is_null($userid)) {
-               // Do not handle this as of below isset() will always return false
-               return false;
-       } // END - if
-
        // Do we have cache?
        if (!isset($GLOBALS[__FUNCTION__][$userid])) {
                // Check it out
@@ -1262,6 +1267,7 @@ function isValidUserId ($userid) {
        } // END - if
 
        // Return cache
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',result=' . intval($GLOBALS[__FUNCTION__][$userid]));
        return $GLOBALS[__FUNCTION__][$userid];
 }