diff --git a/libraries/classes/Controllers/Database/StructureController.php b/libraries/classes/Controllers/Database/StructureController.php index eb1a0a406f..0e40b6cd5c 100644 --- a/libraries/classes/Controllers/Database/StructureController.php +++ b/libraries/classes/Controllers/Database/StructureController.php @@ -66,6 +66,9 @@ class StructureController extends AbstractController /** @var bool whether stats show or not */ protected $isShowStats; + /** @var bool whether database details show or not */ + protected $isShowDbDetails; + /** @var Relation */ private $relation; @@ -106,6 +109,8 @@ class StructureController extends AbstractController $this->dbi = $dbi; $this->flash = $flash; + $this->isShowDbDetails = $GLOBALS['cfg']['PropertiesNumColumns'] < 2; + $this->replicationInfo = new ReplicationInfo($this->dbi); } @@ -380,6 +385,7 @@ class StructureController extends AbstractController 'replication' => $replicaInfo['status'], 'properties_num_columns' => $GLOBALS['cfg']['PropertiesNumColumns'], 'is_show_stats' => $this->isShowStats, + 'is_show_db_details' => $this->isShowDbDetails, 'show_charset' => $GLOBALS['cfg']['ShowDbStructureCharset'], 'show_comment' => $GLOBALS['cfg']['ShowDbStructureComment'], 'show_creation' => $GLOBALS['cfg']['ShowDbStructureCreation'], @@ -440,6 +446,7 @@ class StructureController extends AbstractController 'already_favorite' => $this->checkFavoriteTable($currentTable['TABLE_NAME']), 'num_favorite_tables' => $GLOBALS['cfg']['NumFavoriteTables'], 'properties_num_columns' => $GLOBALS['cfg']['PropertiesNumColumns'], + 'is_show_db_details' => $this->isShowDbDetails, 'limit_chars' => $GLOBALS['cfg']['LimitChars'], 'show_charset' => $GLOBALS['cfg']['ShowDbStructureCharset'], 'show_comment' => $GLOBALS['cfg']['ShowDbStructureComment'], @@ -468,11 +475,20 @@ class StructureController extends AbstractController $relationParameters = $this->relation->getRelationParameters(); + $defaultStorageEngine = ''; + if ($this->isShowDbDetails) { + $defaultStorageEngineVar = $this->dbi->getVersion() >= 50503 + ? '@@default_storage_engine' + : '@@storage_engine'; + $defaultStorageEngine = $this->dbi->fetchValue(sprintf('SELECT %s;', $defaultStorageEngineVar)); + } + return $html . $this->template->render('database/structure/table_header', [ 'db' => $this->db, 'db_is_system_schema' => $this->dbIsSystemSchema, 'replication' => $replicaInfo['status'], 'properties_num_columns' => $GLOBALS['cfg']['PropertiesNumColumns'], + 'is_show_db_details' => $this->isShowDbDetails, 'is_show_stats' => $this->isShowStats, 'show_charset' => $GLOBALS['cfg']['ShowDbStructureCharset'], 'show_comment' => $GLOBALS['cfg']['ShowDbStructureComment'], @@ -498,6 +514,8 @@ class StructureController extends AbstractController 'num_favorite_tables' => $GLOBALS['cfg']['NumFavoriteTables'], 'db' => $GLOBALS['db'], 'properties_num_columns' => $GLOBALS['cfg']['PropertiesNumColumns'], + 'is_show_db_details' => $this->isShowDbDetails, + 'default_storage_engine' => $defaultStorageEngine, 'dbi' => $this->dbi, 'show_charset' => $GLOBALS['cfg']['ShowDbStructureCharset'], 'show_comment' => $GLOBALS['cfg']['ShowDbStructureComment'], diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 60a5e8909c..075747b204 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -5037,7 +5037,7 @@ parameters: - message: "#^Cannot access offset 'PropertiesNumColumns' on mixed\\.$#" - count: 1 + count: 2 path: libraries/classes/Controllers/Database/StructureController.php - diff --git a/templates/database/structure/body_for_table_summary.twig b/templates/database/structure/body_for_table_summary.twig index 2bb026994c..0d354bc86b 100644 --- a/templates/database/structure/body_for_table_summary.twig +++ b/templates/database/structure/body_for_table_summary.twig @@ -35,16 +35,10 @@ {% set cell_text = row_count_sum %} {% endif %} {{ cell_text }} - {% if not (properties_num_columns > 1) %} - {# MySQL <= 5.5.2 #} - {% set default_engine = dbi.fetchValue('SELECT @@storage_engine;') %} - {% if default_engine is empty %} - {# MySQL >= 5.5.3 #} - {% set default_engine = dbi.fetchValue('SELECT @@default_storage_engine;') %} - {% endif %} + {% if is_show_db_details %} - - {{ default_engine }} + + {{ default_storage_engine }} diff --git a/templates/database/structure/structure_table_row.twig b/templates/database/structure/structure_table_row.twig index 5c56e167df..04896790de 100644 --- a/templates/database/structure/structure_table_row.twig +++ b/templates/database/structure/structure_table_row.twig @@ -114,7 +114,7 @@ {{ show_superscript|raw }} - {% if not (properties_num_columns > 1) %} + {% if is_show_db_details %} {% if current_table['ENGINE'] is not empty %} {{ current_table['ENGINE'] }} diff --git a/templates/database/structure/table_header.twig b/templates/database/structure/table_header.twig index 15c1f71b37..af8ab3a5ac 100644 --- a/templates/database/structure/table_header.twig +++ b/templates/database/structure/table_header.twig @@ -26,7 +26,7 @@ {{ sortable_table_header('Rows'|trans, 'records', 'DESC') }} {{ show_hint('May be approximate. Click on the number to get the exact count. See [doc@faq3-11]FAQ 3.11[/doc].'|trans|sanitize) }} - {% if not (properties_num_columns > 1) %} + {% if is_show_db_details %} {{ sortable_table_header('Type'|trans, 'type') }} {{ sortable_table_header('Collation'|trans, 'collation') }} {% endif %}