diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2006-03-01 22:19:24 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2006-03-01 22:19:24 +0000 |
commit | 3f2b287d7c6ce2f9ea798406e2458421fb4b0371 (patch) | |
tree | 5e6ae137f781c325a84acf8811f7e71256ec6b4b /database | |
parent | 9a014043a467e9710d93c66580b33f374e2f4223 (diff) | |
download | brdo-3f2b287d7c6ce2f9ea798406e2458421fb4b0371.tar.gz brdo-3f2b287d7c6ce2f9ea798406e2458421fb4b0371.tar.bz2 |
- #49501: Improve error reporting in the update system
Diffstat (limited to 'database')
-rw-r--r-- | database/updates.inc | 51 |
1 files changed, 6 insertions, 45 deletions
diff --git a/database/updates.inc b/database/updates.inc index 9847ee136..bbbade5ec 100644 --- a/database/updates.inc +++ b/database/updates.inc @@ -1458,8 +1458,9 @@ function system_update_169() { } } + // Note: 'access' table manually updated in update.php return _system_update_utf8(array( - 'access', 'accesslog', 'aggregator_category', + 'accesslog', 'aggregator_category', 'aggregator_category_feed', 'aggregator_category_item', 'aggregator_feed', 'aggregator_item', 'authmap', 'blocks', 'book', 'boxes', 'cache', 'comments', 'contact', @@ -1477,7 +1478,7 @@ function system_update_169() { } /** - * Converts tables to UTF-8 encoding. + * Converts a set of tables to UTF-8 encoding. * * This update is designed to be re-usable by contrib modules and is * used by system_update_169(). @@ -1513,51 +1514,11 @@ function _system_update_utf8($tables) { $_SESSION['update_utf8_total'] = count($tables); } - // Fetch remaining tables list + // Fetch remaining tables list and convert next table $list = &$_SESSION['update_utf8']; - $ret = array(); - - // Convert a table to UTF-8. - // We change all text columns to their correspending binary type, - // then back to text, but with a UTF-8 character set. - // See: http://dev.mysql.com/doc/refman/4.1/en/charset-conversion.html - $types = array('char' => 'binary', - 'varchar' => 'varbinary', - 'tinytext' => 'tinyblob', - 'text' => 'blob', - 'mediumtext' => 'mediumblob', - 'longtext' => 'longblob'); - - // Get next table in list - $table = array_shift($list); - $convert_to_binary = array(); - $convert_to_utf8 = array(); - - // Set table default charset - $ret[] = update_sql('ALTER TABLE {'. $table .'} DEFAULT CHARACTER SET utf8'); - - // Find out which columns need converting and build SQL statements - $result = db_query('SHOW FULL COLUMNS FROM {'. $table .'}'); - while ($column = db_fetch_array($result)) { - list($type) = explode('(', $column['Type']); - if (isset($types[$type])) { - $names = 'CHANGE `'. $column['Field'] .'` `'. $column['Field'] .'` '; - $attributes = ' DEFAULT '. ($column['Default'] == 'NULL' ? 'NULL ' : - "'". db_escape_string($column['Default']) ."' ") . - ($column['Null'] == 'YES' ? 'NULL' : 'NOT NULL'); - - $convert_to_binary[] = $names . preg_replace('/'. $type .'/i', $types[$type], $column['Type']) . $attributes; - $convert_to_utf8[] = $names . $column['Type'] .' CHARACTER SET utf8'. $attributes; - } - } - - if (count($convert_to_binary)) { - // Convert text columns to binary - $ret[] = update_sql('ALTER TABLE {'. $table .'} '. implode(', ', $convert_to_binary)); - // Convert binary columns to UTF-8 - $ret[] = update_sql('ALTER TABLE {'. $table .'} '. implode(', ', $convert_to_utf8)); - } + $ret = update_convert_table_utf8(array_shift($list)); + // Are we done? if (count($list) == 0) { unset($_SESSION['update_utf8']); |