From 15a83c32af6b0926ee6cfa11f2029c90498bae3a Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 12 May 2023 22:11:22 +0100 Subject: [PATCH 1/6] $db in addNewRelation() Signed-off-by: Kamil Tekiela --- .../Database/DesignerController.php | 1 - .../classes/Database/Designer/Common.php | 2 - phpstan-baseline.neon | 47 +++++++++---------- psalm-baseline.xml | 4 -- 4 files changed, 21 insertions(+), 33 deletions(-) diff --git a/libraries/classes/Controllers/Database/DesignerController.php b/libraries/classes/Controllers/Database/DesignerController.php index c0c01c42c5..d416b010c5 100644 --- a/libraries/classes/Controllers/Database/DesignerController.php +++ b/libraries/classes/Controllers/Database/DesignerController.php @@ -111,7 +111,6 @@ class DesignerController extends AbstractController $this->response->addJSON('message', $GLOBALS['message']); } elseif ($operation === 'addNewRelation') { [$success, $GLOBALS['message']] = $this->designerCommon->addNewRelation( - $db, $request->getParsedBodyParam('T1'), $request->getParsedBodyParam('F1'), $request->getParsedBodyParam('T2'), diff --git a/libraries/classes/Database/Designer/Common.php b/libraries/classes/Database/Designer/Common.php index 384a6d37ad..d192267295 100644 --- a/libraries/classes/Database/Designer/Common.php +++ b/libraries/classes/Database/Designer/Common.php @@ -489,7 +489,6 @@ class Common /** * Adds a new foreign relation * - * @param string $db database name * @param string $t1 foreign table * @param string $f1 foreign field * @param string $t2 master table @@ -503,7 +502,6 @@ class Common * @psalm-return array{0: bool, 1: string} */ public function addNewRelation( - string $db, string $t1, string $f1, string $t2, diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index cc9c7e11c1..1418f2394a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -825,11 +825,6 @@ parameters: count: 1 path: libraries/classes/Controllers/Database/DesignerController.php - - - message: "#^Parameter \\#1 \\$db of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" - count: 1 - path: libraries/classes/Controllers/Database/DesignerController.php - - message: "#^Parameter \\#1 \\$db of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:getDefaultPage\\(\\) expects string, mixed given\\.$#" count: 1 @@ -885,6 +880,11 @@ parameters: count: 1 path: libraries/classes/Controllers/Database/DesignerController.php + - + message: "#^Parameter \\#1 \\$t1 of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" + count: 1 + path: libraries/classes/Controllers/Database/DesignerController.php + - message: "#^Parameter \\#1 \\$t1 of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:removeRelation\\(\\) expects string, mixed given\\.$#" count: 1 @@ -895,6 +895,11 @@ parameters: count: 1 path: libraries/classes/Controllers/Database/DesignerController.php + - + message: "#^Parameter \\#2 \\$f1 of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" + count: 1 + path: libraries/classes/Controllers/Database/DesignerController.php + - message: "#^Parameter \\#2 \\$f1 of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:removeRelation\\(\\) expects string, mixed given\\.$#" count: 1 @@ -910,11 +915,6 @@ parameters: count: 1 path: libraries/classes/Controllers/Database/DesignerController.php - - - message: "#^Parameter \\#2 \\$t1 of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" - count: 1 - path: libraries/classes/Controllers/Database/DesignerController.php - - message: "#^Parameter \\#2 \\$table of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:getTablesInfo\\(\\) expects string\\|null, mixed given\\.$#" count: 2 @@ -931,12 +931,12 @@ parameters: path: libraries/classes/Controllers/Database/DesignerController.php - - message: "#^Parameter \\#3 \\$f1 of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#3 \\$field of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:saveDisplayField\\(\\) expects string, mixed given\\.$#" count: 1 path: libraries/classes/Controllers/Database/DesignerController.php - - message: "#^Parameter \\#3 \\$field of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:saveDisplayField\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#3 \\$t2 of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" count: 1 path: libraries/classes/Controllers/Database/DesignerController.php @@ -945,38 +945,33 @@ parameters: count: 1 path: libraries/classes/Controllers/Database/DesignerController.php + - + message: "#^Parameter \\#4 \\$f2 of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" + count: 1 + path: libraries/classes/Controllers/Database/DesignerController.php + - message: "#^Parameter \\#4 \\$f2 of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:removeRelation\\(\\) expects string, mixed given\\.$#" count: 1 path: libraries/classes/Controllers/Database/DesignerController.php - - message: "#^Parameter \\#4 \\$t2 of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#5 \\$onDelete of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" count: 1 path: libraries/classes/Controllers/Database/DesignerController.php - - message: "#^Parameter \\#5 \\$f2 of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#6 \\$onUpdate of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" count: 1 path: libraries/classes/Controllers/Database/DesignerController.php - - message: "#^Parameter \\#6 \\$onDelete of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#7 \\$db1 of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" count: 1 path: libraries/classes/Controllers/Database/DesignerController.php - - message: "#^Parameter \\#7 \\$onUpdate of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" - count: 1 - path: libraries/classes/Controllers/Database/DesignerController.php - - - - message: "#^Parameter \\#8 \\$db1 of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" - count: 1 - path: libraries/classes/Controllers/Database/DesignerController.php - - - - message: "#^Parameter \\#9 \\$db2 of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#8 \\$db2 of method PhpMyAdmin\\\\Database\\\\Designer\\\\Common\\:\\:addNewRelation\\(\\) expects string, mixed given\\.$#" count: 1 path: libraries/classes/Controllers/Database/DesignerController.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 07dc380b56..9c46f8adf4 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -996,7 +996,6 @@ $db $db $db - $db $html $page @@ -5143,9 +5142,6 @@ $indexArray1 $indexArray2 - - $db - From 3a5f6c924d9d5e25935e483d42cdeac2952c0178 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 12 May 2023 22:14:26 +0100 Subject: [PATCH 2/6] getTableDef in ExportHtmlword Signed-off-by: Kamil Tekiela --- libraries/classes/Plugins/Export/ExportHtmlword.php | 6 ++---- psalm-baseline.xml | 3 --- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/libraries/classes/Plugins/Export/ExportHtmlword.php b/libraries/classes/Plugins/Export/ExportHtmlword.php index d0dd231329..27ef29f524 100644 --- a/libraries/classes/Plugins/Export/ExportHtmlword.php +++ b/libraries/classes/Plugins/Export/ExportHtmlword.php @@ -317,7 +317,6 @@ class ExportHtmlword extends ExportPlugin * export types which use this parameter * @param bool $doMime whether to include mime comments * at the end - * @param bool $view whether we're handling a view * @param mixed[] $aliases Aliases of db/table/columns * * @return string resulting schema @@ -328,7 +327,6 @@ class ExportHtmlword extends ExportPlugin bool $doRelation, bool $doComments, bool $doMime, - bool $view = false, array $aliases = [], ): string { $relationParameters = $this->relation->getRelationParameters(); @@ -532,7 +530,7 @@ class ExportHtmlword extends ExportPlugin . __('Table structure for table') . ' ' . htmlspecialchars($tableAlias) . ''; - $dump .= $this->getTableDef($db, $table, $doRelation, $doComments, $doMime, false, $aliases); + $dump .= $this->getTableDef($db, $table, $doRelation, $doComments, $doMime, $aliases); break; case 'triggers': $triggers = Triggers::getDetails($GLOBALS['dbi'], $db, $table); @@ -548,7 +546,7 @@ class ExportHtmlword extends ExportPlugin $dump .= '

' . __('Structure for view') . ' ' . htmlspecialchars($tableAlias) . '

'; - $dump .= $this->getTableDef($db, $table, $doRelation, $doComments, $doMime, true, $aliases); + $dump .= $this->getTableDef($db, $table, $doRelation, $doComments, $doMime, $aliases); break; case 'stand_in': $dump .= '

' diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 9c46f8adf4..596412652a 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -9210,9 +9210,6 @@ $comments $mimeMap - - $view - bool From 99426f4d23c86df2ce860925a81023bd99fe27d6 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 12 May 2023 22:15:49 +0100 Subject: [PATCH 3/6] getTableDef in ExportOdt Signed-off-by: Kamil Tekiela --- .../classes/Plugins/Export/ExportOdt.php | 56 +++++-------------- psalm-baseline.xml | 6 -- test/classes/Plugins/Export/ExportOdtTest.php | 2 - 3 files changed, 13 insertions(+), 51 deletions(-) diff --git a/libraries/classes/Plugins/Export/ExportOdt.php b/libraries/classes/Plugins/Export/ExportOdt.php index cc3c0d495c..4a0174c648 100644 --- a/libraries/classes/Plugins/Export/ExportOdt.php +++ b/libraries/classes/Plugins/Export/ExportOdt.php @@ -387,32 +387,24 @@ class ExportOdt extends ExportPlugin /** * Returns $table's CREATE definition * - * @param string $db the database name - * @param string $table the table name - * @param string $errorUrl the url to go back in case of error - * @param bool $doRelation whether to include relation comments - * @param bool $doComments whether to include the pmadb-style column - * comments as comments in the structure; - * this is deprecated but the parameter is - * left here because /export calls - * PMA_exportStructure() also for other - * @param bool $doMime whether to include mime comments - * @param bool $showDates whether to include creation/update/check dates - * @param bool $addSemicolon whether to add semicolon and end-of-line at - * the end - * @param bool $view whether we're handling a view - * @param mixed[] $aliases Aliases of db/table/columns + * @param string $db the database name + * @param string $table the table name + * @param bool $doRelation whether to include relation comments + * @param bool $doComments whether to include the pmadb-style column + * comments as comments in the structure; + * this is deprecated but the parameter is + * left here because /export calls + * PMA_exportStructure() also for other + * @param bool $doMime whether to include mime comments + * the end + * @param mixed[] $aliases Aliases of db/table/columns */ public function getTableDef( string $db, string $table, - string $errorUrl, bool $doRelation, bool $doComments, bool $doMime, - bool $showDates = false, - bool $addSemicolon = true, - bool $view = false, array $aliases = [], ): bool { $dbAlias = $db; @@ -660,18 +652,7 @@ class ExportOdt extends ExportPlugin . __('Table structure for table') . ' ' . htmlspecialchars($tableAlias) . ''; - $this->getTableDef( - $db, - $table, - $errorUrl, - $doRelation, - $doComments, - $doMime, - $dates, - true, - false, - $aliases, - ); + $this->getTableDef($db, $table, $doRelation, $doComments, $doMime, $aliases); break; case 'triggers': $triggers = Triggers::getDetails($GLOBALS['dbi'], $db, $table); @@ -691,18 +672,7 @@ class ExportOdt extends ExportPlugin . __('Structure for view') . ' ' . htmlspecialchars($tableAlias) . ''; - $this->getTableDef( - $db, - $table, - $errorUrl, - $doRelation, - $doComments, - $doMime, - $dates, - true, - true, - $aliases, - ); + $this->getTableDef($db, $table, $doRelation, $doComments, $doMime, $aliases); break; case 'stand_in': $GLOBALS['odt_buffer'] .= ' - - $addSemicolon - $errorUrl - $showDates - $view - string diff --git a/test/classes/Plugins/Export/ExportOdtTest.php b/test/classes/Plugins/Export/ExportOdtTest.php index 91ec902d24..86a1634b4d 100644 --- a/test/classes/Plugins/Export/ExportOdtTest.php +++ b/test/classes/Plugins/Export/ExportOdtTest.php @@ -632,7 +632,6 @@ class ExportOdtTest extends AbstractTestCase $this->object->getTableDef( 'database', '', - 'example.com', true, true, true, @@ -715,7 +714,6 @@ class ExportOdtTest extends AbstractTestCase $this->object->getTableDef( 'database', '', - 'example.com', true, true, true, From 9f9bf09ea9c19112d79317d32c7b00ab654bc3c6 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 12 May 2023 22:16:34 +0100 Subject: [PATCH 4/6] getTableDef in ExportTexytext Signed-off-by: Kamil Tekiela --- .../classes/Plugins/Export/ExportTexytext.php | 58 +++++-------------- psalm-baseline.xml | 6 -- .../Plugins/Export/ExportTexytextTest.php | 2 +- 3 files changed, 15 insertions(+), 51 deletions(-) diff --git a/libraries/classes/Plugins/Export/ExportTexytext.php b/libraries/classes/Plugins/Export/ExportTexytext.php index ad6605b283..a2f8b69e1e 100644 --- a/libraries/classes/Plugins/Export/ExportTexytext.php +++ b/libraries/classes/Plugins/Export/ExportTexytext.php @@ -305,35 +305,27 @@ class ExportTexytext extends ExportPlugin /** * Returns $table's CREATE definition * - * @param string $db the database name - * @param string $table the table name - * @param string $errorUrl the url to go back in case of error - * @param bool $doRelation whether to include relation comments - * @param bool $doComments whether to include the pmadb-style column - * comments as comments in the structure; - * this is deprecated but the parameter is - * left here because /export calls - * $this->exportStructure() also for other - * export types which use this parameter - * @param bool $doMime whether to include mime comments - * @param bool $showDates whether to include creation/update/check dates - * @param bool $addSemicolon whether to add semicolon and end-of-line - * at the end - * @param bool $view whether we're handling a view - * @param mixed[] $aliases Aliases of db/table/columns + * @param string $db the database name + * @param string $table the table name + * @param bool $doRelation whether to include relation comments + * @param bool $doComments whether to include the pmadb-style column + * comments as comments in the structure; + * this is deprecated but the parameter is + * left here because /export calls + * $this->exportStructure() also for other + * export types which use this parameter + * @param bool $doMime whether to include mime comments + * at the end + * @param mixed[] $aliases Aliases of db/table/columns * * @return string resulting schema */ public function getTableDef( string $db, string $table, - string $errorUrl, bool $doRelation, bool $doComments, bool $doMime, - bool $showDates = false, - bool $addSemicolon = true, - bool $view = false, array $aliases = [], ): string { $relationParameters = $this->relation->getRelationParameters(); @@ -503,18 +495,7 @@ class ExportTexytext extends ExportPlugin case 'create_table': $dump .= '== ' . __('Table structure for table') . ' ' . $tableAlias . "\n\n"; - $dump .= $this->getTableDef( - $db, - $table, - $errorUrl, - $doRelation, - $doComments, - $doMime, - $dates, - true, - false, - $aliases, - ); + $dump .= $this->getTableDef($db, $table, $doRelation, $doComments, $doMime, $aliases); break; case 'triggers': $triggers = Triggers::getDetails($GLOBALS['dbi'], $db, $table); @@ -526,18 +507,7 @@ class ExportTexytext extends ExportPlugin break; case 'create_view': $dump .= '== ' . __('Structure for view') . ' ' . $tableAlias . "\n\n"; - $dump .= $this->getTableDef( - $db, - $table, - $errorUrl, - $doRelation, - $doComments, - $doMime, - $dates, - true, - true, - $aliases, - ); + $dump .= $this->getTableDef($db, $table, $doRelation, $doComments, $doMime, $aliases); break; case 'stand_in': $dump .= '== ' . __('Stand-in structure for view') diff --git a/psalm-baseline.xml b/psalm-baseline.xml index d4a1941072..80400fa342 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -9735,12 +9735,6 @@ $comments $mimeMap - - $addSemicolon - $errorUrl - $showDates - $view - diff --git a/test/classes/Plugins/Export/ExportTexytextTest.php b/test/classes/Plugins/Export/ExportTexytextTest.php index 450c23905c..11b0e2942f 100644 --- a/test/classes/Plugins/Export/ExportTexytextTest.php +++ b/test/classes/Plugins/Export/ExportTexytextTest.php @@ -310,7 +310,7 @@ class ExportTexytextTest extends AbstractTestCase [$GLOBALS['server'] => $relationParameters], ); - $result = $this->object->getTableDef('db', 'table', 'example.com', true, true, true); + $result = $this->object->getTableDef('db', 'table', true, true, true); $this->assertStringContainsString('1|<ftable (ffield>)|comm|Test<', $result); } From d3701b52cf03d6846fe32313f312c1caa22c5688 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 12 May 2023 22:17:18 +0100 Subject: [PATCH 5/6] getTableDef in Pdf Signed-off-by: Kamil Tekiela --- .../classes/Plugins/Export/ExportPdf.php | 4 ++-- .../classes/Plugins/Export/Helpers/Pdf.php | 24 ++++++++----------- psalm-baseline.xml | 4 ---- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/libraries/classes/Plugins/Export/ExportPdf.php b/libraries/classes/Plugins/Export/ExportPdf.php index 6d5aa1bc5a..6b47b0924d 100644 --- a/libraries/classes/Plugins/Export/ExportPdf.php +++ b/libraries/classes/Plugins/Export/ExportPdf.php @@ -272,13 +272,13 @@ class ExportPdf extends ExportPlugin */ switch ($exportMode) { case 'create_table': - $pdf->getTableDef($db, $table, $doRelation, true, $doMime, false, $aliases); + $pdf->getTableDef($db, $table, $doRelation, true, $doMime); break; case 'triggers': $pdf->getTriggers($db, $table); break; case 'create_view': - $pdf->getTableDef($db, $table, $doRelation, true, $doMime, false, $aliases); + $pdf->getTableDef($db, $table, $doRelation, true, $doMime); break; case 'stand_in': // export a stand-in definition to resolve view dependencies diff --git a/libraries/classes/Plugins/Export/Helpers/Pdf.php b/libraries/classes/Plugins/Export/Helpers/Pdf.php index 3fb67a40cf..3f8dad6824 100644 --- a/libraries/classes/Plugins/Export/Helpers/Pdf.php +++ b/libraries/classes/Plugins/Export/Helpers/Pdf.php @@ -431,18 +431,16 @@ class Pdf extends PdfLib /** * Print $table's CREATE definition * - * @param string $db the database name - * @param string $table the table name - * @param bool $doRelation whether to include relation comments - * @param bool $doComments whether to include the pmadb-style column - * comments as comments in the structure; - * this is deprecated but the parameter is - * left here because /export calls - * PMA_exportStructure() also for other - * export types which use this parameter - * @param bool $doMime whether to include mime comments - * @param bool $view whether we're handling a view - * @param mixed[] $aliases aliases of db/table/columns + * @param string $db the database name + * @param string $table the table name + * @param bool $doRelation whether to include relation comments + * @param bool $doComments whether to include the pmadb-style column + * comments as comments in the structure; + * this is deprecated but the parameter is + * left here because /export calls + * PMA_exportStructure() also for other + * export types which use this parameter + * @param bool $doMime whether to include mime comments */ public function getTableDef( string $db, @@ -450,8 +448,6 @@ class Pdf extends PdfLib bool $doRelation, bool $doComments, bool $doMime, - bool $view = false, - array $aliases = [], ): void { $relationParameters = $this->relation->getRelationParameters(); diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 80400fa342..d8755312f5 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -10089,10 +10089,6 @@ $resRel $resRel - - $aliases - $view - $results Pdf From 90b5312efa3dc47f819546a85affffce1beaedda Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Fri, 12 May 2023 22:20:42 +0100 Subject: [PATCH 6/6] createFile in ZipExtension Signed-off-by: Kamil Tekiela --- libraries/classes/ZipExtension.php | 3 +-- psalm-baseline.xml | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/libraries/classes/ZipExtension.php b/libraries/classes/ZipExtension.php index 7303ac1746..6c7880a70e 100644 --- a/libraries/classes/ZipExtension.php +++ b/libraries/classes/ZipExtension.php @@ -197,11 +197,10 @@ class ZipExtension * * @param mixed[]|string $data contents of the file/files * @param mixed[]|string $name name of the file/files in the archive - * @param int $time the current timestamp * * @return string|false the ZIP file contents, or false if there was an error. */ - public function createFile(array|string $data, array|string $name, int $time = 0): string|false + public function createFile(array|string $data, array|string $name): string|false { $datasec = []; // Array to store compressed data $ctrlDir = []; // Central directory diff --git a/psalm-baseline.xml b/psalm-baseline.xml index d8755312f5..cc602bd714 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -13830,9 +13830,6 @@ $newData[$newName] $value - - $time -