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
147 changes: 0 additions & 147 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public function update($installer)
$this->updateDatabase();
$this->updateAssets($installer);
$this->clearStatsCache();
$this->convertTablesToUtf8mb4(true);
$this->addUserAuthProviderColumn();
$this->cleanJoomlaCache();
}
Expand Down Expand Up @@ -7904,152 +7903,6 @@ public function updateAssets($installer)
return true;
}

/**
* Converts the site's database tables to support UTF-8 Multibyte.
*
* @param boolean $doDbFixMsg Flag if message to be shown to check db fix
*
* @return void
*
* @since 3.5
*/
public function convertTablesToUtf8mb4($doDbFixMsg = false)
{
$db = Factory::getDbo();

if ($db->getServerType() !== 'mysql') {
return;
}

// Check if the #__utf8_conversion table exists
$db->setQuery('SHOW TABLES LIKE ' . $db->quote($db->getPrefix() . 'utf8_conversion'));

try {
$rows = $db->loadRowList(0);
} catch (Exception $e) {
// Render the error message from the Exception object
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');

if ($doDbFixMsg) {
// Show an error message telling to check database problems
Factory::getApplication()->enqueueMessage(Text::_('JLIB_DATABASE_ERROR_DATABASE_UPGRADE_FAILED'), 'error');
}

return;
}

// Nothing to do if the table doesn't exist because the CMS has never been updated from a pre-4.0 version
if (count($rows) === 0) {
return;
}

// Set required conversion status
$converted = 5;

// Check conversion status in database
$db->setQuery(
'SELECT ' . $db->quoteName('converted')
. ' FROM ' . $db->quoteName('#__utf8_conversion')
);

try {
$convertedDB = $db->loadResult();
} catch (Exception $e) {
// Render the error message from the Exception object
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');

if ($doDbFixMsg) {
// Show an error message telling to check database problems
Factory::getApplication()->enqueueMessage(Text::_('JLIB_DATABASE_ERROR_DATABASE_UPGRADE_FAILED'), 'error');
}

return;
}

// If conversion status from DB is equal to required final status, try to drop the #__utf8_conversion table
if ($convertedDB === $converted) {
$this->dropUtf8ConversionTable();

return;
}

// Perform the required conversions of core tables if not done already in a previous step
if ($convertedDB !== 99) {
$fileName1 = JPATH_ROOT . '/administrator/components/com_admin/sql/others/mysql/utf8mb4-conversion.sql';

if (is_file($fileName1)) {
$fileContents1 = @file_get_contents($fileName1);
$queries1 = $db->splitSql($fileContents1);

if (!empty($queries1)) {
foreach ($queries1 as $query1) {
try {
$db->setQuery($query1)->execute();
} catch (Exception $e) {
$converted = $convertedDB;

// Still render the error message from the Exception object
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
}
}
}
}
}

// If no error before, perform the optional conversions of tables which might or might not exist
if ($converted === 5) {
$fileName2 = JPATH_ROOT . '/administrator/components/com_admin/sql/others/mysql/utf8mb4-conversion_optional.sql';

if (is_file($fileName2)) {
$fileContents2 = @file_get_contents($fileName2);
$queries2 = $db->splitSql($fileContents2);

if (!empty($queries2)) {
foreach ($queries2 as $query2) {
// Get table name from query
if (preg_match('/^ALTER\s+TABLE\s+([^\s]+)\s+/i', $query2, $matches) === 1) {
$tableName = str_replace('`', '', $matches[1]);
$tableName = str_replace('#__', $db->getPrefix(), $tableName);

// Check if the table exists and if yes, run the query
try {
$db->setQuery('SHOW TABLES LIKE ' . $db->quote($tableName));

$rows = $db->loadRowList(0);

if (count($rows) > 0) {
$db->setQuery($query2)->execute();
}
} catch (Exception $e) {
$converted = 99;

// Still render the error message from the Exception object
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
}
}
}
}
}
}

if ($doDbFixMsg && $converted !== 5) {
// Show an error message telling to check database problems
Factory::getApplication()->enqueueMessage(Text::_('JLIB_DATABASE_ERROR_DATABASE_UPGRADE_FAILED'), 'error');
}

// If the conversion was successful try to drop the #__utf8_conversion table
if ($converted === 5 && $this->dropUtf8ConversionTable()) {
// Table successfully dropped
return;
}

// Set flag in database if the conversion status has changed.
if ($converted !== $convertedDB) {
$db->setQuery('UPDATE ' . $db->quoteName('#__utf8_conversion')
. ' SET ' . $db->quoteName('converted') . ' = ' . $converted . ';')->execute();
}
}

/**
* This method clean the Joomla Cache using the method `clean` from the com_cache model
*
Expand Down

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions administrator/components/com_installer/src/Model/DatabaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,6 @@ public function fix($cids = array())
$installer = new \JoomlaInstallerScript();
$installer->deleteUnexistingFiles();
$this->fixDefaultTextFilters();

/*
* Finally, if the schema updates succeeded, make sure the database table is
* converted to utf8mb4 or, if not supported by the server, compatible to it.
*/
$statusArray = $changeSet['changeset']->getStatus();

if (count($statusArray['error']) == 0) {
$installer->convertTablesToUtf8mb4(false);
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion administrator/language/en-GB/com_installer.ini
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ COM_INSTALLER_MSG_DATABASE_SCHEMA_ERROR="Database version (<strong>%1$s</strong>
COM_INSTALLER_MSG_DATABASE_SCHEMA_VERSION="Database version (in #__schemas): %s."
COM_INSTALLER_MSG_DATABASE_SKIPPED="%s database changes did not alter table structure and were skipped."
COM_INSTALLER_MSG_DATABASE_UPDATEVERSION_ERROR="Database update version (<strong>%1$s</strong>) does not match <strong>%2$s</strong> version (<strong>%3$s</strong>)."
COM_INSTALLER_MSG_DATABASE_UTF8_CONVERSION_UTF8MB4="The Joomla! Core database tables have not been converted yet to UTF-8 Multibyte (utf8mb4)."
COM_INSTALLER_MSG_DISCOVER_DESCRIPTION="Discover extensions that have not gone through the normal installation process."
COM_INSTALLER_MSG_DISCOVER_FAILEDTOPURGEEXTENSIONS="Failed to clear discovered extensions"
COM_INSTALLER_MSG_DISCOVER_INSTALLFAILED="Discover install failed."
Expand Down
Loading