diff --git a/e107_admin/sql/core_sql.php b/e107_admin/sql/core_sql.php index a51d8ba13..c5d4ee23b 100644 --- a/e107_admin/sql/core_sql.php +++ b/e107_admin/sql/core_sql.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/sql/core_sql.php,v $ -| $Revision: 1.12 $ -| $Date: 2008-11-02 14:54:38 $ +| $Revision: 1.13 $ +| $Date: 2008-11-18 21:29:37 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -457,7 +457,8 @@ CREATE TABLE tmp ( tmp_ip varchar(45) NOT NULL default '', tmp_time int(10) unsigned NOT NULL default '0', tmp_info text NOT NULL, - KEY tmp_ip (tmp_ip) + KEY tmp_ip (tmp_ip), + KEY tmp_time (tmp_time) ) TYPE=MyISAM; # -------------------------------------------------------- diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index 8209b5571..90fcc3317 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/update_routines.php,v $ -| $Revision: 1.30 $ -| $Date: 2008-11-09 20:14:17 $ +| $Revision: 1.31 $ +| $Date: 2008-11-18 21:29:37 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -442,28 +442,24 @@ function update_706_to_800($type='') } -//--------------------------------------------------------- -// Add index to download history -//--------------------------------------------------------- - if ($sql -> db_Query("SHOW INDEX FROM ".MPREFIX."download_requests")) + + // Add index to download history + if (FALSE !== ($temp = addIndexToTable('download_requests', 'download_request_datestamp', $just_check, &$updateMessages))) { - $found = FALSE; - while ($row = $sql -> db_Fetch()) - { // One index per field - if (in_array('download_request_datestamp', $row)) + if ($just_check) { - $found = TRUE; - break; + return update_needed($temp); } - } - if (!$found) - { - if ($just_check) return update_needed(); - mysql_query("ALTER TABLE `".MPREFIX."download_requests` ADD INDEX `download_request_datestamp` (`download_request_datestamp`);"); - $updateMessages[] = LAN_UPDATE_37; - } } + // Extra index to tmp table + if (FALSE !== ($temp = addIndexToTable('tmp', 'tmp_time', $just_check, &$updateMessages))) + { + if ($just_check) + { + return update_needed($temp); + } + } // Front page prefs (logic has changed) if (!isset($pref['frontpage_force'])) @@ -825,6 +821,32 @@ function mysql_table_exists($table) } +// Add index to a table. Returns FALSE if not required. Returns a message if required and just checking +function addIndexToTable($target, $indexSpec, $just_check, &$updateMessages) +{ + global $sql; + if ($sql -> db_Query("SHOW INDEX FROM ".MPREFIX.$target)) + { + $found = FALSE; + while ($row = $sql -> db_Fetch()) + { // One index per field + if (in_array($indexSpec, $row)) + { + return !$just_check; // Found - nothing to do + } + } + // Index not found here + if ($just_check) + { + return 'Required to add index to '.$target; + } + mysql_query("ALTER TABLE `".MPREFIX.$target."` ADD INDEX `".$indexSpec."` (`".$indexSpec."`);"); + $updateMessages[] = str_replace(array('--TABLE--','--INDEX--'),array($target,$indexSpec),LAN_UPDATE_37); + } + return FALSE; +} + + function catch_error() { if (mysql_error()!='' && E107_DEBUG_LEVEL != 0) diff --git a/e107_languages/English/admin/lan_e107_update.php b/e107_languages/English/admin/lan_e107_update.php index 9fbcb8d0a..649f8e19f 100644 --- a/e107_languages/English/admin/lan_e107_update.php +++ b/e107_languages/English/admin/lan_e107_update.php @@ -4,8 +4,8 @@ | e107 website system - Language File. | | $Source: /cvs_backup/e107_0.8/e107_languages/English/admin/lan_e107_update.php,v $ -| $Revision: 1.4 $ -| $Date: 2008-11-09 20:14:22 $ +| $Revision: 1.5 $ +| $Date: 2008-11-18 21:29:43 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -41,7 +41,7 @@ define('LAN_UPDATE_33', 'Update comment table format'); define('LAN_UPDATE_34', 'Error adding columns to comment table'); define('LAN_UPDATE_35', 'Error modifying data in comment table'); define('LAN_UPDATE_36', 'Error deleting old field in comment table'); -define('LAN_UPDATE_37', 'Add index to download history'); +define('LAN_UPDATE_37', 'Add index --INDEX-- to table --TABLE--'); define('LAN_UPDATE_38', 'Update front page settings'); define('LAN_UPDATE_39', 'Update linkwords table'); define('LAN_UPDATE_40', 'Update newsfeeds table');