From 98077af43126dd7c274fe57f6ea0494e906e8943 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 31 Jul 2009 22:04:06 +0000 Subject: [PATCH] Fixes for extension problems while installing/removing (still double-registration is not yet fixed) --- inc/extensions.php | 40 ++++++++++++++++++++++++--------- inc/extensions/ext-admins.php | 8 +++---- inc/modules/admin/admin-inc.php | 2 +- inc/mysql-manager.php | 2 +- 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/inc/extensions.php b/inc/extensions.php index 5eb14f67ad..5f3a704895 100644 --- a/inc/extensions.php +++ b/inc/extensions.php @@ -238,6 +238,9 @@ function REGISTER_EXTENSION ($ext_name, $task_id, $dry_run = false, $logout = tr // Try to register the extension //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().":ext_update=".$ext_update.",taskId=".$task."
\n"; $test = REGISTER_EXTENSION($ext_update, $task, $dry_run, false); + + // Reset extension name + EXT_SET_CURR_NAME($ext_name); //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().':'; var_dump($test); } // END - if } elseif ($ext_ver != EXT_GET_VERSION()) { @@ -289,7 +292,7 @@ function REGISTER_EXTENSION ($ext_name, $task_id, $dry_run = false, $logout = tr // Register extension //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:insert=".EXT_GET_CURR_NAME().'/'.EXT_GET_VERSION()." - INSERT!
\n"; SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_extensions` (ext_name, ext_active, ext_version) VALUES ('%s','%s','%s')", - array(EXT_GET_CURR_NAME(), EXT_GET_ALWAYS_ACTIVE(), EXT_GET_VERSION()), __FUNCTION__, __LINE__); + array(EXT_GET_CURR_NAME(), EXT_GET_ALWAYS_ACTIVE(), EXT_GET_VERSION()), __FUNCTION__, __LINE__); // Remove cache file(s) if extension is active runFilterChain('post_extension_installed', array('ext_name' => EXT_GET_CURR_NAME(), 'task_id' => $task_id)); @@ -545,21 +548,38 @@ function EXTENSION_UPDATE ($ext_name, $ext_ver, $dry_run = false) { // And load SQL queries in order of version history for ($idx = ($start + 1); $idx < count($history); $idx++) { + // Set current extension name + //* DEBUG: */ print __FUNCTION__.'['.__LINE__.':] ext_name='.$ext_name.'
'; + EXT_SET_CURR_NAME($ext_name); + // Set extension version $GLOBALS['cache_array']['update_ver'][EXT_GET_CURR_NAME()] = $history[$idx]; // Load again... LOAD_EXTENSION(EXT_GET_CURR_NAME(), 'update', $GLOBALS['cache_array']['update_ver'][EXT_GET_CURR_NAME()], $dry_run); - if (EXT_GET_UPDATE_DEPENDS() != '') { - // Is the extension there? - if (GET_EXT_VERSION(EXT_GET_UPDATE_DEPENDS()) != '') { - // Update another extension first! - $test = EXTENSION_UPDATE(EXT_GET_UPDATE_DEPENDS(), GET_EXT_VERSION(EXT_GET_UPDATE_DEPENDS()), $dry_run); - } else { - // Register new extension - $test = REGISTER_EXTENSION(EXT_GET_UPDATE_DEPENDS(), 0, $dry_run, false); - } + // Get all depencies + $depencies = EXT_GET_UPDATE_DEPENDS(); + + // Nothing to apply? + if (count($depencies) > 0) { + // Apply all extension depencies + foreach ($depencies as $ext_depend) { + // Set it as current + EXT_SET_CURR_NAME($ext_depend); + + // Is the extension there? + if (GET_EXT_VERSION($ext_depend) != '') { + // Update another extension first! + $test = EXTENSION_UPDATE($ext_depend, GET_EXT_VERSION($ext_depend), $dry_run); + } else { + // Register new extension + $test = REGISTER_EXTENSION($ext_depend, 0, $dry_run, false); + } + } // END - foreach + + // Set name back + EXT_SET_CURR_NAME($ext_name); } // END - if // Add notes diff --git a/inc/extensions/ext-admins.php b/inc/extensions/ext-admins.php index 80ccceb242..695d280075 100644 --- a/inc/extensions/ext-admins.php +++ b/inc/extensions/ext-admins.php @@ -297,10 +297,10 @@ PRIMARY KEY (id) break; case '0.7.2': // SQL queries for v0.7.2 - ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admins` DROP login_failtures"); - ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admins` DROP last_failture"); - ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admins` ADD login_failures BIGINT(20) UNSIGNED NOT NULL DEFAULT 0"); - ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admins` ADD last_failure TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'"); + ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admins` DROP `login_failtures`"); + ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admins` DROP `last_failture`"); + ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admins` ADD `login_failures` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0"); + ADD_EXT_SQL("ALTER TABLE `{!_MYSQL_PREFIX!}_admins` ADD `last_failure` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'"); // Update notes (these will be set as task text!) EXT_SET_UPDATE_NOTES("Schreibweise korregiert."); diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 0903d1311a..1353ad3d10 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -95,7 +95,7 @@ function CHECK_ADMIN_LOGIN ($admin_login, $password) { $add = runFilterChain('sql_admin_extra_data'); // Get password from DB - $result = SQL_QUERY_ESC("SELECT password" . $add . " FROM `{!_MYSQL_PREFIX!}_admins` WHERE `id`=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `password`" . $add . " FROM `{!_MYSQL_PREFIX!}_admins` WHERE `id`=%s LIMIT 1", array($aid), __FUNCTION__, __LINE__); // Entry found? diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index a50e4e23fa..7137be73f1 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -217,7 +217,7 @@ function checkModulePermissions ($mod) { } // END - if // Still no luck or not found? - if ((($ret == 'cache_miss') || ($found === false)) && (getOutputMode() == '0')) { + if (($ret == 'cache_miss') || ($found === false)) { // ----- Legacy module ----- ---- Module in base folder ---- --- Module with extension's name --- if ((isFileReadable(sprintf("%sinc/modules/%s.php", constant('PATH'), $mod))) || (isFileReadable(sprintf("%s%s.php", constant('PATH'), $mod))) || (isFileReadable(sprintf("%s%s/%s.php", constant('PATH'), $extension, $mod)))) { // Data is missing so we add it -- 2.39.5