Skip to content

Commit

Permalink
Simplify getting row format
Browse files Browse the repository at this point in the history
- remove not needed word Table from method name
- fix code to handle errors
- convert existing users of getStatusInfo('ROW_FORMAT') to this method

Signed-off-by: Michal Čihař <[email protected]>
  • Loading branch information
nijel committed Mar 20, 2017
1 parent ca9ea74 commit a51ac4e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
9 changes: 5 additions & 4 deletions libraries/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,12 @@ public function getNumRows() {
* @param Current table properties.
* @return Return table row format info if it is set for the selected table or return blank.
*/
public function getTableRowFormat() {
public function getRowFormat() {
$table_row_format = $this->getStatusInfo('ROW_FORMAT', false, true);
return isset($table_row_format)
? $table_row_format
: '';
if ($table_row_format === false) {
return '';
}
return $table_row_format;
}

/**
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 @@ -132,7 +132,7 @@ public function indexAction()
}
$tbl_collation = $table_class_object->getCollation();
$table_info_num_rows = $table_class_object->getNumRows();
$row_format = $table_class_object->getTableRowFormat();
$row_format = $table_class_object->getRowFormat();
$auto_increment = $table_class_object->getAutoIncrementInfo();
$create_options = $table_class_object->createOptionsArray();
} elseif (strlen($this->db) > 0) {
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 @@ -80,7 +80,7 @@ public function displayFormAction()
}
$tbl_collation = $table_class_object->getCollation();
$table_info_num_rows = $table_class_object->getNumRows();
$row_format = $table_class_object->getTableRowFormat();
$row_format = $table_class_object->getRowFormat();
$auto_increment = $table_class_object->getAutoIncrementInfo();
$create_options = $table_class_object->createOptionsArray();
$add_fields = 0;
Expand Down
4 changes: 2 additions & 2 deletions tbl_operations.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@

$row_format = (isset($create_options['row_format']))
? $create_options['row_format']
: $pma_table->getStatusInfo('ROW_FORMAT');
: $pma_table->getRowFormat();

$table_alters = PMA_getTableAltersArray(
$pma_table,
Expand Down Expand Up @@ -226,7 +226,7 @@
}
$tbl_collation = $pma_table->getCollation();
$table_info_num_rows = $pma_table->getNumRows();
$row_format = $pma_table->getTableRowFormat();
$row_format = $pma_table->getRowFormat();
$auto_increment = $pma_table->getAutoIncrementInfo();
$create_options = $pma_table->createOptionsArray();
}
Expand Down
6 changes: 3 additions & 3 deletions test/classes/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1272,11 +1272,11 @@ public function testGetCollation(){
}

/**
* Test for getTableRowFormat
* Test for getRowFormat
*
* @return void
*/
public function testGetTableRowFormat(){
public function testGetRowFormat(){
$target_table = 'table1';
$target_db = 'pma_test';
$tbl_object = new Table($target_db, $target_table);
Expand All @@ -1287,7 +1287,7 @@ public function testGetTableRowFormat(){
$row_format = $dbi->getTable(
$target_db,
$target_table
)->getTableRowFormat();
)->getRowFormat();
$this->assertEquals(
$expect,
$row_format
Expand Down

0 comments on commit a51ac4e

Please sign in to comment.