From cd235dfd428afe001fc0e5ae191136566ec3fbe0 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Sun, 15 Nov 2020 22:59:47 +0100 Subject: [PATCH] [ticket/16629] Fix ACP get_database_size() for MySql 8 PHPBB3-16629 --- phpBB/includes/functions_admin.php | 34 +++++++++++------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 60eb7b616d..07bf9f9192 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2842,34 +2842,24 @@ function get_database_size() switch ($db->get_sql_layer()) { case 'mysqli': - $sql = 'SELECT VERSION() AS mysql_version'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $mysql_engine = ['MyISAM', 'InnoDB', 'Aria']; - if ($row) + $db_name = $db->get_db_name(); + + $sql = 'SHOW TABLE STATUS + FROM ' . $db_name; + $result = $db->sql_query($sql, 7200); + + while ($row = $db->sql_fetchrow($result)) { - $version = $row['mysql_version']; - $mysql_engine = ['MyISAM', 'InnoDB', 'Aria']; - $db_name = $db->get_db_name(); - - $sql = 'SHOW TABLE STATUS - FROM ' . $db_name; - $result = $db->sql_query($sql, 7200); - - while ($row = $db->sql_fetchrow($result)) + if (isset($row['Engine']) && in_array($row['Engine'], $mysql_engine)) { - if (isset($row['Engine']) - && in_array($row['Engine'], $mysql_engine) - ) - { - $database_size += $row['Data_length'] + $row['Index_length']; - } + $database_size += $row['Data_length'] + $row['Index_length']; } - - $db->sql_freeresult($result); } + $db->sql_freeresult($result); + break; case 'sqlite3':