QA
Dieser Commit ist enthalten in:
Ursprung
898ba15ff6
Commit
0155920475
3 geänderte Dateien mit 28 neuen und 26 gelöschten Zeilen
|
@ -25,14 +25,14 @@ class Msd_Dump
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->dbsToBackup = array();
|
||||
$this->tableInfo = array();
|
||||
$this->recordsTotal = 0;
|
||||
$this->tablesTotal = 0;
|
||||
$this->dbsToBackup = array();
|
||||
$this->tableInfo = array();
|
||||
$this->recordsTotal = 0;
|
||||
$this->tablesTotal = 0;
|
||||
$this->datasizeTotal = 0;
|
||||
$this->dbActual = null;
|
||||
$this->sumTotal = $this->_initSum();
|
||||
$this->dbo = Msd_Db::getAdapter();
|
||||
$this->dbActual = null;
|
||||
$this->sumTotal = $this->_initSum();
|
||||
$this->dbo = Msd_Db::getAdapter();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,9 +42,9 @@ class Msd_Dump
|
|||
*/
|
||||
function prepareDumpProcess()
|
||||
{
|
||||
$taskList = Msd_TaskManager::getInstance('backupTasks', true);
|
||||
$taskList = Msd_TaskManager::getInstance('backupTasks', true);
|
||||
$this->dbsToBackup = $this->_getDbsToBackup();
|
||||
$dbNames=array_keys($this->dbsToBackup);
|
||||
$dbNames = array_keys($this->dbsToBackup);
|
||||
foreach ($dbNames as $dbName) {
|
||||
$sumInfo = $this->_getDatabaseSums($dbName);
|
||||
$this->_addDatabaseSums($sumInfo);
|
||||
|
@ -52,7 +52,7 @@ class Msd_Dump
|
|||
}
|
||||
// set db to be dumped first -> start index is needed
|
||||
$this->dbActual = $dbNames[0];
|
||||
//Debug::out($taskList->getTasks());
|
||||
//var_dump($taskList->getTasks());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +63,7 @@ class Msd_Dump
|
|||
private function _getDbsToBackup()
|
||||
{
|
||||
$dynamicConfig = Msd_Registry::getDynamicConfig();
|
||||
$databases = $dynamicConfig->getParam('dynamic.databases');
|
||||
$databases = $dynamicConfig->getParam('dynamic.databases');
|
||||
// first check if any db is marked to be dumped
|
||||
$dbToDumpExists = false;
|
||||
if (!empty($databases)) {
|
||||
|
@ -71,14 +71,14 @@ class Msd_Dump
|
|||
$this->databases[$dbName] = array();
|
||||
if (isset($val['dump']) && $val['dump'] == 1) {
|
||||
$this->dbsToBackup[$dbName] = $val;
|
||||
$dbToDumpExists = true;
|
||||
$dbToDumpExists = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$dbToDumpExists) {
|
||||
// no db selected for dump -> set actual db to be dumped
|
||||
$index = $dynamicConfig->getParam('dbActual');
|
||||
$this->dbsToBackup[$index] = array();
|
||||
$index = $dynamicConfig->getParam('dbActual');
|
||||
$this->dbsToBackup[$index] = array();
|
||||
$this->dbsToBackup[$index]['dump'] = 1;
|
||||
}
|
||||
|
||||
|
@ -88,15 +88,15 @@ class Msd_Dump
|
|||
/**
|
||||
* Get sum of tables, records and data size grouped by table type
|
||||
*
|
||||
* @param string $db The database to check
|
||||
* @param string $dbName The database to check
|
||||
*
|
||||
* @return void
|
||||
* @return array
|
||||
*/
|
||||
private function _getDatabaseSums($dbName)
|
||||
{
|
||||
$this->dbo->selectDb($dbName);
|
||||
$metaInfo = $this->dbo->getTableStatus();
|
||||
$sum = array();
|
||||
$sum = array();
|
||||
foreach ($metaInfo as $index => $vals) {
|
||||
if ($vals['TABLE_TYPE'] == 'BASE TABLE') {
|
||||
$type = $vals['ENGINE'];
|
||||
|
@ -130,7 +130,7 @@ class Msd_Dump
|
|||
if (!isset($this->sumTotal['tables'][$type])) {
|
||||
$this->sumTotal['tables'][$type] = $this->_initSum();
|
||||
}
|
||||
$this->sumTotal['tables'][$type] =$this->_sumAdd(
|
||||
$this->sumTotal['tables'][$type] = $this->_sumAdd(
|
||||
$this->sumTotal['tables'][$type], $sum[$type]
|
||||
);
|
||||
$this->sumTotal['tablesTotal'] += $sum[$type]['tablesTotal'];
|
||||
|
@ -146,9 +146,9 @@ class Msd_Dump
|
|||
*/
|
||||
private function _initSum()
|
||||
{
|
||||
$sum = array();
|
||||
$sum['tablesTotal'] = 0;
|
||||
$sum['recordsTotal'] = 0;
|
||||
$sum = array();
|
||||
$sum['tablesTotal'] = 0;
|
||||
$sum['recordsTotal'] = 0;
|
||||
$sum['datasizeTotal'] = 0;
|
||||
return $sum;
|
||||
}
|
||||
|
@ -181,23 +181,25 @@ class Msd_Dump
|
|||
// add create table
|
||||
$taskList->addTask(
|
||||
Msd_TaskManager::GET_CREATE_TABLE,
|
||||
array('db' => $dbName,
|
||||
array('db' => $dbName,
|
||||
'table' => $table['TABLE_NAME']
|
||||
)
|
||||
);
|
||||
|
||||
// add dump data
|
||||
if ($table['TABLE_TYPE'] === 'BASE TABLE') {
|
||||
$taskList->addTask(
|
||||
Msd_TaskManager::BACKUP_TABLE_DATA,
|
||||
array('db' => $dbName,
|
||||
array('db' => $dbName,
|
||||
'table' => $table['TABLE_NAME']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// add keys and indexes
|
||||
$taskList->addTask(
|
||||
Msd_TaskManager::GET_ALTER_TABLE_ADD_KEYS,
|
||||
array('db' => $dbName,
|
||||
array('db' => $dbName,
|
||||
'table' => $table['TABLE_NAME']
|
||||
)
|
||||
);
|
||||
|
|
|
@ -62,7 +62,7 @@ class Msd_Registry extends Zend_Registry
|
|||
*/
|
||||
public static function setConfig(Msd_Config $config)
|
||||
{
|
||||
self::set(self::CONFIG_KEY . '', $config);
|
||||
self::set(self::CONFIG_KEY, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -106,7 +106,7 @@ class Msd_TaskManager
|
|||
*
|
||||
* @param string $type
|
||||
*
|
||||
* @return array|false
|
||||
* @return array|bool
|
||||
*/
|
||||
public function getTasks($type = '')
|
||||
{
|
||||
|
|
Laden …
In neuem Issue referenzieren