From: Roland Häder Date: Thu, 27 Dec 2012 04:11:37 +0000 (+0000) Subject: More fixes for new installer and script in general :( X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b6a6d0a2c0a0f274b937eb75c413db8fa9b44f9c;p=mailer.git More fixes for new installer and script in general :( --- diff --git a/inc/ajax/ajax_installer.php b/inc/ajax/ajax_installer.php index 1fedf138f0..055d00270a 100644 --- a/inc/ajax/ajax_installer.php +++ b/inc/ajax/ajax_installer.php @@ -52,6 +52,9 @@ function establishAjaxInstallerDatabaseLink () { reportBug(__FUNCTION__, __LINE__, 'Required session data for this step not found.'); } // END - if + // Remove any previous flag + unsetSqlLinkUp(__FUNCTION__, __LINE__); + // Establish link $linkResource = SQL_CONNECT(getSession('mysql_host'), getSession('mysql_login'), getSession('mysql_password1'), __FUNCTION__, __LINE__); @@ -628,9 +631,6 @@ function doAjaxInstallerStepInstallExtensions () { reportBug(__FUNCTION__, __LINE__, 'Cannot load/register extension ' . $ext_name . '.'); } // END - if } // END - foreach - - // Close SQL link - SQL_CLOSE(__FUNCTION__, __LINE__); } // Call-back function to write local configuration file diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index e577551244..d7a7fd3872 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -75,7 +75,10 @@ function SQL_QUERY ($sqlString, $F, $L, $enableCodes = TRUE) { $GLOBALS[__FUNCTION__][$sqlString] = $sqlStringModified; $GLOBALS['last_sql'] = $sqlStringModified; //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Stored cache: ' . $sqlStringModified); - } else { + } elseif (!SQL_IS_LINK_UP()) { + // Link went down while using cached SQL + reportBug(__FUNCTION__, __LINE__, 'Link went down while using cached SQL: sqlString=' . $sqlString . ',F=' . basename($F) . ',L=' . $L . ',enableCodes=' . intval($enableCodes)); + } else { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cache used: ' . $sqlString); // Use cache (to save a lot function calls @@ -169,7 +172,7 @@ function SQL_AFFECTEDROWS() { // SQL fetch row function SQL_FETCHROW ($resource) { - // Is a result resource set? + // Is $resource valid? if ((!is_resource($resource)) || (!SQL_IS_LINK_UP())) return FALSE; // Fetch the data and return it @@ -178,10 +181,10 @@ function SQL_FETCHROW ($resource) { // SQL fetch array function SQL_FETCHARRAY ($resource) { - // Is a result resource set? + // Is $resource valid? if ((!is_resource($resource)) || (!SQL_IS_LINK_UP())) return FALSE; - // Load row from database + // Load row as array from database $row = mysql_fetch_assoc($resource); // Return only arrays here @@ -219,10 +222,11 @@ function SQL_CONNECT ($host, $login, $password, $F, $L) { * SQL_IS_LINK_UP() will only return 'true' if there is really a * working database link. */ - SQL_SET_LINK($linkResource); + SQL_SET_LINK(__FUNCTION__, __LINE__, $linkResource); } // END - if // Return the resource + //* DEBUG: */ logDebugMessage($F . ':' . __FUNCTION__, $L . ':' . __LINE__, 'linkResource[]=' . gettype($linkResource)); return $linkResource; } @@ -232,23 +236,27 @@ function SQL_SELECT_DB ($dbName, $F, $L) { if (!SQL_IS_LINK_UP()) return FALSE; // Return the result + //* DEBUG: */ logDebugMessage($F . ':' . __FUNCTION__, $L . ':' . __LINE__, 'Selecting database ' . $dbName); return mysql_select_db($dbName, SQL_GET_LINK()) or SQL_ERROR($F, $L, mysql_error()); } // SQL close link function SQL_CLOSE ($F, $L) { + // Is the link up? if (!SQL_IS_LINK_UP()) { // Skip double close + //* DEBUG: */ logDebugMessage($F . ':' . __FUNCTION__, $L . ':' . __LINE__, 'Called but no link is open.'); return FALSE; } // END - if // Close database link and forget the link - $close = mysql_close(SQL_GET_LINK()) or SQL_ERROR($F, $L, mysql_error()); + $close = mysql_close(SQL_GET_LINK()) or SQL_ERROR($F . ':' . __FUNCTION__, $L . ':' . __LINE__, mysql_error()); - // Close link - SQL_SET_LINK(NULL); + // Close link in this layer + unsetSqlLinkUp(__FUNCTION__, __LINE__); // Return the result + //* DEBUG: */ logDebugMessage($F . ':' . __FUNCTION__, $L . ':' . __LINE__, 'close[' . gettype($close) . ']=' . intval($close)); return $close; } diff --git a/inc/filter-functions.php b/inc/filter-functions.php index c75f48417e..0f50b2e027 100644 --- a/inc/filter-functions.php +++ b/inc/filter-functions.php @@ -217,7 +217,7 @@ function registerFilter ($F, $L, $filterName, $filterFunction, $silentAbort = TR $filterFunction = 'FILTER_' . strtoupper($filterFunction); // Debug message with FILTER_ prefix - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ENTRY: filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',force=' . intval($force) . ',F=' . basename($F) . ',L=' . $L . ' - ENTERED!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ENTRY: filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',force=' . intval($force) . ',isDryRun=' . intval($isDryRun) . ',F=' . basename($F) . ',L=' . $L . ' - ENTERED!'); // Is that filter already there? if ((isset($GLOBALS['cache_array']['filter']['chains'][$filterName][$filterFunction])) && ($force === FALSE)) { @@ -236,7 +236,7 @@ function registerFilter ($F, $L, $filterName, $filterFunction, $silentAbort = TR // Is the function there? if (!function_exists($filterFunction)) { // Then abort here - addFatalMessage(__FUNCTION__, __LINE__, sprintf("Filter function %s could not be added to filter chain %s. F=%s,L=%s,force=%d", $filterFunction, $filterName, basename($F), $L, intval($force))); + logDebugMessage(__FUNCTION__, __LINE__, sprintf("Filter function %s could not be added to filter chain %s. F=%s,L=%s,force=%d", $filterFunction, $filterName, basename($F), $L, intval($force))); return FALSE; } // END - if @@ -246,7 +246,10 @@ function registerFilter ($F, $L, $filterName, $filterFunction, $silentAbort = TR $GLOBALS['cache_array']['filter']['counter'][$filterName][$filterFunction] = '0'; } // END - if - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ENTRY: filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',force=' . intval($force) . ',F=' . basename($F) . ',L=' . $L . ' - EXIT!'); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ENTRY: filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',force=' . intval($force) . ',isDryRun=' . intval($isDryRun) . ',F=' . basename($F) . ',L=' . $L . ' - EXIT!'); + + // Worked + return TRUE; } // "Unregisters" a filter from the given chain @@ -261,7 +264,7 @@ function unregisterFilter ($F, $L, $filterName, $filterFunction, $force = FALSE, // Is that filter there? if ((!isset($GLOBALS['cache_array']['filter']['chains'][$filterName][$filterFunction])) && ($force === FALSE)) { // Not found, so abort here - addFatalMessage(__FUNCTION__, __LINE__, sprintf(getMessage('FILTER_FAILED_NOT_REMOVED'), $filterFunction, $filterName)); + logDebugMessage(__FUNCTION__, __LINE__, sprintf('Filter function %s cannot be unregistered from filter %s.', $filterFunction, $filterName)); return FALSE; } // END - if @@ -273,6 +276,9 @@ function unregisterFilter ($F, $L, $filterName, $filterFunction, $force = FALSE, } // END - if //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'F=' . $F . ',L=' . $L . ',filterName=' . $filterName . ',filterFunction=' . $filterFunction . ',force=' . intval($force) . ',isDryRun=' . intval($isDryRun) . ' - EXIT!'); + + // Worked + return TRUE; } // "Runs" the given filters, filterData is optional and can be any type of data @@ -309,7 +315,7 @@ function runFilterChain ($filterName, $filterData = NULL) { } // END - if // Call the filter chain - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $filterName . '/' . $filterFunction . ',[]=' . gettype($returnValue)); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $filterName . '/' . $filterFunction . ',[]=' . gettype($returnValue) . ' - CALLING!'); $returnValue = call_user_func_array($filterFunction, array($returnValue)); // Update usage counter diff --git a/inc/filters.php b/inc/filters.php index 8c885c5006..aeb102d24d 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -51,11 +51,12 @@ function FILTER_FLUSH_FILTERS () { reportBug(__FUNCTION__, __LINE__, 'No database link is up. Cannot flush filters.'); } elseif ((isInstallationPhase()) && (!SQL_IS_LINK_UP())) { // If the link is not up in installation phase, skip flushing filters + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cannot flush filters: No link is up.'); return; } // Is the extension ext-sql_patches updated? - if ((!isExtensionInstalled('sql_patches')) || (isExtensionInstalledAndOlder('sql_patches', '0.5.9'))) { + if (((!isExtensionInstalled('sql_patches')) || (isExtensionInstalledAndOlder('sql_patches', '0.5.9'))) && (!isInstallationPhase())) { // Log only in debug mode if (isDebugModeEnabled()) { logDebugMessage(__FUNCTION__, __LINE__, 'Cannot flush filters, ext-sql_patches might be missing. isExtensionInstalled()=' . intval(isExtensionInstalled('sql_patches')) . ',isExtensionInstalledAndOlder()=' . intval(isExtensionInstalledAndOlder('sql_patches', '0.5.9'))); @@ -78,12 +79,12 @@ function FILTER_FLUSH_FILTERS () { // Walk through all filters foreach ($filterArray as $filterFunction => $active) { // Is this filter loaded? - //* DEBUG: */ debugOutput('FOUND:'.$filterName.'/'.$filterFunction.'='.$active); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'FOUND:'.$filterName.'/'.$filterFunction.'='.$active); if (((!isset($GLOBALS['cache_array']['filter']['loaded'][$filterName][$filterFunction])) && ($active != 'R')) || ($active == 'A')) { // Is this filter already in database? if (countSumTotalData($filterFunction, 'filters', 'filter_name', 'filter_function', TRUE, sprintf(" AND `filter_name`='%s'", SQL_ESCAPE($filterName))) == 0) { // Add this filter (all filters are active by default) - //* DEBUG: */ debugOutput('ADD:'.$filterName.'/'.$filterFunction); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ADD:'.$filterName.'/'.$filterFunction); $insertSQL .= sprintf("('%s','%s','Y'),", $filterName, $filterFunction); $inserted++; } elseif (isDebugModeEnabled()) { @@ -92,13 +93,16 @@ function FILTER_FLUSH_FILTERS () { } } elseif ($active == 'R') { // Remove this filter - //* DEBUG: */ debugOutput('REMOVE:'.$filterName.'/'.$filterFunction); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'REMOVE:'.$filterName.'/'.$filterFunction); $removeSQL .= sprintf(" (`filter_name`='%s' AND `filter_function`='%s') OR", $filterName, $filterFunction); $removed++; } } // END - foreach } // END - foreach + // Debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'inserted=' . $inserted . ',removed=' . $removed . ' - AFTER COLLECTION'); + // Something has been added? if ($inserted > 0) { // Finish SQL command and add it @@ -153,21 +157,6 @@ function FILTER_CALL_HANDLER_LOGIN_FAILTURES ($filterData) { return $content; } -// Filter for redirecting to logout if ext-sql_patches has been installed -function FILTER_REDIRECT_TO_LOGOUT_SQL_PATCHES () { - // Remove this filter - unregisterFilter(__FUNCTION__, __LINE__, 'shutdown', __FUNCTION__); - - // Is the element set? - if (isset($GLOBALS['ext_load_mode'])) { - // Redirect here - redirectToUrl('modules.php?module=admin&logout=1&' . $GLOBALS['ext_load_mode'] . '=sql_patches'); - } // END - if - - // This should not happen! - logDebugMessage(__FUNCTION__, __LINE__, 'Cannot auto-logout because no extension load-mode has been set.'); -} - // Filter for auto-activation of a extension function FILTER_AUTO_ACTIVATE_EXTENSION ($filterData) { // Debug message diff --git a/inc/functions.php b/inc/functions.php index f5aa6344ab..faecd19e7d 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -70,15 +70,17 @@ function addFatalMessage ($F, $L, $message, $extra = '') { // Getter for total fatal message count function getTotalFatalErrors () { // Init count - $count = '0'; + $count = 0; // Is there at least the first entry? if (!empty($GLOBALS['fatal_messages'][0])) { // Get total count $count = count($GLOBALS['fatal_messages']); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count=' . $count . ' - FROM ARRAY'); } // END - if // Return value + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'count=' . $count . ' - EXIT!'); return $count; } @@ -1298,7 +1300,7 @@ function logDebugMessage ($funcFile, $line, $message, $force=true) { $message = str_replace(array(chr(13), PHP_EOL), array('', ''), $message); // Log this message away - appendLineToFile(getPath() . getCachePath() . 'debug.log', generateDateTime(time(), '4') . '|' . getModule(FALSE) . '|' . basename($funcFile) . '|' . $line . '|' . $message); + appendLineToFile(getPath() . getCachePath() . 'debug.log', generateDateTime(time(), '4') . '|' . getModule(FALSE) . ':' . getExtraModule() . '|' . basename($funcFile) . '|' . $line . '|' . $message); } // END - if } @@ -1624,8 +1626,8 @@ function doShutdown () { // Call the filter chain 'shutdown' runFilterChain('shutdown', NULL); - // Check if not in installation phase and the link is up - if ((!isInstallationPhase()) && (SQL_IS_LINK_UP())) { + // Check if link is up + if (SQL_IS_LINK_UP()) { // Close link SQL_CLOSE(__FUNCTION__, __LINE__); } elseif (!isInstallationPhase()) { diff --git a/inc/install-functions.php b/inc/install-functions.php index f6d75436b9..b8db7c8dd1 100644 --- a/inc/install-functions.php +++ b/inc/install-functions.php @@ -651,11 +651,14 @@ function isInstallerPostDatabaseConfigValid ($currentTab) { return FALSE; } // END - if + // Remove any previous flag + unsetSqlLinkUp(__FUNCTION__, __LINE__); + // Try to connect to the database - $linkResource = SQL_CONNECT(postRequestElement('mysql_host'), postRequestElement('mysql_login'), postRequestElement('mysql_password1'), __FUNCTION__, __LINE__); + SQL_CONNECT(postRequestElement('mysql_host'), postRequestElement('mysql_login'), postRequestElement('mysql_password1'), __FUNCTION__, __LINE__); // Is the link up - if (!is_resource($linkResource)) { + if (!SQL_IS_LINK_UP()) { // Cannot connect to database $GLOBALS['installer_post_error'][$currentTab] = '{--INSTALLER_POST_DATABASE_CONNECT_ERROR--}'; array_push($GLOBALS['installer_failed_fields'][$currentTab], 'mysql_login', 'mysql_password1', 'mysql_password2'); diff --git a/inc/install/install_page_finalize.php b/inc/install/install_page_finalize.php index 572dcd2a9a..8e432c95d9 100644 --- a/inc/install/install_page_finalize.php +++ b/inc/install/install_page_finalize.php @@ -46,7 +46,7 @@ if ((isPostRequestElementSet('finalize')) && (!isInstalled())) { initSqls(); // Remove any existing "cache" - unset($GLOBALS['is_sql_link_up']); + unsetSqlLinkUp(__FILE__, __LINE__); // Connect to database server SQL_CONNECT($GLOBALS['install_mysql']['host'], $GLOBALS['install_mysql']['login'], $GLOBALS['install_mysql']['password1'], __FILE__, __LINE__); diff --git a/inc/language/de.php b/inc/language/de.php index ac297af6a6..88c39bd99a 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -1190,7 +1190,6 @@ addMessages(array( 'FILTER_FAILED_ALREADY_INIT' => "Filter-System ist bereits initialisiert.", 'FILTER_FAILED_ALREADY_ADDED' => "Die Filterfunktion %s ist bereits der Filterkette %s hinzugefügt.", 'FILTER_FAILED_NO_FILTER_FOUND' => "Die Filterkette %s konnte nicht gefunden werden.", - 'FILTER_FAILED_NOT_REMOVED' => "Die Filterfunktion %s konnte nicht aus der Filterkette %s entfernt werden, da sie nicht existiert.", // Status changes 'ADMIN_STATUS_CHANGED' => "Es wurden %s von %s Einträgen geändert.", diff --git a/inc/loader/load- b/inc/loader/load- index a01d875336..eca6dfd929 100644 --- a/inc/loader/load- +++ b/inc/loader/load- @@ -47,7 +47,7 @@ if (!defined('__SECURITY')) { if (($GLOBALS['cache_instance']->loadCacheFile('foo')) && ($GLOBALS['cache_instance']->extensionVersionMatches('foo'))) { // Load cache $GLOBALS['cache_array']['foo'] = $GLOBALS['cache_instance']->getArrayFromCache(); -} elseif (isHtmlOutputMode()) { +} elseif ((isHtmlOutputMode()) || (isRawOutputMode())) { // Create cache file $GLOBALS['cache_instance']->init(); diff --git a/inc/loader/load-admins.php b/inc/loader/load-admins.php index c34f9585be..e3b5663ed2 100644 --- a/inc/loader/load-admins.php +++ b/inc/loader/load-admins.php @@ -81,7 +81,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('admin')) && ($GLOBALS['cache_ins $GLOBALS['cache_instance']->removeCacheFile(); unset($GLOBALS['cache_array']['admin']); } -} elseif (isHtmlOutputMode()) { +} elseif ((isHtmlOutputMode()) || (isRawOutputMode())) { // Create cache file $GLOBALS['cache_instance']->init(); @@ -152,7 +152,7 @@ if (isExtensionInstalledAndNewer('admins', '0.3')) { // This may drive a lot messages to the logfile //* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'No entry found in admin_acls to rewrite.'); } - } elseif (isHtmlOutputMode()) { + } elseif ((isHtmlOutputMode()) || (isRawOutputMode())) { // Create cache file here $GLOBALS['cache_instance']->init(); diff --git a/inc/loader/load-config.php b/inc/loader/load-config.php index d62984bb41..e6bb7580a5 100644 --- a/inc/loader/load-config.php +++ b/inc/loader/load-config.php @@ -58,7 +58,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('config')) && ($GLOBALS['cache_in // Remove dummy array unset($config); -} elseif (isHtmlOutputMode()) { +} elseif ((isHtmlOutputMode()) || (isRawOutputMode())) { // Create cache file here $GLOBALS['cache_instance']->init(); diff --git a/inc/loader/load-extension.php b/inc/loader/load-extension.php index bc5932f252..791e647616 100644 --- a/inc/loader/load-extension.php +++ b/inc/loader/load-extension.php @@ -132,7 +132,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('extension')) && ($GLOBALS['cache // Remove array and mark cache as loaded unset($EXT_POOL); -} elseif (isHtmlOutputMode()) { +} elseif ((isHtmlOutputMode()) || (isRawOutputMode())) { // Create cache file here $GLOBALS['cache_instance']->init(); diff --git a/inc/loader/load-filter.php b/inc/loader/load-filter.php index b10cb34ab1..7789ef963b 100644 --- a/inc/loader/load-filter.php +++ b/inc/loader/load-filter.php @@ -50,7 +50,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('filter')) && ($GLOBALS['cache_in // Prepare the array here prepareFilterArray(); -} elseif ((isHtmlOutputMode()) && (isExtensionInstalled('sql_patches'))) { +} elseif (((isHtmlOutputMode()) || (isRawOutputMode())) && (isExtensionInstalledAndNewer('sql_patches', '0.5.9'))) { // Create cache file here $GLOBALS['cache_instance']->init(); diff --git a/inc/loader/load-imprint.php b/inc/loader/load-imprint.php index d904fd9cf6..ab2f389025 100644 --- a/inc/loader/load-imprint.php +++ b/inc/loader/load-imprint.php @@ -50,7 +50,7 @@ if (!defined('__SECURITY')) { if (($GLOBALS['cache_instance']->loadCacheFile('imprint')) && ($GLOBALS['cache_instance']->extensionVersionMatches('imprint'))) { // Load cache $GLOBALS['cache_array']['imprint'] = $GLOBALS['cache_instance']->getArrayFromCache(); -} elseif (isHtmlOutputMode()) { +} elseif ((isHtmlOutputMode()) || (isRawOutputMode())) { // Create cache file $GLOBALS['cache_instance']->init(); diff --git a/inc/loader/load-modules.php b/inc/loader/load-modules.php index 03fd6c9bd3..382bf52859 100644 --- a/inc/loader/load-modules.php +++ b/inc/loader/load-modules.php @@ -87,7 +87,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('modules')) && ($GLOBALS['cache_i } // END - foreach } // END - foreach unset($modArray); -} elseif (isHtmlOutputMode()) { +} elseif ((isHtmlOutputMode()) || (isRawOutputMode())) { // Create cache file here $GLOBALS['cache_instance']->init(); diff --git a/inc/loader/load-payments.php b/inc/loader/load-payments.php index b4a9375b2f..8383a50411 100644 --- a/inc/loader/load-payments.php +++ b/inc/loader/load-payments.php @@ -66,7 +66,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('payments')) && ($GLOBALS['cache_ // Set the array back and remove temporary $GLOBALS['cache_array']['payments'] = $paymentsData; unset($paymentsData); -} elseif (isHtmlOutputMode()) { +} elseif ((isHtmlOutputMode()) || (isRawOutputMode())) { // Create cache file $GLOBALS['cache_instance']->init(); diff --git a/inc/loader/load-refdepths.php b/inc/loader/load-refdepths.php index 876372eb3f..82522aad10 100644 --- a/inc/loader/load-refdepths.php +++ b/inc/loader/load-refdepths.php @@ -47,7 +47,7 @@ if (!defined('__SECURITY')) { if (($GLOBALS['cache_instance']->loadCacheFile('refdepths')) && ($GLOBALS['cache_instance']->extensionVersionMatches('sql_patches'))) { // Load referral system from cache $GLOBALS['cache_array']['refdepths'] = $GLOBALS['cache_instance']->getArrayFromCache(); -} elseif (isHtmlOutputMode()) { +} elseif ((isHtmlOutputMode()) || (isRawOutputMode())) { // Create cache file here $GLOBALS['cache_instance']->init(); diff --git a/inc/loader/load-refsystem.php b/inc/loader/load-refsystem.php index ccfb5aa821..9be26d6807 100644 --- a/inc/loader/load-refsystem.php +++ b/inc/loader/load-refsystem.php @@ -47,7 +47,7 @@ if (!defined('__SECURITY')) { if (($GLOBALS['cache_instance']->loadCacheFile('refsystem')) && ($GLOBALS['cache_instance']->extensionVersionMatches('sql_patches'))) { // Load referral system from cache $GLOBALS['cache_array']['refsystem'] = $GLOBALS['cache_instance']->getArrayFromCache(); -} elseif (isHtmlOutputMode()) { +} elseif ((isHtmlOutputMode()) || (isRawOutputMode())) { // Create cache file here $GLOBALS['cache_instance']->init(); diff --git a/inc/loader/load-themes.php b/inc/loader/load-themes.php index c482fc53e8..3613f7232d 100644 --- a/inc/loader/load-themes.php +++ b/inc/loader/load-themes.php @@ -70,7 +70,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('themes')) && ($GLOBALS['cache_in // Remove dummy array unset($cache); -} elseif (isHtmlOutputMode()) { +} elseif ((isHtmlOutputMode()) || (isRawOutputMode())) { // Create cache file here $GLOBALS['cache_instance']->init(); diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php index e25d40dfc7..fd68e77b91 100644 --- a/inc/mysql-connect.php +++ b/inc/mysql-connect.php @@ -131,6 +131,9 @@ if ((!isInstalling()) && (!isInstallationPhase())) { // CFG: DATABASE-TYPE setConfigEntry('_DB_TYPE', 'mysql3'); + // Set link as down + unsetSqlLinkUp(__FILE__, __LINE__); + // Load database layer here loadIncludeOnce('inc/db/lib.php'); diff --git a/inc/sql-functions.php b/inc/sql-functions.php index 671a866744..b08d51ca5c 100644 --- a/inc/sql-functions.php +++ b/inc/sql-functions.php @@ -218,18 +218,28 @@ function getInsertSqlFromArray ($array, $tableName) { return $SQL; } +// Function to unset __is_sql_link_up +function unsetSqlLinkUp ($F, $L) { + // Unset it + //* DEBUG: */ logDebugMessage($F, $L, __FUNCTION__ . ': Called!'); + SQL_SET_LINK($F, $L, NULL); +} + // Initializes the SQL link by bringing it up if set function initSqlLink () { + // "Unset" the link + unsetSqlLinkUp(__FUNCTION__, __LINE__); + // Do this only if link is down assert(!SQL_IS_LINK_UP()); // Is the configuration data set? if ((!empty($GLOBALS['mysql']['host'])) && (!empty($GLOBALS['mysql']['login'])) && (!empty($GLOBALS['mysql']['dbase']))) { // Remove cache - unset($GLOBALS['is_sql_link_up']); + unsetSqlLinkUp(__FUNCTION__, __LINE__); // Connect to DB - SQL_CONNECT($GLOBALS['mysql']['host'], $GLOBALS['mysql']['login'], $GLOBALS['mysql']['password'], __FILE__, __LINE__); + SQL_CONNECT($GLOBALS['mysql']['host'], $GLOBALS['mysql']['login'], $GLOBALS['mysql']['password'], __FUNCTION__, __LINE__); // Is the link valid? if (SQL_IS_LINK_UP()) { @@ -237,7 +247,7 @@ function initSqlLink () { enableExitOnError(); // Is it a valid resource? - if (SQL_SELECT_DB($GLOBALS['mysql']['dbase'], __FILE__, __LINE__) === TRUE) { + if (SQL_SELECT_DB($GLOBALS['mysql']['dbase'], __FUNCTION__, __LINE__) === TRUE) { // Set database name (required for ext-optimize and ifSqlTableExists()) setConfigEntry('__DB_NAME', $GLOBALS['mysql']['dbase']); @@ -248,15 +258,15 @@ function initSqlLink () { loadIncludeOnce('inc/load_cache.php'); } else { // Wrong database? - reportBug(__FILE__, __LINE__, 'Wrong database selected.'); + reportBug(__FUNCTION__, __LINE__, 'Wrong database selected.'); } } else { // No link to database! - reportBug(__FILE__, __LINE__, 'Database link is not yet up.'); + reportBug(__FUNCTION__, __LINE__, 'Database link is not yet up.'); } } else { // Maybe you forgot to enter your database login? - reportBug(__FILE__, __LINE__, 'Database login is missing.'); + reportBug(__FUNCTION__, __LINE__, 'Database login is missing.'); } } @@ -268,7 +278,7 @@ function importSqlDump ($path, $dumpName, $sqlPool) { // Is the file readable? if (!isFileReadable($FQFN)) { // Not found, which is bad - reportBug(__FILE__, __LINE__, sprintf("SQL dump %s/%s.sql is not readable.", $path, $dumpName)); + reportBug(__FUNCTION__, __LINE__, sprintf("SQL dump %s/%s.sql is not readable.", $path, $dumpName)); } // END - if // Then read it @@ -283,7 +293,7 @@ function SQL_QUERY_ESC ($sqlString, $data, $F, $L, $run = TRUE, $strip = TRUE, $ // Link is there? if ((!SQL_IS_LINK_UP()) || (!is_array($data))) { // Link is down or data is not an array - /* DEBUG: */ logDebugMessage($F, $L, 'SQL_IS_LINK_UP()=' . intval(SQL_IS_LINK_UP()) . ',data[]=' . gettype($data) . ',sqlString=' . $sqlString . ': ABORTING!'); + //* DEBUG: */ logDebugMessage($F, $L, 'SQL_IS_LINK_UP()=' . intval(SQL_IS_LINK_UP()) . ',data[]=' . gettype($data) . ',sqlString=' . $sqlString . ': ABORTING!'); return FALSE; } // END - if @@ -473,43 +483,49 @@ function SQL_GET_LINK () { $link = NULL; // Is it in the globals? - if (isset($GLOBALS['sql_link'])) { + if (isset($GLOBALS['__sql_link'])) { // Then take it - $link = $GLOBALS['sql_link']; + $link = $GLOBALS['__sql_link']; + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'link[]=' . gettype($link) . ' - FROM GLOBALS!'); } // END - if // Return it + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'link[]=' . gettype($link) . ' - EXIT!'); return $link; } // Setter for link -function SQL_SET_LINK ($link) { +function SQL_SET_LINK ($F, $L, $link) { + //* DEBUG: */ logDebugMessage($F . ':' . __FUNCTION__, $L . ':' . __LINE__, 'link[]=' . gettype($link) . ' - ENTERED!'); // Is this a resource or null? if ((ifFatalErrorsDetected()) && (isInstallationPhase())) { // This may happen in installation phase + //* DEBUG: */ logDebugMessage($F . ':' . __FUNCTION__, $L . ':' . __LINE__, 'Some fatal errors detected in installation phase.'); return; } elseif ((!is_resource($link)) && (!is_null($link))) { // This should never happen! - reportBug(__FUNCTION__, __LINE__, sprintf("Type of link is not resource or null, type=%s", gettype($link))); + reportBug($F . ':' . __FUNCTION__, $L . ':' . __LINE__, sprintf("Type of link is not resource or null, type=%s", gettype($link))); } // END - if // Set it - $GLOBALS['sql_link'] = $link; + $GLOBALS['__sql_link'] = $link; // Re-init cache - $GLOBALS['is_sql_link_up'] = is_resource($link); + $GLOBALS['__is_sql_link_up'] = is_resource($link); + //* DEBUG: */ logDebugMessage($F . ':' . __FUNCTION__, $L . ':' . __LINE__, '__is_sql_link_up=' . intval($GLOBALS['__is_sql_link_up']) . ' - EXIT!'); } // Checks if the link is up function SQL_IS_LINK_UP () { // Is there cached this? - if (!isset($GLOBALS['is_sql_link_up'])) { - // Determine it - $GLOBALS['is_sql_link_up'] = is_resource(SQL_GET_LINK()); + if (!isset($GLOBALS['__is_sql_link_up'])) { + // Something bad went wrong + reportBug(__FUNCTION__, __LINE__, 'Called before SQL_SET_LINK() was called!'); } // END - if // Return the result - return $GLOBALS['is_sql_link_up']; + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, '__is_sql_link_up=' . intval($GLOBALS['__is_sql_link_up']) . ' - EXIT!'); + return $GLOBALS['__is_sql_link_up']; } // Wrapper function to make code more readable @@ -568,7 +584,7 @@ function ifSqlTableExists ($tableName) { if (!isset($GLOBALS[__FUNCTION__][$tableName])) { // Check if the table is there $result = SQL_QUERY_ESC("SHOW TABLES FROM `{?__DB_NAME?}` WHERE `Tables_in_{?__DB_NAME?}`='{?_MYSQL_PREFIX?}_%s'", - array($tableName), __FILE__, __LINE__); + array($tableName), __FUNCTION__, __LINE__); // Is a link there? if (!is_resource($result)) { diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index fe5834dcd7..60fccd2839 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -673,6 +673,27 @@ function setModule ($newModule) { $GLOBALS['__module'] = strtolower($newModule); } +// Wrapper to get extra module names +function getExtraModule () { + // Default is 'NULL' + $extra = 'NULL'; + + // Is 'tab/step' set? + if (isPostRequestElementSet('tab')) { + // Use this + $extra = 'tab=' . postRequestElement('tab'); + } elseif (isPostRequestElementSet('step')) { + // Use this + $extra = 'step=' . postRequestElement('step'); + } elseif ((isActionSet()) && (isWhatSet())) { + // Use 'action/what' + $extra = 'action=' . getAction() . ':what=' . getWhat(); + } + + // Return it + return $extra; +} + // Checks whether module is set and optionally aborts on miss function isModuleSet ($strict = FALSE) { // Check for it