mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Merge branch '3.3.x'
This commit is contained in:
commit
2a9ecaea8c
2 changed files with 45 additions and 36 deletions
|
@ -2832,56 +2832,34 @@ function view_warned_users(&$users, &$user_count, $limit = 0, $offset = 0, $limi
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get database size
|
* Get database size
|
||||||
* Currently only mysql and mssql are supported
|
|
||||||
*/
|
*/
|
||||||
function get_database_size()
|
function get_database_size()
|
||||||
{
|
{
|
||||||
global $db, $user, $table_prefix;
|
global $db, $user;
|
||||||
|
|
||||||
$database_size = false;
|
$database_size = false;
|
||||||
|
|
||||||
// This code is heavily influenced by a similar routine in phpMyAdmin 2.2.0
|
|
||||||
switch ($db->get_sql_layer())
|
switch ($db->get_sql_layer())
|
||||||
{
|
{
|
||||||
case 'mysqli':
|
case 'mysqli':
|
||||||
$sql = 'SELECT VERSION() AS mysql_version';
|
$mysql_engine = ['MyISAM', 'InnoDB', 'Aria'];
|
||||||
$result = $db->sql_query($sql);
|
|
||||||
$row = $db->sql_fetchrow($result);
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
|
|
||||||
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'];
|
if (isset($row['Engine']) && in_array($row['Engine'], $mysql_engine))
|
||||||
|
|
||||||
if (preg_match('#(3\.23|[45]\.|10\.[0-9]\.[0-9]{1,2}-+Maria)#', $version))
|
|
||||||
{
|
{
|
||||||
$db_name = (preg_match('#^(?:3\.23\.(?:[6-9]|[1-9]{2}))|[45]\.|10\.[0-9]\.[0-9]{1,2}-+Maria#', $version)) ? "`{$db->get_db_name()}`" : $db->get_db_name();
|
$database_size += $row['Data_length'] + $row['Index_length'];
|
||||||
|
|
||||||
$sql = 'SHOW TABLE STATUS
|
|
||||||
FROM ' . $db_name;
|
|
||||||
$result = $db->sql_query($sql, 7200);
|
|
||||||
|
|
||||||
$database_size = 0;
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
|
||||||
{
|
|
||||||
if ((isset($row['Type']) && $row['Type'] != 'MRG_MyISAM') || (isset($row['Engine']) && ($row['Engine'] == 'MyISAM' || $row['Engine'] == 'InnoDB' || $row['Engine'] == 'Aria')))
|
|
||||||
{
|
|
||||||
if ($table_prefix != '')
|
|
||||||
{
|
|
||||||
if (strpos($row['Name'], $table_prefix) !== false)
|
|
||||||
{
|
|
||||||
$database_size += $row['Data_length'] + $row['Index_length'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$database_size += $row['Data_length'] + $row['Index_length'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'sqlite3':
|
case 'sqlite3':
|
||||||
|
|
31
tests/functional/acp_main_test.php
Normal file
31
tests/functional/acp_main_test.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group functional
|
||||||
|
*/
|
||||||
|
class phpbb_functional_acp_main_test extends phpbb_functional_test_case
|
||||||
|
{
|
||||||
|
public function test_acp_database_size()
|
||||||
|
{
|
||||||
|
$this->add_lang(['acp/common', 'acp/board']);
|
||||||
|
$this->login();
|
||||||
|
$this->admin_login();
|
||||||
|
|
||||||
|
$crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid);
|
||||||
|
$this->assertContainsLang('WELCOME_PHPBB', $this->get_content());
|
||||||
|
$this->assertContainsLang('ADMIN_INTRO', $this->get_content());
|
||||||
|
$this->assertContainsLang('DATABASE_SIZE', $crawler->filter('tbody > tr')->eq(2)->filter('td[class="tabled"]')->eq(0)->text());
|
||||||
|
$this->assertNotContainsLang('NOT_AVAILABLE', $crawler->filter('tbody > tr')->eq(2)->filter('td[class="tabled"]')->eq(1)->text());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue