From b54a3a02622b614a7b7bd8d189262c9c9605bed7 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 11 Aug 2009 22:30:23 +0000 Subject: [PATCH] fixed #10279: Some columns still latin1 after upgrade to 7.5.40 --- docs/changelog/7.x.x.txt | 1 + docs/upgrades/upgrade_7.7.16-7.7.17.pl | 41 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index db419e9fa..4cc6b3a5c 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -3,6 +3,7 @@ - fixed: #9595: Gallery layout corruption with old browsers - fixed #10753: Admin Bar will only display 1 title at a time - fixed #10751: Only users in Content Managers group can make Shortcuts + - fixed #10279: Some columns still latin1 after upgrade to 7.5.40 - fixed #10748: In-store credit not reported correctly in email - fixed #10746: SQL queriy is improper for MySQL compliant query - fixed: Existing ThingyRecords are broken after upgrade diff --git a/docs/upgrades/upgrade_7.7.16-7.7.17.pl b/docs/upgrades/upgrade_7.7.16-7.7.17.pl index 6f4892609..85c376464 100644 --- a/docs/upgrades/upgrade_7.7.16-7.7.17.pl +++ b/docs/upgrades/upgrade_7.7.16-7.7.17.pl @@ -36,6 +36,7 @@ fixGalleyImageFolderStyle($session); fixMapTemplateFolderStyle($session); fixDefaultSQLReportDownloadGroup($session); addExpireIncompleteSurveyResponsesWorkflow($session); +ensureAllFieldsUtf8($session); finish($session); # this line required @@ -49,6 +50,46 @@ finish($session); # this line required # print "DONE!\n" unless $quiet; #} +sub ensureAllFieldsUtf8 { + my $session = shift; + print "\tEnsuring all database fields are UTF-8... " unless $quiet; + + my $dbh = $session->db->dbh; + my $sth; + my @tables; + my @stmts; + # Get table list + $sth = $dbh->table_info(undef, undef, '%'); + while (my $row = $sth->fetchrow_hashref) { + push @tables, $row->{TABLE_NAME}; + } + $sth->finish; + + for my $table (@tables) { + my $sth = $dbh->column_info(undef, undef, $table, '%'); + while (my $row = $sth->fetchrow_hashref) { + if ($row->{TYPE_NAME} =~ /(?:VAR)?CHAR|TEXT/i) { + push @stmts, sprintf('ALTER TABLE %s MODIFY %s %s %s CHARACTER SET utf8 %s %s', + $dbh->quote_identifier($row->{TABLE_NAME}), + $dbh->quote_identifier($row->{COLUMN_NAME}), + $row->{mysql_type_name}, + ($row->{COLUMN_SIZE} == 22 ? 'binary' : ''), + ($row->{IS_NULLABLE} eq 'NO' ? 'NOT NULL' : ''), + (defined $row->{COLUMN_DEF} && $row->{COLUMN_DEF} ne '' ? 'DEFAULT ' . $dbh->quote($row->{COLUMN_DEF}) : ''), + ); + } + } + $sth->finish; + } + + + for my $stmt (@stmts) { + $dbh->do($stmt); + } + + print "Done.\n" unless $quiet; +} + sub addFriendManagerSettings { my $session = shift; print "\tAdding Friend Manager Style and Layout template settings... " unless $quiet;