Commit 1c365f0c authored by Till Brehm's avatar Till Brehm

Merge branch 'stable-3.1' into 'stable-3.1'

fix getDatabaseSize()

See merge request ispconfig/ispconfig3!829
parents 6d28d421 8c4359bb
...@@ -654,13 +654,24 @@ class db ...@@ -654,13 +654,24 @@ class db
* @return int - database-size in bytes * @return int - database-size in bytes
*/ */
public function getDatabaseSize($database_name) { public function getDatabaseSize($database_name) {
global $app; global $app, $conf;
static $db=null;
if ( ! $db ) {
$clientdb_host = ($conf['db_host']) ? $conf['db_host'] : NULL;
$clientdb_user = ($conf['db_user']) ? $conf['db_user'] : NULL;
$clientdb_password = ($conf['db_password']) ? $conf['db_password'] : NULL;
$clientdb_port = ((int)$conf['db_port']) ? (int)$conf['db_port'] : NULL;
$clientdb_flags = ($conf['db_flags'] !== NULL) ? $conf['db_flags'] : NULL;
require_once 'lib/mysql_clientdb.conf'; require_once 'lib/mysql_clientdb.conf';
$result = $this->_query("SELECT SUM(data_length+index_length) FROM information_schema.TABLES WHERE table_schema='".$this->escape($database_name)."'"); $db = new db($clientdb_host, $clientdb_user, $clientdb_password, NULL, $clientdb_port, $clientdb_flags);
}
$result = $db->_query("SELECT SUM(data_length+index_length) FROM information_schema.TABLES WHERE table_schema='".$db->escape($database_name)."'");
if(!$result) { if(!$result) {
$this->_sqlerror('Unable to determine the size of database ' . $database_name); $db->_sqlerror('Unable to determine the size of database ' . $database_name);
return; return;
} }
$database_size = $result->getAsRow(); $database_size = $result->getAsRow();
......
...@@ -654,13 +654,24 @@ class db ...@@ -654,13 +654,24 @@ class db
* @return int - database-size in bytes * @return int - database-size in bytes
*/ */
public function getDatabaseSize($database_name) { public function getDatabaseSize($database_name) {
global $app; global $app, $conf;
static $db=null;
if ( ! $db ) {
$clientdb_host = ($conf['db_host']) ? $conf['db_host'] : NULL;
$clientdb_user = ($conf['db_user']) ? $conf['db_user'] : NULL;
$clientdb_password = ($conf['db_password']) ? $conf['db_password'] : NULL;
$clientdb_port = ((int)$conf['db_port']) ? (int)$conf['db_port'] : NULL;
$clientdb_flags = ($conf['db_flags'] !== NULL) ? $conf['db_flags'] : NULL;
require_once 'lib/mysql_clientdb.conf'; require_once 'lib/mysql_clientdb.conf';
$result = $this->_query("SELECT SUM(data_length+index_length) FROM information_schema.TABLES WHERE table_schema='".$this->escape($database_name)."'"); $db = new db($clientdb_host, $clientdb_user, $clientdb_password, NULL, $clientdb_port, $clientdb_flags);
}
$result = $db->_query("SELECT SUM(data_length+index_length) FROM information_schema.TABLES WHERE table_schema='".$db->escape($database_name)."'");
if(!$result) { if(!$result) {
$this->_sqlerror('Unable to determine the size of database ' . $database_name); $db->_sqlerror('Unable to determine the size of database ' . $database_name);
return; return;
} }
$database_size = $result->getAsRow(); $database_size = $result->getAsRow();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment