From 240cdcaa56c9bd8fe4d76c770d6fac88b1f54fee Mon Sep 17 00:00:00 2001 From: Joe Steele Date: Fri, 20 Nov 2015 16:45:13 -0500 Subject: [PATCH] Don't ignore exceptions when applying utf8mb4 conversions 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(). --- .../com_installer/models/database.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/administrator/components/com_installer/models/database.php b/administrator/components/com_installer/models/database.php index 3acc1d445e945..b7d5b0b53fd72 100644 --- a/administrator/components/com_installer/models/database.php +++ b/administrator/components/com_installer/models/database.php @@ -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())); + } } } }