1
0
mirror of https://github.com/phpmyadmin/phpmyadmin.git synced 2026-10-23 18:29:15 +03:00

Get export_item param from ServerRequest object

Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.com.br>
This commit is contained in:
Maurício Meneghini Fauth
2026-10-10 18:11:39 -03:00
parent f80ee5387c
commit 3ff024fe9d
4 changed files with 36 additions and 61 deletions

View File

@@ -1374,13 +1374,13 @@ parameters:
-
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
identifier: empty.notAllowed
count: 16
count: 14
path: src/Controllers/Database/EventsController.php
-
message: '#^Parameter \#1 \$identifier of static method PhpMyAdmin\\Util\:\:backquote\(\) expects string\|Stringable\|null, mixed given\.$#'
identifier: argument.type
count: 2
count: 1
path: src/Controllers/Database/EventsController.php
-
@@ -1401,12 +1401,6 @@ parameters:
count: 1
path: src/Controllers/Database/EventsController.php
-
message: '#^Parameter \#3 \$name of static method PhpMyAdmin\\Database\\Events\:\:getDefinition\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Controllers/Database/EventsController.php
-
message: '#^Cannot access offset ''handler'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
@@ -1434,7 +1428,7 @@ parameters:
-
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
identifier: empty.notAllowed
count: 23
count: 21
path: src/Controllers/Database/RoutinesController.php
-
@@ -1446,7 +1440,7 @@ parameters:
-
message: '#^Parameter \#1 \$identifier of static method PhpMyAdmin\\Util\:\:backquote\(\) expects string\|Stringable\|null, mixed given\.$#'
identifier: argument.type
count: 4
count: 3
path: src/Controllers/Database/RoutinesController.php
-
@@ -1473,18 +1467,6 @@ parameters:
count: 3
path: src/Controllers/Database/RoutinesController.php
-
message: '#^Parameter \#3 \$name of static method PhpMyAdmin\\Database\\Routines\:\:getFunctionDefinition\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Controllers/Database/RoutinesController.php
-
message: '#^Parameter \#3 \$name of static method PhpMyAdmin\\Database\\Routines\:\:getProcedureDefinition\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Controllers/Database/RoutinesController.php
-
message: '#^Parameter \#4 \$name of static method PhpMyAdmin\\Database\\Routines\:\:getDetails\(\) expects string, mixed given\.$#'
identifier: argument.type

View File

@@ -714,21 +714,16 @@
<code><![CDATA[$_POST['item_name']]]></code>
<code><![CDATA[$_REQUEST['item_name']]]></code>
<code><![CDATA[$_REQUEST['item_name']]]></code>
<code><![CDATA[$itemName]]></code>
<code><![CDATA[$itemName]]></code>
</PossiblyInvalidArgument>
<PossiblyInvalidCast>
<code><![CDATA[$_POST['item_name']]]></code>
<code><![CDATA[$_POST['item_name']]]></code>
<code><![CDATA[$_REQUEST['item_name']]]></code>
<code><![CDATA[$itemName]]></code>
</PossiblyInvalidCast>
<PossiblyUnusedReturnValue>
<code><![CDATA[Response]]></code>
</PossiblyUnusedReturnValue>
<RiskyTruthyFalsyComparison>
<code><![CDATA[empty($_GET['export_item'])]]></code>
<code><![CDATA[empty($_GET['item_name'])]]></code>
<code><![CDATA[empty($_POST['editor_process_add'])]]></code>
<code><![CDATA[empty($_POST['editor_process_add'])]]></code>
<code><![CDATA[empty($_POST['editor_process_edit'])]]></code>
@@ -790,9 +785,6 @@
<code><![CDATA[Current::$database]]></code>
</MixedArgument>
<PossiblyInvalidArgument>
<code><![CDATA[$_GET['item_name']]]></code>
<code><![CDATA[$_GET['item_name']]]></code>
<code><![CDATA[$_GET['item_name']]]></code>
<code><![CDATA[$_GET['item_name']]]></code>
<code><![CDATA[$_GET['item_name']]]></code>
<code><![CDATA[$_GET['item_name']]]></code>
@@ -807,8 +799,6 @@
<code><![CDATA[$_REQUEST['type'] ?? '']]></code>
</PossiblyInvalidArgument>
<PossiblyInvalidCast>
<code><![CDATA[$_GET['item_name']]]></code>
<code><![CDATA[$_GET['item_name']]]></code>
<code><![CDATA[$_GET['item_name']]]></code>
<code><![CDATA[$_GET['item_name']]]></code>
<code><![CDATA[$_GET['item_type']]]></code>
@@ -826,8 +816,6 @@
</PossiblyUnusedReturnValue>
<RiskyTruthyFalsyComparison>
<code><![CDATA[empty($_GET['execute_dialog'])]]></code>
<code><![CDATA[empty($_GET['export_item'])]]></code>
<code><![CDATA[empty($_GET['item_name'])]]></code>
<code><![CDATA[empty($_GET['item_name'])]]></code>
<code><![CDATA[empty($_GET['item_name'])]]></code>
<code><![CDATA[empty($_POST['editor_process_add'])]]></code>

