diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2f867066bf..fed592c22c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -5670,7 +5670,7 @@ parameters: - message: '#^Cannot access offset int\<0, max\> on mixed\.$#' identifier: offsetAccess.nonOffsetAccessible - count: 16 + count: 15 path: src/Database/Routines.php - @@ -5703,12 +5703,6 @@ parameters: count: 3 path: src/Database/Routines.php - - - message: '#^Cannot assign new offset to list\\|string\|null\.$#' - identifier: offsetAssign.dimType - count: 1 - path: src/Database/Routines.php - - message: '#^Cannot assign new offset to list\\|string\.$#' identifier: offsetAssign.dimType @@ -5808,7 +5802,7 @@ parameters: - message: '#^Parameter \#1 \$string of function mb_strtolower expects string, mixed given\.$#' identifier: argument.type - count: 7 + count: 5 path: src/Database/Routines.php - diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 11d752880f..b9c68df32f 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -3674,8 +3674,6 @@ - - @@ -3708,8 +3706,6 @@ - - diff --git a/resources/templates/database/routines/execute_form.twig b/resources/templates/database/routines/execute_form.twig index 0370e9f8b3..f8c728dcec 100644 --- a/resources/templates/database/routines/execute_form.twig +++ b/resources/templates/database/routines/execute_form.twig @@ -6,57 +6,62 @@
{{ ajax ? t('Routine parameters') : routine['item_name'] }}
-
- - {% if not ajax %} - - {% endif %} - - - - {% if show_function_fields %} - + {% if params is not empty %} +
+
{{ t('Routine parameters') }}
{{ t('Name') }}{{ t('Type') }}{{ t('Function') }}
+ {% if not ajax %} + {% endif %} - - - {% for i in 0..routine['item_num_params'] - 1 %} - - + + {% if show_function_fields %} - + {% endif %} + + + {% for i in 0..routine['item_num_params'] - 1 %} + + + + {% if show_function_fields %} + + {% endif %} + - {% endif %} - - - {% endfor %} -
{{ t('Routine parameters') }}
{{ t('Value') }}
{{ routine['item_param_name'][loop.index0] }}{{ routine['item_param_type'][loop.index0] }}{{ t('Name') }}{{ t('Type') }} - {% if (params[loop.index0]['generator'] ?? null) is not null %} - + {{ t('Function') }}{{ t('Value') }}
{{ routine['item_param_name'][loop.index0] }}{{ routine['item_param_type'][loop.index0] }} + {% if (params[loop.index0]['generator'] ?? null) is not null %} + + {% else %} + -- + {% endif %} + + {% if routine['item_param_type'][loop.index0] in ['ENUM', 'SET'] %} + {% for value in routine['item_param_length_arr'][loop.index0] %} + + {{ params[loop.parent.loop.index0]['htmlentities'][loop.index0] }} +
+ {% endfor %} {% else %} - -- + {% endif %}
- {% if routine['item_param_type'][loop.index0] in ['ENUM', 'SET'] %} - {% for value in routine['item_param_length_arr'][loop.index0] %} - - {{ params[loop.parent.loop.index0]['htmlentities'][loop.index0] }} -
- {% endfor %} - {% elseif routine['item_param_type'][loop.index0]|lower in params['no_support_types'] %} - {% else %} - - {% endif %} -
-
- - {% if not ajax %} - {% else %} - - +
+

{{ t('This routine does not require any parameters.') }}

