From 56046cc7e26307faa32da750f1bcfbd21be73a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 6 Mar 2017 09:31:22 +0100 Subject: [PATCH] Simplify getting storage engine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - remove not needed word Table from method name - fix code to handle errors - convert existing users of getStatusInfo('ENGINE') to this method Signed-off-by: Michal Čihař --- libraries/Table.php | 9 ++++----- libraries/controllers/table/TableChartController.php | 2 +- libraries/controllers/table/TableIndexesController.php | 2 +- libraries/controllers/table/TableRelationController.php | 3 +-- libraries/controllers/table/TableStructureController.php | 2 +- tbl_operations.php | 2 +- test/classes/TableTest.php | 6 +++--- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/libraries/Table.php b/libraries/Table.php index 296f89e691..52c0fb7ece 100644 --- a/libraries/Table.php +++ b/libraries/Table.php @@ -172,9 +172,7 @@ class Table */ public function isEngine($engine) { - $tbl_storage_engine = strtoupper( - $this->getStatusInfo('ENGINE', false, true) - ); + $tbl_storage_engine = $this->getStorageEngine(); if (is_array($engine)){ foreach($engine as $e){ @@ -327,11 +325,12 @@ class Table * @return string Return storage engine info if it is set for * the selected table else return blank. */ - public function getTableStorageEngine() { + public function getStorageEngine() { $table_storage_engine = $this->getStatusInfo('ENGINE', false, true); if ($table_storage_engine === false) { - return isset($table_storage_engine)? mb_strtoupper($table_storage_engine): ''; + return ''; } + return strtoupper($table_storage_engine); } /** diff --git a/libraries/controllers/table/TableChartController.php b/libraries/controllers/table/TableChartController.php index c537a668a4..8ea597f61b 100644 --- a/libraries/controllers/table/TableChartController.php +++ b/libraries/controllers/table/TableChartController.php @@ -127,7 +127,7 @@ class TableChartController extends TableController $show_comment = null; } else { $tbl_is_view = false; - $tbl_storage_engine = $table_class_object->getTableStorageEngine(); + $tbl_storage_engine = $table_class_object->getStorageEngine(); $show_comment = $table_class_object->getShowComment(); } $tbl_collation = $table_class_object->getTableCollation(); diff --git a/libraries/controllers/table/TableIndexesController.php b/libraries/controllers/table/TableIndexesController.php index 6ecd6a6da1..0b2b869e25 100644 --- a/libraries/controllers/table/TableIndexesController.php +++ b/libraries/controllers/table/TableIndexesController.php @@ -75,7 +75,7 @@ class TableIndexesController extends TableController $show_comment = null; } else { $tbl_is_view = false; - $tbl_storage_engine = $table_class_object->getTableStorageEngine(); + $tbl_storage_engine = $table_class_object->getStorageEngine(); $show_comment = $table_class_object->getShowComment(); } $tbl_collation = $table_class_object->getTableCollation(); diff --git a/libraries/controllers/table/TableRelationController.php b/libraries/controllers/table/TableRelationController.php index 6fe0f7db84..2af9198c30 100644 --- a/libraries/controllers/table/TableRelationController.php +++ b/libraries/controllers/table/TableRelationController.php @@ -146,8 +146,7 @@ class TableRelationController extends TableController } // display secondary level tabs if necessary - $engine = $this->dbi->getTable($this->db, $this->table) - ->getStatusInfo('ENGINE'); + $engine = $this->dbi->getTable($this->db, $this->table)->getStorageEngine(); $this->response->addHTML( Template::get('table/secondary_tabs')->render( diff --git a/libraries/controllers/table/TableStructureController.php b/libraries/controllers/table/TableStructureController.php index 9e7b54f5f8..ed3f6560d8 100644 --- a/libraries/controllers/table/TableStructureController.php +++ b/libraries/controllers/table/TableStructureController.php @@ -252,7 +252,7 @@ class TableStructureController extends TableController } // display secondary level tabs if necessary - $engine = $this->table_obj->getStatusInfo('ENGINE'); + $engine = $this->table_obj->getStorageEngine(); $this->response->addHTML( Template::get('table/secondary_tabs')->render( array( diff --git a/tbl_operations.php b/tbl_operations.php index 6ccbed741e..0db89ffe8e 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -221,7 +221,7 @@ if ($reread_info) { $show_comment = null; } else { $tbl_is_view = false; - $tbl_storage_engine = $pma_table->getTableStorageEngine(); + $tbl_storage_engine = $pma_table->getStorageEngine(); $show_comment = $pma_table->getShowComment(); } $tbl_collation = $pma_table->getTableCollation(); diff --git a/test/classes/TableTest.php b/test/classes/TableTest.php index fbe982e94a..f2b98beebe 100644 --- a/test/classes/TableTest.php +++ b/test/classes/TableTest.php @@ -1203,11 +1203,11 @@ class TableTest extends PMATestCase } /** - * Test for getTableStorageEngine + * Test for getStorageEngine * * @return void */ - public function testGetTableStorageEngine(){ + public function testGetStorageEngine(){ $target_table = 'table1'; $target_db = 'pma_test'; $tbl_object = new Table($target_db, $target_table); @@ -1218,7 +1218,7 @@ class TableTest extends PMATestCase $tbl_storage_engine = $dbi->getTable( $target_db, $target_table - )->getTableStorageEngine(); + )->getStorageEngine(); $this->assertEquals( $expect, $tbl_storage_engine