Skip to content

Commit

Permalink
Don't ignore exceptions when applying utf8mb4 conversions
Browse files Browse the repository at this point in the history
It should be safe to apply them multiple times.  If an error occurs, then
there's something that is broken and needs fixing.  Don't hide the problem.

Also, don't attempt to process empty lines or comments.  Doing so could lead to
errors.  This treatment is consistent with JInstaller::parseSQLFiles().
  • Loading branch information
zjw committed Nov 21, 2015
1 parent 61bc854 commit 240cdca
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions administrator/components/com_installer/models/database.php
Expand Up @@ -287,13 +287,18 @@ public function convertTablesToUtf8mb4()

foreach ($queries as $query)
{
try
{
$db->setQuery($query)->execute();
}
catch (Exception $e)
$query = trim($query);

if ($query != '' && $query{0} != '#')
{
// If the query fails we will go on. It probably means we've already done this conversion.
try
{
$db->setQuery($query)->execute();
}
catch (RuntimeException $e)
{
JFactory::getApplication()->enqueueMessage(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $e->getCode(), $e->getMessage()));
}
}
}
}
Expand Down

0 comments on commit 240cdca

Please sign in to comment.