Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -2464,11 +2464,17 @@ public function convertTablesToUtf8mb4($doDbFixMsg = false)
{
$convertedStep1 = 2;
$convertedStep2 = 4;

// The first step has to be repeated if it has not been run (converted = 4 in database)
$convertedRequired = 5;
}
else
{
$convertedStep1 = 1;
$convertedStep2 = 3;

// All done after step 2
$convertedRequired = 3;
}

// Check conversion status in database
Expand All @@ -2495,7 +2501,7 @@ public function convertTablesToUtf8mb4($doDbFixMsg = false)
}

// Nothing to do, saved conversion status from DB is equal to required final status
if ($convertedDB == $convertedStep2)
if ($convertedDB == $convertedRequired)
{
return;
}
Expand All @@ -2504,7 +2510,7 @@ public function convertTablesToUtf8mb4($doDbFixMsg = false)
$hasErrors = false;

// Steps 1 and 2: Convert core tables if necessary and not to be done at later steps
if ($convertedDB < $convertedStep1)
if ($convertedDB < $convertedStep1 || ($convertedRequired == 5 && ($convertedDB == 3 || $convertedDB == 4)))
{
// Step 1: Drop indexes later to be added again with column lengths limitations at step 2
$fileName1 = JPATH_ROOT . '/administrator/components/com_admin/sql/others/mysql/utf8mb4-conversion-01.sql';
Expand Down Expand Up @@ -2591,11 +2597,11 @@ public function convertTablesToUtf8mb4($doDbFixMsg = false)
}
}
}
}

if (!$hasErrors)
{
$converted = $convertedStep2;
}
if (!$hasErrors)
{
$converted = $convertedRequired;
}

if ($doDbFixMsg && $hasErrors)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Add back the default value which might have been lost with utf8mb4 conversion on certain CMS versions
ALTER TABLE `#__ucm_content` MODIFY `core_title` varchar(400) NOT NULL DEFAULT '';
2 changes: 1 addition & 1 deletion installation/model/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ public function createTables($options)
{
$query->clear()
->update($db->quoteName('#__utf8_conversion'))
->set($db->quoteName('converted') . ' = ' . ($db->hasUTF8mb4Support() ? 4 : 3));
->set($db->quoteName('converted') . ' = ' . ($db->hasUTF8mb4Support() ? 5 : 3));
$db->setQuery($query);

try
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Schema/ChangeSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function __construct($db, $folder = null)
// Set the check query
if ($this->db->hasUTF8mb4Support())
{
$converted = 4;
$converted = 5;
$tmpSchemaChangeItem->queryType = 'UTF8_CONVERSION_UTF8MB4';
}
else
Expand Down