diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b553d2f14e..248909dfeb 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -41703,6 +41703,16 @@ parameters: count: 1 path: test/classes/Controllers/Database/StructureControllerTest.php + - + message: "#^Cannot access offset 'ShowDbStructureCrea…' on mixed\\.$#" + count: 1 + path: test/classes/Controllers/Database/StructureControllerTest.php + + - + message: "#^Cannot access offset 'ShowDbStructureLast…' on mixed\\.$#" + count: 2 + path: test/classes/Controllers/Database/StructureControllerTest.php + - message: "#^Cannot access offset 'ShowStats' on mixed\\.$#" count: 1 @@ -41733,16 +41743,6 @@ parameters: count: 1 path: test/classes/Controllers/Database/StructureControllerTest.php - - - message: "#^Parameter \\#2 \\$haystack of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringContainsString\\(\\) expects string, mixed given\\.$#" - count: 4 - path: test/classes/Controllers/Database/StructureControllerTest.php - - - - message: "#^Parameter \\#2 \\$haystack of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertStringNotContainsString\\(\\) expects string, mixed given\\.$#" - count: 1 - path: test/classes/Controllers/Database/StructureControllerTest.php - - message: "#^Parameter \\#3 \\$db of class PhpMyAdmin\\\\Controllers\\\\Database\\\\StructureController constructor expects string, mixed given\\.$#" count: 8 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 1206739719..b50a63a55a 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -14641,10 +14641,8 @@ - + $currentTable - $result - $result $currentTable @@ -14676,9 +14674,7 @@ $currentTable['ENGINE'] $currentTable['ENGINE'] - - $result - $result + [$currentTable, , , $sumSize] [$currentTable, , , $sumSize] [$currentTable, , , $sumSize] diff --git a/templates/database/structure/body_for_table_summary.twig b/templates/database/structure/body_for_table_summary.twig index 0d354bc86b..5470581118 100644 --- a/templates/database/structure/body_for_table_summary.twig +++ b/templates/database/structure/body_for_table_summary.twig @@ -69,19 +69,13 @@ {% endif %} {% if show_creation %} - - {{ create_time_all }} - + {{ create_time_all }} {% endif %} {% if show_last_update %} - - {{ update_time_all }} - + {{ update_time_all }} {% endif %} {% if show_last_check %} - - {{ check_time_all }} - + {{ check_time_all }} {% endif %} diff --git a/test/classes/Controllers/Database/StructureControllerTest.php b/test/classes/Controllers/Database/StructureControllerTest.php index edea2a1452..b36a135ee7 100644 --- a/test/classes/Controllers/Database/StructureControllerTest.php +++ b/test/classes/Controllers/Database/StructureControllerTest.php @@ -389,6 +389,10 @@ class StructureControllerTest extends AbstractTestCase */ public function testDisplayTableList(): void { + $GLOBALS['cfg']['ShowDbStructureCreation'] = true; + $GLOBALS['cfg']['ShowDbStructureLastUpdate'] = true; + $GLOBALS['cfg']['ShowDbStructureLastCheck'] = true; + $class = new ReflectionClass(StructureController::class); $method = $class->getMethod('displayTableList'); if (PHP_VERSION_ID < 80100) { @@ -425,34 +429,59 @@ class StructureControllerTest extends AbstractTestCase $numTables->setAccessible(true); } - $numTables->setValue($controller, 1); + $_REQUEST['db'] = 'my_unique_test_db'; //no tables - $_REQUEST['db'] = 'my_unique_test_db'; + $numTables->setValue($controller, 0); $tablesProperty->setValue($controller, []); + /** @var string $result */ $result = $method->invoke($controller, ['status' => false]); self::assertStringContainsString($_REQUEST['db'], $result); self::assertStringNotContainsString('id="overhead"', $result); //with table - $_REQUEST['db'] = 'my_unique_test_db'; + $tableInfo = [ + 'ENGINE' => 'Maria', + 'TABLE_TYPE' => 'BASE TABLE', + 'TABLE_ROWS' => '0', + 'TABLE_COMMENT' => 'test', + 'Data_length' => '5000', + 'Index_length' => '100', + 'Data_free' => '10000', + ]; $tablesProperty->setValue($controller, [ - [ - 'TABLE_NAME' => 'my_unique_test_db', - 'ENGINE' => 'Maria', - 'TABLE_TYPE' => 'BASE TABLE', - 'TABLE_ROWS' => 0, - 'TABLE_COMMENT' => 'test', - 'Data_length' => 5000, - 'Index_length' => 100, - 'Data_free' => 10000, - ], + 'my_unique_test_table_1' => [ + 'TABLE_NAME' => 'my_unique_test_table_1', + 'Create_time' => '2026-09-04 09:11:00', + 'Update_time' => '2026-09-04 10:11:00', + 'Check_time' => '2026-09-04 11:11:00', + ] + $tableInfo, + 'my_unique_test_table_2' => [ + 'TABLE_NAME' => 'my_unique_test_table_2', + 'Create_time' => '2026-09-04 09:22:00', + 'Update_time' => '2026-09-04 10:22:00', + 'Check_time' => '2026-09-04 11:22:00', + ] + $tableInfo, ]); + $numTables->setValue($controller, 2); + /** @var string $result */ $result = $method->invoke($controller, ['status' => false]); self::assertStringContainsString($_REQUEST['db'], $result); self::assertStringContainsString('id="overhead"', $result); self::assertStringContainsString('9.8', $result); + self::assertStringContainsString( + 'Sep 04, 2026 at 09:11 AM', + $result + ); + self::assertStringContainsString( + 'Sep 04, 2026 at 10:22 AM', + $result + ); + self::assertStringContainsString( + 'Sep 04, 2026 at 11:11 AM', + $result + ); } /**