Skip to content

Commit

Permalink
Simplify getting table comment
Browse files Browse the repository at this point in the history
- remove not needed word Show from method name
- fix code to handle errors

Signed-off-by: Michal Čihař <[email protected]>
  • Loading branch information
nijel committed Mar 20, 2017
1 parent 56046cc commit b2bf9fb
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion libraries/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ private function _getBreadcrumbs()
$show_comment = null;
} else {
$tbl_is_view = false;
$show_comment = $table_class_object->getShowComment();
$show_comment = $table_class_object->getComment();
}
$retval .= $separator;
if (Util::showIcons('TabsMode')) {
Expand Down
5 changes: 3 additions & 2 deletions libraries/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,12 @@ public function getStorageEngine() {
*
* @return string Return comment info if it is set for the selected table or return blank.
*/
public function getShowComment() {
public function getComment() {
$table_comment = $this->getStatusInfo('COMMENT', false, true);
if ($table_comment === false) {
return isset($table_comment) ? $table_comment : '';
return '';
}
return $table_comment;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/controllers/table/TableChartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function indexAction()
} else {
$tbl_is_view = false;
$tbl_storage_engine = $table_class_object->getStorageEngine();
$show_comment = $table_class_object->getShowComment();
$show_comment = $table_class_object->getComment();
}
$tbl_collation = $table_class_object->getTableCollation();
$table_info_num_rows = $table_class_object->getTableNumRowInfo();
Expand Down
2 changes: 1 addition & 1 deletion libraries/controllers/table/TableIndexesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function displayFormAction()
} else {
$tbl_is_view = false;
$tbl_storage_engine = $table_class_object->getStorageEngine();
$show_comment = $table_class_object->getShowComment();
$show_comment = $table_class_object->getComment();
}
$tbl_collation = $table_class_object->getTableCollation();
$table_info_num_rows = $table_class_object->getTableNumRowInfo();
Expand Down
2 changes: 1 addition & 1 deletion tbl_operations.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
} else {
$tbl_is_view = false;
$tbl_storage_engine = $pma_table->getStorageEngine();
$show_comment = $pma_table->getShowComment();
$show_comment = $pma_table->getComment();
}
$tbl_collation = $pma_table->getTableCollation();
$table_info_num_rows = $pma_table->getTableNumRowInfo();
Expand Down
6 changes: 3 additions & 3 deletions test/classes/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1226,11 +1226,11 @@ public function testGetStorageEngine(){
}

/**
* Test for getShowComment
* Test for getComment
*
* @return void
*/
public function testGetShowComment(){
public function testGetComment(){
$target_table = 'table1';
$target_db = 'pma_test';
$tbl_object = new Table($target_db, $target_table);
Expand All @@ -1241,7 +1241,7 @@ public function testGetShowComment(){
$show_comment = $dbi->getTable(
$target_db,
$target_table
)->getShowComment();
)->getComment();
$this->assertEquals(
$expect,
$show_comment
Expand Down

0 comments on commit b2bf9fb

Please sign in to comment.