File tree Expand file tree Collapse file tree 1 file changed +34
-12
lines changed
administrator/components/com_admin Expand file tree Collapse file tree 1 file changed +34
-12
lines changed Original file line number Diff line number Diff line change @@ -1685,6 +1685,40 @@ private function convertTablesToUtf8mb4()
16851685 return ;
16861686 }
16871687
1688+ // Check if utf8mb4 is supported and set required conversion status
1689+ $ utf8mb4Support = false ;
1690+
1691+ if ($ this ->serverClaimsUtf8mb4Support ($ name ))
1692+ {
1693+ $ utf8mb4Support = true ;
1694+ $ converted = 2 ;
1695+ }
1696+ else
1697+ {
1698+ $ converted = 1 ;
1699+ }
1700+
1701+ // Check conversion status in database
1702+ $ db ->setQuery ('SELECT ' . $ db ->quoteName ('converted ' )
1703+ . ' FROM ' . $ db ->quoteName ('#__utf8_conversion ' );
1704+
1705+ try
1706+ {
1707+ $ convertedDB = $ db ->loadResult ();
1708+ }
1709+ catch (Exception $ e )
1710+ {
1711+ JFactory::getApplication ()->enqueueMessage ($ e ->getMessage (), 'error ' );
1712+
1713+ return ;
1714+ }
1715+
1716+ // Nothing to do, saved conversion status from DB is equal to required
1717+ if ($ convertedDB === $ converted )
1718+ {
1719+ return ;
1720+ }
1721+
16881722 // Step 1: Drop indexes later to be added again with column lengths limitations at step 2
16891723 $ fileName1 = JPATH_ADMINISTRATOR . "/components/com_admin/sql/others/mysql/utf8mb4-conversion-01.sql " ;
16901724
@@ -1712,18 +1746,6 @@ private function convertTablesToUtf8mb4()
17121746 // Step 2: Perform the index modifications and conversions
17131747 $ fileName2 = JPATH_ADMINISTRATOR . "/components/com_admin/sql/others/mysql/utf8mb4-conversion-02.sql " ;
17141748
1715- $ utf8mb4Support = false ;
1716-
1717- if ($ this ->serverClaimsUtf8mb4Support ($ name ))
1718- {
1719- $ utf8mb4Support = true ;
1720- $ converted = 2 ;
1721- }
1722- else
1723- {
1724- $ converted = 1 ;
1725- }
1726-
17271749 if (is_file ($ fileName2 ))
17281750 {
17291751 $ fileContents2 = @file_get_contents ($ fileName2 );
You can’t perform that action at this time.
0 commit comments