From 0155920475a8bad993e8bc6c1466e2ff5e055ff3 Mon Sep 17 00:00:00 2001 From: DSB Date: Sat, 26 Jan 2013 23:30:00 +0100 Subject: [PATCH] QA --- library/Msd/Dump.php | 50 +++++++++++++++++++------------------ library/Msd/Registry.php | 2 +- library/Msd/TaskManager.php | 2 +- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/library/Msd/Dump.php b/library/Msd/Dump.php index 2ee5b23..ebc49a8 100644 --- a/library/Msd/Dump.php +++ b/library/Msd/Dump.php @@ -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'] ) ); diff --git a/library/Msd/Registry.php b/library/Msd/Registry.php index dac525a..b4f7629 100644 --- a/library/Msd/Registry.php +++ b/library/Msd/Registry.php @@ -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); } /** diff --git a/library/Msd/TaskManager.php b/library/Msd/TaskManager.php index 2d0967c..4609518 100644 --- a/library/Msd/TaskManager.php +++ b/library/Msd/TaskManager.php @@ -106,7 +106,7 @@ class Msd_TaskManager * * @param string $type * - * @return array|false + * @return array|bool */ public function getTasks($type = '') {