Skip to content

Commit

Permalink
Merge pull request #9658 from richard67/correct-pr-9652
Browse files Browse the repository at this point in the history
Correction after PR 9652
  • Loading branch information
wilsonge committed Apr 5, 2016
2 parents 44c28d3 + 6e34f2e commit 3716365
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
-- to force a new conversion when updating from version 3.5.0
--

UPDATE `#__utf8_conversion` SET converted = 0 WHERE (SELECT COUNT(*) FROM `#__extensions` WHERE `extension_id`=700 AND `manifest_cache` LIKE '%"version":"3.5.0"%') = 1;
UPDATE `#__utf8_conversion` SET `converted` = 0
WHERE (SELECT COUNT(*) FROM `#__schemas` WHERE `extension_id`=700 AND `version_id` LIKE '3.5.0%') = 1;
13 changes: 13 additions & 0 deletions libraries/cms/schema/changeitem/mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ protected function buildCheckQuery()
// We can only make check queries for alter table and create table queries
$command = strtoupper($wordArray[0] . ' ' . $wordArray[1]);

// Check for special update statement to reset utf8mb4 conversion status
if (($command == 'UPDATE `#__UTF8_CONVERSION`'
|| $command == 'UPDATE #__UTF8_CONVERSION')
&& strtoupper($wordArray[2]) == 'SET'
&& strtolower(substr(str_replace('`', '', $wordArray[3]), 0, 9)) == 'converted')
{
// Statement is special statement to reset conversion status
$this->queryType = 'UTF8CNV';

// Done with method
return;
}

if ($command === 'ALTER TABLE')
{
$alterCommand = strtoupper($wordArray[3] . ' ' . $wordArray[4]);
Expand Down
20 changes: 19 additions & 1 deletion libraries/cms/schema/changeset.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,25 @@ public function __construct($db, $folder = null)

foreach ($updateQueries as $obj)
{
$this->changeItems[] = JSchemaChangeitem::getInstance($db, $obj->file, $obj->updateQuery);
$changeItem = JSchemaChangeitem::getInstance($db, $obj->file, $obj->updateQuery);

if ($changeItem->queryType === 'UTF8CNV')
{
// Execute the special update query for utf8mb4 conversion status reset
try
{
$this->db->setQuery($changeItem->updateQuery)->execute();
}
catch (Exception $e)
{
JFactory::getApplication()->enqueueMessage($e->getMessage(), 'error');
}
}
else
{
// Normal change item
$this->changeItems[] = $changeItem;
}
}

// If on mysql, add a query at the end to check for utf8mb4 conversion status
Expand Down

0 comments on commit 3716365

Please sign in to comment.