From c3266c2c52f65ad3c87a8ea88ab09393d90838ee Mon Sep 17 00:00:00 2001 From: Liviu-Mihail Concioiu Date: Wed, 30 Apr 2025 19:23:30 +0200 Subject: [PATCH 1/5] Prevent ol.css being added multiple times Signed-off-by: Liviu-Mihail Concioiu --- libraries/classes/Gis/GisVisualization.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/classes/Gis/GisVisualization.php b/libraries/classes/Gis/GisVisualization.php index 8bdcae4e2b..92bd7b5fd6 100644 --- a/libraries/classes/Gis/GisVisualization.php +++ b/libraries/classes/Gis/GisVisualization.php @@ -434,7 +434,13 @@ class GisVisualization $output = 'function drawOpenLayers() {' . 'if (typeof ol !== "undefined") {' . 'var olCss = "js/vendor/openlayers/theme/ol.css";' - . '$(\'head\').append(\'\');' + . 'if (!document.querySelector(\'link[rel="stylesheet"][href="\' + olCss + \'"]\')) {' + . 'var link = document.createElement(\'link\');' + . 'link.rel = \'stylesheet\';' + . 'link.type = \'text/css\';' + . 'link.href = olCss;' + . 'document.head.appendChild(link);' + . '}' . 'var vectorLayer = new ol.source.Vector({});' . 'var map = new ol.Map({' . 'target: \'openlayersmap\',' From 0ffd9385ea290c3b349c7286f1d908c2ed838310 Mon Sep 17 00:00:00 2001 From: M393 Date: Wed, 30 Apr 2025 12:30:55 +0200 Subject: [PATCH 2/5] Translated using Weblate (German) Currently translated at 100.0% (3428 of 3428 strings) [ci skip] Translation: phpMyAdmin/5.2 Translate-URL: https://hosted.weblate.org/projects/phpmyadmin/5-2/de/ Signed-off-by: M393 --- po/de.po | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/po/de.po b/po/de.po index 53166866f9..2a0728bbc1 100644 --- a/po/de.po +++ b/po/de.po @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: phpMyAdmin-docs 4.0.0-dev\n" "Report-Msgid-Bugs-To: translators@phpmyadmin.net\n" "POT-Creation-Date: 2025-02-27 14:25-0300\n" -"PO-Revision-Date: 2025-02-13 15:02+0000\n" +"PO-Revision-Date: 2025-05-01 11:02+0000\n" "Last-Translator: M393 \n" "Language-Team: German \n" @@ -13,7 +13,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 5.10-dev\n" +"X-Generator: Weblate 5.12-dev\n" #: libraries/advisory_rules_generic.php:9 msgid "Uptime below one day" @@ -1088,16 +1088,17 @@ msgid "" "innodb_buffer_pool_size/\">this article" msgstr "" "Der InnoDB-Pufferpool hat tiefgreifende Auswirkungen auf die Leistung für " -"InnoDB-Tabellen. Weisen Sie dieser Puffer alle Ihren verbleibenden " -"Arbeitsspeicher zuweisen. Für Datenbankserver, die ausschließlich InnoDB " -"Tabellen als Speicher verwenden und keine anderen Dienste (z. B. ein " -"Webserver) ausgeführt, können Sie diesen auf bis zu 80% Ihres verfügbaren " -"Speichers festlegen. Wenn dieses nicht der Fall ist, müssen Sie sorgfältig " -"den Speicherverbrauch von anderen Diensten und nicht-InnoDB-Tabellen " -"bewerten und stellen Sie diese Variable entsprechend ein. Wenn der Wert zu " -"hoch ist, startet Ihr System Speicher auf die Festplatte auszulagern, was " -"die Leistung erheblich senkt. Siehe auch diesen Artikel" +"InnoDB-Tabellen. Weisen Sie diesem Puffer den gesamten verbleibenden " +"Arbeitsspeicher zu. Für Datenbankserver, die ausschließlich InnoDB Tabellen " +"als Speicher verwenden und keine anderen Dienste (z. B. ein Webserver) " +"ausgeführt, können Sie diesen auf bis zu 80% Ihres verfügbaren Speichers " +"festlegen. Wenn dies nicht der Fall ist, müssen Sie sorgfältig den " +"Speicherverbrauch von anderen Diensten und nicht-InnoDB-Tabellen bewerten " +"und diese Variable entsprechend einstellen. Wenn der Wert zu hoch ist, " +"beginnt Ihr System Speicher auf die Festplatte auszulagern, was die Leistung " +"erheblich senkt. Siehe auch diesen Artikel" #: libraries/advisory_rules_generic.php:697 #, php-format @@ -1321,14 +1322,14 @@ msgid "" "(often invalidated due to table updates) increasing {query_cache_limit} " "might reduce efficiency." msgstr "" -"Verändern von {query_cache_limit} (in der Regel durch erhöhen) kann die " +"Verändern von {query_cache_limit} (in der Regel durch Erhöhen) kann die " "Effizienz steigern. Diese Variable bestimmt die maximale Größe eines " "Abfrageergebnis, das in den Abfrage-Cache eingefügt werden soll. Wenn es " "viele Abfrageergebnisse über 1 MiB gibt die sich auch zwischenspeichern " -"lassen (viele Lesevorgänge, wenig schreibt) dann kann ein erhöhen von " -"{query_cache_limit} die Effizienz erhöhen. Während bei viele " -"Abfrageergebnisse über 1 MiB die nicht sehr gut zwischenspeicherbar sind " -"(oft aufgrund von Aktualisierungen der Tabelle ungültig) ein Erhöhen von " +"lassen (viele Lesevorgänge, wenig schreiben), dann kann ein Erhöhen von " +"{query_cache_limit} die Effizienz steigern. Während bei vielen " +"Abfrageergebnissen über 1 MiB, die nicht gut zwischenspeicherbar sind (oft " +"aufgrund von Aktualisierungen der Tabelle ungültig geworden) ein Erhöhen von " "{query_cache_limit} die Effizienz reduzieren kann." #: libraries/advisory_rules_mysql_before80003.php:120 From c70a77d47dd67e29e14fd089511fcc1308b9eeb3 Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Sun, 4 May 2025 10:41:24 +0200 Subject: [PATCH 3/5] Translated using Weblate (Hebrew) Currently translated at 46.3% (1590 of 3428 strings) [ci skip] Translation: phpMyAdmin/5.2 Translate-URL: https://hosted.weblate.org/projects/phpmyadmin/5-2/he/ Signed-off-by: Yaron Shahrabani --- po/he.po | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/po/he.po b/po/he.po index 07d7c4a505..3a10a4fc72 100644 --- a/po/he.po +++ b/po/he.po @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: phpMyAdmin 5.2.3-dev\n" "Report-Msgid-Bugs-To: translators@phpmyadmin.net\n" "POT-Creation-Date: 2025-02-27 14:25-0300\n" -"PO-Revision-Date: 2025-04-13 22:07+0000\n" +"PO-Revision-Date: 2025-05-04 17:35+0000\n" "Last-Translator: Yaron Shahrabani \n" "Language-Team: Hebrew \n" @@ -13,7 +13,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Weblate 5.11-dev\n" +"X-Generator: Weblate 5.12-dev\n" #: libraries/advisory_rules_generic.php:9 msgid "Uptime below one day" @@ -588,15 +588,11 @@ msgid "Percentage of used open files limit" msgstr "אחוז מגבלת הקבצים הפתוחים שנוצל" #: libraries/advisory_rules_generic.php:433 -#, fuzzy -#| msgid "" -#| "The number of open files is approaching the max number of open files. " -#| "You may get a \"Too many open files\" error." msgid "" "The number of open files is approaching the max number of open files. You " "may get a \"Too many open files\" error." msgstr "" -"מספר הקבצים הפתוחים מגיע לסף המרבי של קבצים פתוחים. יתכן ותתקבל שגיאת „יותר " +"מספר הקבצים הפתוחים מגיע לסף המרבי של קבצים פתוחים. אולי תתקבל שגיאת „יותר " "מדי קבצים פתוחים”." #: libraries/advisory_rules_generic.php:437 @@ -10791,10 +10787,8 @@ msgid "" msgstr "" #: libraries/classes/Plugins/Import/ImportLdi.php:62 -#, fuzzy -#| msgid "Column names" msgid "Column names: " -msgstr "שמות עמודה" +msgstr "שמות עמודות: " #: libraries/classes/Plugins/Import/ImportLdi.php:106 msgid "This plugin does not support compressed imports!" @@ -12963,10 +12957,8 @@ msgstr "" #: templates/table/relation/common_form.twig:233 #: templates/table/zoom_search/result_form.twig:26 #: templates/table/zoom_search/result_form.twig:97 -#, fuzzy -#| msgid "Loading…" msgid "Loading" -msgstr "בטעינה…" +msgstr "בטעינה" #: templates/columns_definitions/column_name.twig:4 #, php-format @@ -14398,13 +14390,11 @@ msgid "Inside column:" msgstr "בתוך העמודה:" #: templates/database/search/results.twig:12 -#, fuzzy, php-format -#| msgid "%1$s match inside table %2$s" -#| msgid_plural "%1$s matches inside table %2$s" +#, php-format msgid "%1$s match in %2$s" msgid_plural "%1$s matches in %2$s" -msgstr[0] "תוצאה אחת (%1$s) בטבלה %2$s" -msgstr[1] "%1$s תוצאות בטבלה %2$s" +msgstr[0] "תוצאה אחת (%1$s) בטבלה %2$s" +msgstr[1] "%1$s תוצאות בטבלה %2$s" #: templates/database/search/results.twig:56 msgid "Total: %count% match" @@ -16069,10 +16059,8 @@ msgid "phpMyAdmin configuration storage" msgstr "תיעוד phpMyAdmin" #: templates/relation/check_relations.twig:9 -#, fuzzy -#| msgid "Modifications have been saved" msgid "Configuration of pmadb…" -msgstr "שינויים נשמרו" +msgstr "תצורה של pmadb…" #: templates/relation/check_relations.twig:10 #: templates/relation/check_relations.twig:56 @@ -18090,10 +18078,8 @@ msgid "Use the NULL value for this column." msgstr "ערך עבור העמודה „%s“" #: templates/table/insert/column_row.twig:65 -#, fuzzy -#| msgid "Because of its length,
this field might not be editable " msgid "Because of its length,
this column might not be editable." -msgstr "משום אורכם,
השדה הזה יכול להיות בלתי עריך " +msgstr "עקב אורכה,
העמודה הזאת עלולה להיות נעולה לעריכה." #: templates/table/insert/column_row.twig:93 msgid "Binary - do not edit" From 80c5cf7a0b741c71c9cd92490897388b44ed3bd1 Mon Sep 17 00:00:00 2001 From: ClearanceClarence Date: Fri, 9 May 2025 07:50:02 +0200 Subject: [PATCH 4/5] =?UTF-8?q?Translated=20using=20Weblate=20(Norwegian?= =?UTF-8?q?=20Bokm=C3=A5l)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently translated at 59.7% (2048 of 3428 strings) [ci skip] Translation: phpMyAdmin/5.2 Translate-URL: https://hosted.weblate.org/projects/phpmyadmin/5-2/nb_NO/ Signed-off-by: ClearanceClarence --- po/nb.po | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/po/nb.po b/po/nb.po index 36e12506ee..3659c31e43 100644 --- a/po/nb.po +++ b/po/nb.po @@ -4,8 +4,8 @@ msgstr "" "Project-Id-Version: phpMyAdmin 5.2.3-dev\n" "Report-Msgid-Bugs-To: translators@phpmyadmin.net\n" "POT-Creation-Date: 2025-02-27 14:25-0300\n" -"PO-Revision-Date: 2022-02-17 10:35+0000\n" -"Last-Translator: Maurício Meneghini Fauth \n" +"PO-Revision-Date: 2025-05-10 06:01+0000\n" +"Last-Translator: ClearanceClarence \n" "Language-Team: Norwegian Bokmål \n" "Language: nb\n" @@ -13,7 +13,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.11-dev\n" +"X-Generator: Weblate 5.12-dev\n" #: libraries/advisory_rules_generic.php:9 msgid "Uptime below one day" @@ -37,10 +37,8 @@ msgid "The uptime is only %s" msgstr "Oppetid er bare %s" #: libraries/advisory_rules_generic.php:22 -#, fuzzy -#| msgid "Versions" msgid "Questions below 1,000" -msgstr "Versjoner" +msgstr "Spørsmål under 1 000" #: libraries/advisory_rules_generic.php:26 msgid "" @@ -58,16 +56,13 @@ msgstr "" "La serveren kjøre i lengre tid til den har utført en større mengde spørsmål." #: libraries/advisory_rules_generic.php:32 -#, fuzzy, php-format -#| msgid "Current connection" +#, php-format msgid "Current amount of Questions: %s" -msgstr "Nåværende tilkobling" +msgstr "Nåværende antall spørsmål: %s" #: libraries/advisory_rules_generic.php:37 -#, fuzzy -#| msgid "Show SQL queries" msgid "Percentage of slow queries" -msgstr "Vis SQL spørringer" +msgstr "Prosentandel av trege spørringer" #: libraries/advisory_rules_generic.php:41 msgid "" @@ -91,10 +86,8 @@ msgid "The slow query rate should be below 5%%, your value is %s%%." msgstr "Den sakte spørringsgraden bør være under 5%%, verdien din er %s%%." #: libraries/advisory_rules_generic.php:50 -#, fuzzy -#| msgid "Flush query cache" msgid "Slow query rate" -msgstr "Flush query cache" +msgstr "Langsom spørringsfrekvens" #: libraries/advisory_rules_generic.php:54 msgid "" @@ -112,10 +105,8 @@ msgstr "" "per time." #: libraries/advisory_rules_generic.php:63 -#, fuzzy -#| msgid "SQL queries" msgid "Long query time" -msgstr "SQL spørringer" +msgstr "Lang spørringstid" #: libraries/advisory_rules_generic.php:67 msgid "" From 65268af43e62aada8517477800c0e1f3e9724efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 10 May 2025 14:17:58 -0300 Subject: [PATCH 5/5] Fix TwigLintCommandTest failing test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Command/TwigLintCommand.php | 5 +- phpstan-baseline.neon | 30 ---------- psalm-baseline.xml | 12 ++-- test/classes/Command/TwigLintCommandTest.php | 57 ++++--------------- .../templates/lint_command/foo-invalid.twig | 1 + .../templates/lint_command/foo-valid.twig | 1 + 6 files changed, 24 insertions(+), 82 deletions(-) create mode 100644 test/classes/_data/templates/lint_command/foo-invalid.twig create mode 100644 test/classes/_data/templates/lint_command/foo-valid.twig diff --git a/libraries/classes/Command/TwigLintCommand.php b/libraries/classes/Command/TwigLintCommand.php index 876d352376..1bfbba7eab 100644 --- a/libraries/classes/Command/TwigLintCommand.php +++ b/libraries/classes/Command/TwigLintCommand.php @@ -73,6 +73,7 @@ class TwigLintCommand extends Command ->addOption('show-deprecations', null, InputOption::VALUE_NONE, 'Show deprecations as errors'); } + /** @return string[] */ protected function findFiles(string $baseFolder): array { /* Open the handle */ @@ -141,7 +142,8 @@ class TwigLintCommand extends Command return $this->display($output, $io, $filesInfo); } - protected function getFilesInfo(string $templatesPath): array + /** @return array{template: string, file: string, valid: bool, line?: int, exception?: Error}[] */ + public function getFilesInfo(string $templatesPath): array { $filesInfo = []; $filesFound = $this->findFiles($templatesPath); @@ -160,6 +162,7 @@ class TwigLintCommand extends Command return (string) file_get_contents($filePath); } + /** @return array{template: string, file: string, valid: bool, line?: int, exception?: Error} */ private function validate(string $template, string $file): array { $twig = Template::getTwigEnvironment(null); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 34046cb150..b5771ef4fc 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -700,26 +700,11 @@ parameters: count: 1 path: libraries/classes/Command/TwigLintCommand.php - - - message: "#^Method PhpMyAdmin\\\\Command\\\\TwigLintCommand\\:\\:findFiles\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: libraries/classes/Command/TwigLintCommand.php - - message: "#^Method PhpMyAdmin\\\\Command\\\\TwigLintCommand\\:\\:getContext\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: libraries/classes/Command/TwigLintCommand.php - - - message: "#^Method PhpMyAdmin\\\\Command\\\\TwigLintCommand\\:\\:getFilesInfo\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: libraries/classes/Command/TwigLintCommand.php - - - - message: "#^Method PhpMyAdmin\\\\Command\\\\TwigLintCommand\\:\\:validate\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: libraries/classes/Command/TwigLintCommand.php - - message: "#^Only booleans are allowed in a ternary operator condition, \\(callable\\)\\|null given\\.$#" count: 1 @@ -745,16 +730,6 @@ parameters: count: 1 path: libraries/classes/Command/TwigLintCommand.php - - - message: "#^Parameter \\#1 \\$filePath of method PhpMyAdmin\\\\Command\\\\TwigLintCommand\\:\\:getTemplateContents\\(\\) expects string, mixed given\\.$#" - count: 1 - path: libraries/classes/Command/TwigLintCommand.php - - - - message: "#^Parameter \\#2 \\$file of method PhpMyAdmin\\\\Command\\\\TwigLintCommand\\:\\:validate\\(\\) expects string, mixed given\\.$#" - count: 1 - path: libraries/classes/Command/TwigLintCommand.php - - message: "#^Parameter \\#2 \\$template of method PhpMyAdmin\\\\Command\\\\TwigLintCommand\\:\\:renderException\\(\\) expects string, mixed given\\.$#" count: 1 @@ -40975,11 +40950,6 @@ parameters: count: 1 path: test/classes/Command/TwigLintCommandTest.php - - - message: "#^Dynamic call to static method PHPUnit\\\\Framework\\\\TestCase\\:\\:exactly\\(\\)\\.$#" - count: 2 - path: test/classes/Command/TwigLintCommandTest.php - - message: "#^Parameter \\#1 \\$array_arg of function sort expects TArray of array\\, mixed given\\.$#" count: 2 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 3e80ea15d9..d23a3a84c5 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -233,9 +233,8 @@ - + $code - $file $info['exception'] $info['file'] $info['file'] @@ -251,9 +250,8 @@ $info['valid'] $info['valid'] - + $code - $file $info $showDeprecations @@ -14719,13 +14717,15 @@ $filesFound $filesInfos - + $context $context $filesFound - $filesFound $filesInfos + + $filesFound[0]['exception'] + diff --git a/test/classes/Command/TwigLintCommandTest.php b/test/classes/Command/TwigLintCommandTest.php index 2d6e76d16a..3d207b3c4e 100644 --- a/test/classes/Command/TwigLintCommandTest.php +++ b/test/classes/Command/TwigLintCommandTest.php @@ -8,7 +8,6 @@ use PhpMyAdmin\Command\TwigLintCommand; use PhpMyAdmin\Tests\AbstractTestCase; use Symfony\Component\Console\Command\Command; use Twig\Error\SyntaxError; -use Twig\Source; use function class_exists; use function sort; @@ -98,53 +97,21 @@ class TwigLintCommandTest extends AbstractTestCase ], $filesInfos); } - /** - * @requires PHPUnit < 10 - */ public function testGetFilesInfoInvalidFile(): void { - $command = $this->getMockBuilder(TwigLintCommand::class) - ->onlyMethods(['getTemplateContents', 'findFiles']) - ->getMock(); + $twigLintCommand = new TwigLintCommand(); + $path = __DIR__ . '/../_data/templates/lint_command'; + $filesFound = $twigLintCommand->getFilesInfo($path); - $command->expects($this->exactly(1)) - ->method('findFiles') - ->willReturn( - [ - 'foo.twig', - 'foo-invalid.twig', - ] - ); - - $command->expects($this->exactly(2)) - ->method('getTemplateContents') - ->withConsecutive( - ['foo.twig'], - ['foo-invalid.twig'] - ) - ->willReturnOnConsecutiveCalls('{{ file }}', '{{ file }'); - - $filesFound = $this->callFunction($command, TwigLintCommand::class, 'getFilesInfo', [ - TEST_PATH . 'test/classes/_data/file_listing', - ]); - - self::assertEquals([ - [ - 'template' => '{{ file }}', - 'file' => 'foo.twig', - 'valid' => true, - ], - [ - 'template' => '{{ file }', - 'file' => 'foo-invalid.twig', - 'valid' => false, - 'line' => 1, - 'exception' => new SyntaxError('Unexpected "}".', 1, new Source( - '{{ file }', - 'foo-invalid.twig' - )), - ], - ], $filesFound); + self::assertCount(2, $filesFound); + self::assertSame('{{ file }' . "\n", $filesFound[0]['template']); + self::assertSame($path . '/foo-invalid.twig', $filesFound[0]['file']); + self::assertArrayHasKey('exception', $filesFound[0]); + $exception = $filesFound[0]['exception']; + self::assertInstanceOf(SyntaxError::class, $exception); + self::assertSame('Unexpected "}" in "' . $path . '/foo-invalid.twig" at line 1.', $exception->getMessage()); + self::assertSame('{{ file }}' . "\n", $filesFound[1]['template']); + self::assertSame($path . '/foo-valid.twig', $filesFound[1]['file']); } public function testGetContext(): void diff --git a/test/classes/_data/templates/lint_command/foo-invalid.twig b/test/classes/_data/templates/lint_command/foo-invalid.twig new file mode 100644 index 0000000000..30ef87ca01 --- /dev/null +++ b/test/classes/_data/templates/lint_command/foo-invalid.twig @@ -0,0 +1 @@ +{{ file } diff --git a/test/classes/_data/templates/lint_command/foo-valid.twig b/test/classes/_data/templates/lint_command/foo-valid.twig new file mode 100644 index 0000000000..e35132b9fd --- /dev/null +++ b/test/classes/_data/templates/lint_command/foo-valid.twig @@ -0,0 +1 @@ +{{ file }}