diff --git a/libraries/classes/Controllers/Database/ImportController.php b/libraries/classes/Controllers/Database/ImportController.php index 01d33db982..040d5cbae9 100644 --- a/libraries/classes/Controllers/Database/ImportController.php +++ b/libraries/classes/Controllers/Database/ImportController.php @@ -107,6 +107,11 @@ final class ImportController extends AbstractController 'db' => $db, ]; + $choice = Plugins::getChoice('Import', 'format', $importList); + $options = Plugins::getOptions('Import', $importList); + $skipQueriesDefault = Plugins::getDefault('Import', 'skip_queries'); + $isAllowInterruptChecked = Plugins::checkboxCheck('Import', 'allow_interrupt'); + $this->render('database/import/index', [ 'page_settings_error_html' => $pageSettingsErrorHtml, 'page_settings_html' => $pageSettingsHtml, @@ -116,7 +121,10 @@ final class ImportController extends AbstractController 'db' => $db, 'table' => $table, 'max_upload_size' => $GLOBALS['config']->get('max_upload_size'), - 'import_list' => $importList, + 'choice' => $choice, + 'options' => $options, + 'skip_queries_default' => $skipQueriesDefault, + 'is_allow_interrupt_checked' => $isAllowInterruptChecked, 'local_import_file' => $localImportFile, 'is_upload' => $GLOBALS['config']->get('enable_upload'), 'upload_dir' => $cfg['UploadDir'] ?? null, diff --git a/libraries/classes/Controllers/Server/ImportController.php b/libraries/classes/Controllers/Server/ImportController.php index 8fe3c2627c..4ddf91dcc8 100644 --- a/libraries/classes/Controllers/Server/ImportController.php +++ b/libraries/classes/Controllers/Server/ImportController.php @@ -91,6 +91,11 @@ final class ImportController extends AbstractController 'import_type' => 'server', ]; + $choice = Plugins::getChoice('Import', 'format', $importList); + $options = Plugins::getOptions('Import', $importList); + $skipQueriesDefault = Plugins::getDefault('Import', 'skip_queries'); + $isAllowInterruptChecked = Plugins::checkboxCheck('Import', 'allow_interrupt'); + $this->render('server/import/index', [ 'page_settings_error_html' => $pageSettingsErrorHtml, 'page_settings_html' => $pageSettingsHtml, @@ -100,7 +105,10 @@ final class ImportController extends AbstractController 'db' => $db, 'table' => $table, 'max_upload_size' => $GLOBALS['config']->get('max_upload_size'), - 'import_list' => $importList, + 'choice' => $choice, + 'options' => $options, + 'skip_queries_default' => $skipQueriesDefault, + 'is_allow_interrupt_checked' => $isAllowInterruptChecked, 'local_import_file' => $localImportFile, 'is_upload' => $GLOBALS['config']->get('enable_upload'), 'upload_dir' => $cfg['UploadDir'] ?? null, diff --git a/libraries/classes/Controllers/Table/ImportController.php b/libraries/classes/Controllers/Table/ImportController.php index da47aafcd2..d30c846eb1 100644 --- a/libraries/classes/Controllers/Table/ImportController.php +++ b/libraries/classes/Controllers/Table/ImportController.php @@ -101,6 +101,11 @@ final class ImportController extends AbstractController 'table' => $table, ]; + $choice = Plugins::getChoice('Import', 'format', $importList); + $options = Plugins::getOptions('Import', $importList); + $skipQueriesDefault = Plugins::getDefault('Import', 'skip_queries'); + $isAllowInterruptChecked = Plugins::checkboxCheck('Import', 'allow_interrupt'); + $this->render('table/import/index', [ 'page_settings_error_html' => $pageSettingsErrorHtml, 'page_settings_html' => $pageSettingsHtml, @@ -110,7 +115,10 @@ final class ImportController extends AbstractController 'db' => $db, 'table' => $table, 'max_upload_size' => $GLOBALS['config']->get('max_upload_size'), - 'import_list' => $importList, + 'choice' => $choice, + 'options' => $options, + 'skip_queries_default' => $skipQueriesDefault, + 'is_allow_interrupt_checked' => $isAllowInterruptChecked, 'local_import_file' => $localImportFile, 'is_upload' => $GLOBALS['config']->get('enable_upload'), 'upload_dir' => $cfg['UploadDir'] ?? null, diff --git a/libraries/classes/Database/Designer.php b/libraries/classes/Database/Designer.php index f7f4710113..8abe73baf7 100644 --- a/libraries/classes/Database/Designer.php +++ b/libraries/classes/Database/Designer.php @@ -137,10 +137,14 @@ class Designer )->getDisplay(); } + $choice = Plugins::getChoice('Schema', 'export_type', $export_list, 'format'); + $options = Plugins::getOptions('Schema', $export_list); + return $this->template->render('database/designer/schema_export', [ 'db' => $db, 'page' => $page, - 'export_list' => $export_list, + 'choice' => $choice, + 'options' => $options, ]); } diff --git a/libraries/classes/Template.php b/libraries/classes/Template.php index 5b1e4938e4..b638cdd0cd 100644 --- a/libraries/classes/Template.php +++ b/libraries/classes/Template.php @@ -10,7 +10,6 @@ use PhpMyAdmin\Twig\Extensions\Node\TransNode; use PhpMyAdmin\Twig\FlashMessagesExtension; use PhpMyAdmin\Twig\I18nExtension; use PhpMyAdmin\Twig\MessageExtension; -use PhpMyAdmin\Twig\PluginsExtension; use PhpMyAdmin\Twig\RelationExtension; use PhpMyAdmin\Twig\SanitizeExtension; use PhpMyAdmin\Twig\TableExtension; @@ -98,7 +97,6 @@ class Template $twig->addExtension(new FlashMessagesExtension()); $twig->addExtension(new I18nExtension()); $twig->addExtension(new MessageExtension()); - $twig->addExtension(new PluginsExtension()); $twig->addExtension(new RelationExtension()); $twig->addExtension(new SanitizeExtension()); $twig->addExtension(new TableExtension()); diff --git a/libraries/classes/Twig/PluginsExtension.php b/libraries/classes/Twig/PluginsExtension.php deleted file mode 100644 index 38d7b790c9..0000000000 --- a/libraries/classes/Twig/PluginsExtension.php +++ /dev/null @@ -1,43 +0,0 @@ - ['html']] - ), - new TwigFunction( - 'get_choice', - [Plugins::class, 'getChoice'], - ['is_safe' => ['html']] - ), - new TwigFunction( - 'get_default_plugin', - [Plugins::class, 'getDefault'], - ['is_safe' => ['html']] - ), - new TwigFunction( - 'get_options', - [Plugins::class, 'getOptions'], - ['is_safe' => ['html']] - ), - ]; - } -} diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 15fc285329..854626a27b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -95,6 +95,11 @@ parameters: count: 1 path: libraries/classes/Controllers/Database/DesignerController.php + - + message: "#^Parameter \\#2 \\$list of static method PhpMyAdmin\\\\Plugins\\:\\:getOptions\\(\\) expects array\\, array\\ given\\.$#" + count: 1 + path: libraries/classes/Controllers/Database/ImportController.php + - message: "#^Negated boolean expression is always true\\.$#" count: 6 @@ -150,6 +155,11 @@ parameters: count: 1 path: libraries/classes/Controllers/Server/CollationsController.php + - + message: "#^Parameter \\#2 \\$list of static method PhpMyAdmin\\\\Plugins\\:\\:getOptions\\(\\) expects array\\, array\\ given\\.$#" + count: 1 + path: libraries/classes/Controllers/Server/ImportController.php + - message: "#^Offset 1 does not exist on array\\|null\\.$#" count: 3 @@ -165,6 +175,11 @@ parameters: count: 1 path: libraries/classes/Controllers/Table/ChangeController.php + - + message: "#^Parameter \\#2 \\$list of static method PhpMyAdmin\\\\Plugins\\:\\:getOptions\\(\\) expects array\\, array\\ given\\.$#" + count: 1 + path: libraries/classes/Controllers/Table/ImportController.php + - message: "#^Comparison operation \"\\>\" between int\\<1, max\\> and 0 is always true\\.$#" count: 1 @@ -185,6 +200,11 @@ parameters: count: 1 path: libraries/classes/Core.php + - + message: "#^Parameter \\#2 \\$list of static method PhpMyAdmin\\\\Plugins\\:\\:getOptions\\(\\) expects array\\, array\\ given\\.$#" + count: 1 + path: libraries/classes/Database/Designer.php + - message: "#^Offset 'DCN' does not exist on array\\('C_NAME' \\=\\> array\\, \\?'DCN' \\=\\> array\\&nonEmpty, \\?'DTN' \\=\\> array\\&nonEmpty, \\?'SCN' \\=\\> array\\&nonEmpty, \\?'STN' \\=\\> array\\&nonEmpty\\)\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 2959cbe2cd..ebcc43d733 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1332,6 +1332,9 @@ + + $importList + $db $sub_part ?? '' @@ -2548,6 +2551,9 @@ + + $importList + $_SESSION[$SESSION_KEY]['handler'] $_SESSION[$SESSION_KEY]['handler'] @@ -3375,6 +3381,9 @@ + + $importList + $urlParams @@ -4874,6 +4883,9 @@ + + $export_list + $page_rs $tabColumn[$tableName]['COLUMN_ID'] diff --git a/templates/database/designer/schema_export.twig b/templates/database/designer/schema_export.twig index 912b772f5e..15d0759a1e 100644 --- a/templates/database/designer/schema_export.twig +++ b/templates/database/designer/schema_export.twig @@ -2,8 +2,8 @@
{{ get_hidden_inputs(db) }} - {{ get_choice('Schema', 'export_type', export_list, 'format') }} + {{ choice|raw }} - {{ get_options('Schema', export_list) }} + {{ options|raw }}
diff --git a/templates/import.twig b/templates/import.twig index d5bb637526..6bf7f0e995 100644 --- a/templates/import.twig +++ b/templates/import.twig @@ -158,8 +158,7 @@ {% endif %}
- + @@ -171,7 +170,7 @@ {% trans 'Skip this number of queries (for SQL) starting from the first one:' %}
{% else %} @@ -179,7 +178,7 @@ do not show the Skip dialog to avoid the risk of someone entering a value here that would interfere with "skip" #} {% endif %} @@ -195,7 +194,7 @@

{% trans 'Format:' %}

- {{ get_choice('Import', 'format', import_list) }} + {{ choice|raw }}
@@ -204,7 +203,7 @@

{% trans 'Scroll down to fill in the options for the selected format and ignore the options for other formats.' %}

- {{ get_options('Import', import_list) }} + {{ options|raw }}