From 0cbe2bfe902d26f0e99be6005140a9d8c350f017 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 25 Nov 2009 18:14:57 +0000 Subject: [PATCH] More fixes for installation and extension registration --- inc/classes/cachesystem.class.php | 6 ++--- inc/extensions-functions.php | 28 +++++++++++--------- inc/filters.php | 23 +++++++++------- inc/functions.php | 21 ++++++++++++--- inc/modules/admin/what-overview.php | 2 +- templates/de/html/admin/admin_login_form.tpl | 2 +- 6 files changed, 51 insertions(+), 31 deletions(-) diff --git a/inc/classes/cachesystem.class.php b/inc/classes/cachesystem.class.php index a8223aa640..571721e63d 100644 --- a/inc/classes/cachesystem.class.php +++ b/inc/classes/cachesystem.class.php @@ -417,11 +417,11 @@ class CacheSystem { // Get extension version $ext_ver = getExtensionVersion($ext_name); - // Write cache line to file - fwrite($this->pointer, $this->rewriteEntry($ext_name, $ext_ver, 'version', true)); - // Add the extension version to object (DO NOT REMOVE IT! Endless loop...) $this->version[$this->name][$ext_name] = $ext_ver; + + // Write cache line to file + fwrite($this->pointer, $this->rewriteEntry($ext_name, $ext_ver, 'version', true)); } // END - if //* DEBUG: */ outputHtml(__METHOD__."(".__LINE__."): {$this->name} - {$ext_name}={$ext_ver}
"); } else { diff --git a/inc/extensions-functions.php b/inc/extensions-functions.php index e26f462871..c73a57fe4c 100644 --- a/inc/extensions-functions.php +++ b/inc/extensions-functions.php @@ -226,7 +226,7 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru incrementExtensionUpdateIterator(); // Check for required file - if (loadExtension($ext_update, 'register', '', getExtensionDryRun())) { + if ((!isExtensionInstalled($ext_update)) && (loadExtension($ext_update, 'register', '', getExtensionDryRun()))) { // Set current extension name again setCurrentExtensionName($ext_name); @@ -254,12 +254,15 @@ function registerExtension ($ext_name, $task_id, $dry_run = false, $logout = tru } // END - if } elseif ($ext_ver != getCurrentExtensionVersion()) { // Ok, update this extension now - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName().",ext_update=".$ext_update.",ext_ver=".$ext_ver."/".getCurrentExtensionVersion().""); - $GLOBALS['ext_backup'][$ext_update][$ext_ver] = getCurrentExtensionName(); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName='.getCurrentExtensionName().',currVer='.getCurrentExtensionVersion().''); + $GLOBALS['ext_backup_name'][$ext_update][$ext_ver] = getCurrentExtensionName(); + $GLOBALS['ext_backup_ver'][$ext_update][$ext_ver] = getCurrentExtensionVersion(); updateExtension($ext_update, $ext_ver, getExtensionDryRun()); - setCurrentExtensionName($GLOBALS['ext_backup'][$ext_update][$ext_ver]); - unset($GLOBALS['ext_backup'][$ext_update][$ext_ver]); - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName().""); + setCurrentExtensionName($GLOBALS['ext_backup_name'][$ext_update][$ext_ver]); + setCurrentExtensionVersion($GLOBALS['ext_backup_ver'][$ext_update][$ext_ver]); + unset($GLOBALS['ext_backup_name'][$ext_update][$ext_ver]); + unset($GLOBALS['ext_backup_ver'][$ext_update][$ext_ver]); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'currName='.getCurrentExtensionName().',currVer='.getCurrentExtensionVersion().''); // All okay! $test = true; @@ -537,7 +540,7 @@ function getExtensionVersion ($ext_name, $force = false) { // Is the cache written? if (isset($GLOBALS['cache_array']['extension']['ext_version'][$ext_name])) { // Load data from cache - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ": CACHE!"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $ext_name . ': CACHE!'); $data['ext_version'] = $GLOBALS['cache_array']['extension']['ext_version'][$ext_name]; // Count cache hits @@ -546,15 +549,15 @@ function getExtensionVersion ($ext_name, $force = false) { // Load from database $result = SQL_QUERY_ESC("SELECT `ext_version` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `ext_name`='%s' LIMIT 1", array($ext_name), __FUNCTION__, __LINE__); - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ": DB - ".SQL_NUMROWS($result).""); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $ext_name . ': DB - '.SQL_NUMROWS($result).''); // Is the extension there? if (SQL_NUMROWS($result) == 1) { // Load entry $data = SQL_FETCHARRAY($result); } elseif (isDebugModeEnabled()) { - // Not found! - logDebugMessage(__FUNCTION__, __LINE__, sprintf(": Cannot find extension %s in database!", $ext_name)); + // Not found, please report all + debug_report_bug(sprintf(": Cannot find extension %s in database!", $ext_name)); } // Free result @@ -946,7 +949,7 @@ function ifModuleHasMenu ($mod, $forceDb = false) { // All is false by default $ret = false; - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "mod={$mod},cache=".getExtensionVersion('cache')); + // Extension installed and newer than or has version 0.1.2? if (isExtensionInstalledAndNewer('cache', '0.1.2')) { // Cache version is okay, so let's check the cache! if (isset($GLOBALS['cache_array']['modules']['has_menu'][$mod])) { @@ -986,7 +989,6 @@ function ifModuleHasMenu ($mod, $forceDb = false) { } // Return status - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "currName=".getCurrentExtensionName().intval($ret)); return $ret; } @@ -1553,7 +1555,7 @@ function isExtensionIncludeReadable ($ext_name = '') { } // END - if // Return result - //* DEBUG: */ print __FUNCTION__.': '.$ext_name.'='.intval($GLOBALS['ext_inc_readable'][$ext_name]).'
'; + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',realable='.intval($GLOBALS['ext_inc_readable'][$ext_name])); return $GLOBALS['ext_inc_readable'][$ext_name]; } diff --git a/inc/filters.php b/inc/filters.php index b3c41423c4..1019759bde 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -408,7 +408,7 @@ function FILTER_COMPILE_CONFIG ($code, $compiled = false) { // Is the config valid? if (isConfigEntrySet($matches[1][$key])) { // Set it for caching - $GLOBALS['compile_config'][$matches[1][$key]] = "\".getConfig('" . $matches[1][$key] . "').\""; + $GLOBALS['compile_config'][$matches[1][$key]] = "\" . getConfig('" . $matches[1][$key] . "') . \""; } elseif (isConfigEntrySet('default_' . strtoupper($matches[1][$key]))) { // Use default value $GLOBALS['compile_config'][$matches[1][$key]] = "\" . getConfig('" . 'DEFAULT_' . strtoupper($matches[1][$key]) . "') . \""; @@ -525,14 +525,20 @@ function FILTER_COMPILE_EXTENSION ($code) { break; case 'ext': - // Construct call-back function name - $functionName = 'getExtension' . ucfirst(strtolower($callback)); + // Not installed is default + $replacer = 'false'; - // Construct call of the function - $replacer = "\" . call_user_func_array('" . $functionName . "', array('" . $matches[4][$key] . "', true)) . \""; + // Is the extension installed? + if (isExtensionInstalled($matches[4][$key])) { + // Construct call-back function name + $functionName = 'getExtension' . ucfirst(strtolower($callback)); + + // Construct call of the function + $replacer = "\" . call_user_func_array('" . $functionName . "', array('" . $matches[4][$key] . "', true)) . \""; + } // END - if // Replace it and insert parameter for GET request - $code = str_replace($matches[0][$key], sprintf("&ext=%s&rev=\" . getConfig('CURR_SVN_REVISION') . \"", $replacer), $code); + $code = str_replace($matches[0][$key], sprintf("&ext=%s&ver=%s&rev=\" . getConfig('CURR_SVN_REVISION') . \"", $matches[4][$key], $replacer), $code); break; case 'config': // @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again @@ -584,7 +590,7 @@ function FILTER_RUN_RESET_INCLUDES () { // Is the reset set or old sql_patches? if (((!isResetModeEnabled()) || (!isExtensionInstalled('sql_patches'))) && (getOutputMode() == '0')) { // Then abort here - logDebugMessage(__FUNCTION__, __LINE__, 'Cannot run reset! Please report this bug. Thanks'); + debug_report_bug('Cannot run reset! enabled='.intval(isResetModeEnabled()).',ext='.intval(isExtensionInstalled('sql_patches')).' Please report this bug. Thanks'); } // END - if // Get more daily reset scripts @@ -753,10 +759,9 @@ function FILTER_CHECK_SVN_REVISION () { // Filter for running daily reset function FILTER_RUN_DAILY_RESET () { // Only execute this filter if installed - if ((!isInstalled()) || (!isAdminRegistered())) return; + if ((isInstallationPhase()) || (!isInstalled()) || (!isAdminRegistered()) || (!isExtensionInstalled('sql_patches'))) return; // Shall we run the reset scripts? If a day has changed, maybe also a week/month has changed... Simple! :D - // 012 3 4 43 3 4432 2 3 3 21 1 221 1 221 1 2 21 1 22 10 if (((date('d', getConfig('last_update')) != date('d', time())) || ((isConfigEntrySet('DEBUG_RESET')) && (getConfig('DEBUG_RESET') == 'Y'))) && (!isInstallationPhase()) && (isAdminRegistered()) && (!isGetRequestElementSet('register')) && (getOutputMode() != 1)) { // Tell every module we are in reset-mode! doReset(); diff --git a/inc/functions.php b/inc/functions.php index 51e21667aa..eb36b77d60 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -588,10 +588,10 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = ' if (isDebugModeEnabled()) { // In debug mode we want to display the mail instead of sending it away so we can debug this part outputHtml('
-Headers : ' . htmlentities(trim($mailHeader)) . '
-To      : ' . htmlentities($toEmail) . '
-Subject : ' . htmlentities($subject) . '
-Message : ' . htmlentities($message) . '
+Headers : ' . htmlentities(utf8_decode(trim($mailHeader))) . '
+To      : ' . htmlentities(utf8_decode($toEmail)) . '
+Subject : ' . htmlentities(utf8_decode($subject)) . '
+Message : ' . htmlentities(utf8_decode($message)) . '
 
'); } elseif (($isHtml == 'Y') && (isExtensionActive('html_mail'))) { // Send mail as HTML away @@ -1384,6 +1384,16 @@ function generateImageOrCode ($img_code, $headerSent = true) { } // Create selection box or array of splitted timestamp function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = 'center', $return_array=false) { + // Do not continue if ONE_DAY is absend + if (!isConfigEntrySet('ONE_DAY')) { + // And return the timestamp itself or empty array + if ($return_array === true) { + return array(); + } else { + return $timestamp; + } + } // END - if + // Calculate 2-seconds timestamp $stamp = round($timestamp); //* DEBUG: */ print("*" . $stamp.'/' . $timestamp."*
"); @@ -2081,6 +2091,9 @@ function scrambleString($str) { $scrambleNums = explode(':', genScrambleString(strlen($str))); } + // Compare both lengths and abort if different + if (strlen($str) != count($scrambleNums)) return $str; + // Scramble string here //* DEBUG: */ outputHtml('***Original=' . $str.'***
'); for ($idx = '0'; $idx < strlen($str); $idx++) { diff --git a/inc/modules/admin/what-overview.php b/inc/modules/admin/what-overview.php index 4a464836a0..3805b7734d 100644 --- a/inc/modules/admin/what-overview.php +++ b/inc/modules/admin/what-overview.php @@ -58,7 +58,7 @@ $taskExt = false; // Default is that 'task' is not installed // When the admin is logging in check several things first (new jobs to complete and so on) if (getAction() == 'login') { - if (isExtensionActive('task')) { + if ((isExtensionActive('task')) && (function_exists('outputAdvancedOverview'))) { // When task extension is registered output advanced overview page $jobsDone = outputAdvancedOverview($result_tasks); // This function is provided by the extension 'task' $taskExt = true; diff --git a/templates/de/html/admin/admin_login_form.tpl b/templates/de/html/admin/admin_login_form.tpl index 1484dbb5cc..bf071ab2e3 100644 --- a/templates/de/html/admin/admin_login_form.tpl +++ b/templates/de/html/admin/admin_login_form.tpl @@ -35,7 +35,7 @@ @TODO Doesn't work with sessions {--SELECT_TIMEOUT--}: - + @TODO Try to move the select box to our generic functions