From cae2c57b98638e6d910920f64348688dffd2c936 Mon Sep 17 00:00:00 2001 From: quix0r Date: Mon, 1 Oct 2012 20:48:25 +0000 Subject: [PATCH] This 'caching' thing is sometimes anoying, but basicly it shortcuts call trees to speedup the whole application, ifSqlTableExist() was sometimes a name :( --- inc/filter/register_filter.php | 1 - inc/mysql-manager.php | 5 +---- inc/wrapper-functions.php | 30 ++++++++++++++++++------------ 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/inc/filter/register_filter.php b/inc/filter/register_filter.php index ac93c916fa..0720d5f8dd 100644 --- a/inc/filter/register_filter.php +++ b/inc/filter/register_filter.php @@ -43,7 +43,6 @@ if (!defined('__SECURITY')) { // Run a filter for must-fillout fields function FILTER_REGISTER_MUST_FILLOUT ($filterData) { // Get all fields for output - die('!Ok'); //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); $result = SQL_QUERY('SELECT `field_name`,`field_required` FROM `{?_MYSQL_PREFIX?}_must_register` ORDER BY `id` ASC', __FUNCTION__, __LINE__); diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index bb31db5bdf..a890c6e361 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -464,9 +464,6 @@ function fetchUserData ($value, $column = 'userid') { // Secure userid $value = bigintval($value); - // Set it here - setCurrentUserId($value); - // Don't look for invalid userids... if (!isValidUserId($value)) { // Invalid, so abort here @@ -1800,7 +1797,7 @@ function registerExtensionPointsData ($subject, $columnName, $lockedMode, $payme } // END - if // Is the 'subject' there? - if (((!ifSqlTableExist('points_data')) && ((getExtensionMode() == 'register') || (getExtensionMode() == 'update'))) || (countSumTotalData($subject, 'points_data', 'id', 'subject', true, $add) == 0)) { + if (((!ifSqlTableExists('points_data')) && ((getExtensionMode() == 'register') || (getExtensionMode() == 'update'))) || (countSumTotalData($subject, 'points_data', 'id', 'subject', true, $add) == 0)) { // Not found so add an SQL query addExtensionSql(sprintf("INSERT INTO `{?_MYSQL_PREFIX?}_points_data` (`subject`,`column_name`,`locked_mode`,`payment_method`) VALUES ('%s','%s','%s','%s')", $subject, diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 3dbbfa8dc3..2adbd0968c 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -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]; } -- 2.39.5