+
{% endif %}
+ + {% if not ajax %} + + {% else %} + + + {% endif %} diff --git a/resources/templates/database/routines/row.twig b/resources/templates/database/routines/row.twig index 1b959e3867..ce8bb51d1c 100644 --- a/resources/templates/database/routines/row.twig +++ b/resources/templates/database/routines/row.twig @@ -24,26 +24,16 @@ {% endif %} - {% if has_execute_privilege and execute_action is not empty %} - {% if execute_action == 'execute_routine' %} - - {{ get_icon('b_nextpage', t('Execute')) }} - - {% else %} - - {{ get_icon('b_nextpage', t('Execute')) }} - - {% endif %} + {% if has_execute_privilege %} + + {{ get_icon('b_nextpage', t('Execute')) }} + {% else %} {{ get_icon('bd_nextpage', t('Execute')) }} {% endif %} diff --git a/src/Database/Routines.php b/src/Database/Routines.php index 052e399640..57558ffec7 100644 --- a/src/Database/Routines.php +++ b/src/Database/Routines.php @@ -1084,10 +1084,7 @@ class Routines $routine['item_param_name'][$i] = htmlentities($routine['item_param_name'][$i], ENT_QUOTES); } - $noSupportTypes = Util::unsupportedDatatypes(); - $params = []; - $params['no_support_types'] = $noSupportTypes; for ($i = 0; $i < $routine['item_num_params']; $i++) { if ($routine['item_type'] === 'PROCEDURE' && $routine['item_param_dir'][$i] === 'OUT') { @@ -1098,11 +1095,6 @@ class Routines if ( stripos($routine['item_param_type'][$i], 'enum') !== false || stripos($routine['item_param_type'][$i], 'set') !== false - || in_array( - mb_strtolower($routine['item_param_type'][$i]), - $noSupportTypes, - true, - ) ) { $params[$i]['generator'] = null; } else { @@ -1137,8 +1129,6 @@ class Routines $value = htmlentities(Util::unQuote($value), ENT_QUOTES); $params[$i]['htmlentities'][] = $value; } - } elseif (in_array(mb_strtolower($routine['item_param_type'][$i]), $noSupportTypes, true)) { - $params[$i]['input_type'] = null; } else { $params[$i]['input_type'] = 'text'; } @@ -1186,33 +1176,6 @@ class Routines // we will show a dialog to get values for these parameters, // otherwise we can execute it directly. - if ($routine->type === 'FUNCTION') { - $definition = self::getFunctionDefinition($this->dbi, Current::$database, $routine->name); - } else { - $definition = self::getProcedureDefinition($this->dbi, Current::$database, $routine->name); - } - - $executeAction = ''; - - if ($definition !== null && $hasExecutePrivilege) { - $parser = new Parser('DELIMITER $$' . "\n" . $definition); - - /** @var CreateStatement $stmt */ - $stmt = $parser->statements[0]; - - $executeAction = 'execute_routine'; - if ($stmt->parameters !== null) { - foreach ($stmt->parameters as $param) { - if ($routine->type === 'PROCEDURE' && $param->inOut === 'OUT') { - continue; - } - - $executeAction = 'execute_dialog'; - break; - } - } - } - return [ 'db' => Current::$database, 'table' => Current::$table, @@ -1222,7 +1185,6 @@ class Routines 'has_edit_privilege' => $hasEditPrivilege, 'has_export_privilege' => $hasExportPrivilege, 'has_execute_privilege' => $hasExecutePrivilege, - 'execute_action' => $executeAction, ]; } diff --git a/src/Util.php b/src/Util.php index b5fab8a7bf..f73f5ea77c 100644 --- a/src/Util.php +++ b/src/Util.php @@ -1171,17 +1171,6 @@ class Util return $retval; } - /** - * Returns a list of datatypes that are not (yet) handled by PMA. - * Used by: /table/change and libraries/Routines.php - * - * @return string[] list of datatypes - */ - public static function unsupportedDatatypes(): array - { - return []; - } - /** * This function is to check whether database support UUID */ diff --git a/tests/unit/Controllers/Database/RoutinesControllerTest.php b/tests/unit/Controllers/Database/RoutinesControllerTest.php index a9e4e33452..690502b0b2 100644 --- a/tests/unit/Controllers/Database/RoutinesControllerTest.php +++ b/tests/unit/Controllers/Database/RoutinesControllerTest.php @@ -186,10 +186,10 @@ final class RoutinesControllerTest extends AbstractTestCase - - Execute Execute - - + + Execute Execute + + Export Export @@ -215,10 +215,10 @@ final class RoutinesControllerTest extends AbstractTestCase - - Execute Execute - - + + Execute Execute + + Export Export diff --git a/tests/unit/UtilTest.php b/tests/unit/UtilTest.php index f315978980..91175f47b3 100644 --- a/tests/unit/UtilTest.php +++ b/tests/unit/UtilTest.php @@ -1002,15 +1002,6 @@ class UtilTest extends AbstractTestCase return [['test', 'test'], ["\r\ntest", "\n\r\ntest"], ["\ntest", "\ntest"], ["\n\r\ntest", "\n\r\ntest"]]; } - public function testUnsupportedDatatypes(): void - { - $noSupportTypes = []; - self::assertSame( - $noSupportTypes, - Util::unsupportedDatatypes(), - ); - } - public function testGetPageFromPosition(): void { self::assertSame(Util::getPageFromPosition(0, 1), 1);