View File

@@ -20,6 +20,7 @@ use PhpMyAdmin\Util;
use function __;
use function htmlspecialchars;
use function is_string;
use function mb_strtoupper;
use function sprintf;
use function trim;
@@ -203,18 +204,18 @@ final readonly class EventsController implements InvocableController
$this->response->addHTML($message);
}
if (! empty($_GET['export_item']) && ! empty($_GET['item_name'])) {
$itemName = $_GET['item_name'];
$exportData = Events::getDefinition($this->dbi, Current::$database, $itemName);
$eventName = $this->getEventName($request->getQueryParam('item_name'));
if ($request->hasQueryParam('export_item') && $eventName !== '') {
$exportData = Events::getDefinition($this->dbi, Current::$database, $eventName);
if ($exportData === null || $exportData === '') {
$exportData = false;
}
$itemName = Util::backquote($itemName);
$eventName = Util::backquote($eventName);
if ($exportData !== false) {
$exportData = trim($exportData);
$title = sprintf(__('Export of event %s'), $itemName);
$title = sprintf(__('Export of event %s'), $eventName);
if ($request->isAjax()) {
$this->response->addJSON('message', $exportData);
@@ -235,7 +236,7 @@ final readonly class EventsController implements InvocableController
} else {
$message = sprintf(
__('Error in processing request: No event with name %1$s found in database %2$s.'),
htmlspecialchars($itemName),
htmlspecialchars($eventName),
htmlspecialchars(Util::backquote(Current::$database)),
);
$message = Message::error($message);
@@ -263,4 +264,9 @@ final readonly class EventsController implements InvocableController
return $this->response->response();
}
private function getEventName(mixed $param): string
{
return is_string($param) ? $param : '';
}
}

View File

@@ -29,6 +29,7 @@ use PhpMyAdmin\Util;
use function __;
use function htmlspecialchars;
use function in_array;
use function is_string;
use function max;
use function mb_strtoupper;
use function sprintf;
@@ -362,25 +363,13 @@ final readonly class RoutinesController implements InvocableController
}
}
/** @var mixed $routineType */
$routineType = $request->getQueryParam('item_type');
if (
! empty($_GET['export_item'])
&& ! empty($_GET['item_name'])
&& in_array($routineType, ['FUNCTION', 'PROCEDURE'], true)
) {
if ($routineType === 'FUNCTION') {
$routineDefinition = Routines::getFunctionDefinition(
$this->dbi,
Current::$database,
$_GET['item_name'],
);
$routineType = $this->getRoutineType($request->getQueryParam('item_type'));
$routineName = $this->getRoutineName($request->getQueryParam('item_name'));
if ($request->hasQueryParam('export_item') && $routineName !== '' && $routineType !== null) {
if ($routineType === RoutineType::Function) {
$routineDefinition = Routines::getFunctionDefinition($this->dbi, Current::$database, $routineName);
} else {
$routineDefinition = Routines::getProcedureDefinition(
$this->dbi,
Current::$database,
$_GET['item_name'],
);
$routineDefinition = Routines::getProcedureDefinition($this->dbi, Current::$database, $routineName);
}
$exportData = false;
@@ -389,10 +378,10 @@ final readonly class RoutinesController implements InvocableController
$exportData = "DELIMITER $$\n" . $routineDefinition . "$$\nDELIMITER ;\n";
}
$itemName = Util::backquote($_GET['item_name']);
$routineName = Util::backquote($routineName);
if ($exportData !== false) {
$exportData = trim($exportData);
$title = sprintf(__('Export of routine %s'), $itemName);
$title = sprintf(__('Export of routine %s'), $routineName);
if ($request->isAjax()) {
$this->response->addJSON('message', $exportData);
@@ -414,7 +403,7 @@ final readonly class RoutinesController implements InvocableController
'Error in processing request: No routine with name %1$s found in database %2$s.'
. ' You might be lacking the necessary privileges to view/export this routine.',
),
htmlspecialchars($itemName),
htmlspecialchars($routineName),
htmlspecialchars(Util::backquote(Current::$database)),
);
$message = Message::error($message);
@@ -490,4 +479,14 @@ final readonly class RoutinesController implements InvocableController
return $this->response->response();
}
private function getRoutineType(mixed $param): RoutineType|null
{
return is_string($param) ? RoutineType::tryFrom($param) : null;
}
private function getRoutineName(mixed $param): string
{
return is_string($param) ? $param : '';
}
}