diff --git a/libraries/classes/Controllers/Database/EventsController.php b/libraries/classes/Controllers/Database/EventsController.php
index a72b034a46..b0d6c70632 100644
--- a/libraries/classes/Controllers/Database/EventsController.php
+++ b/libraries/classes/Controllers/Database/EventsController.php
@@ -81,7 +81,7 @@ final class EventsController extends AbstractController
$this->events->handleEditor();
$this->events->export();
- $items = $this->dbi->getEvents($GLOBALS['db']);
+ $items = $this->events->getDetails($GLOBALS['db']);
$this->render('database/events/index', [
'db' => $GLOBALS['db'],
diff --git a/libraries/classes/Database/Events.php b/libraries/classes/Database/Events.php
index 2a2f532845..1a2196d8f6 100644
--- a/libraries/classes/Database/Events.php
+++ b/libraries/classes/Database/Events.php
@@ -7,11 +7,14 @@ namespace PhpMyAdmin\Database;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Message;
+use PhpMyAdmin\Query\Generator as QueryGenerator;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Template;
use PhpMyAdmin\Util;
use function __;
+use function array_column;
+use function array_multisort;
use function count;
use function explode;
use function htmlspecialchars;
@@ -23,6 +26,8 @@ use function str_contains;
use function strtoupper;
use function trim;
+use const SORT_ASC;
+
/**
* Functions for event management.
*/
@@ -174,7 +179,7 @@ class Events
if ($this->response->isAjax()) {
if ($GLOBALS['message']->isSuccess()) {
- $events = $this->dbi->getEvents($GLOBALS['db'], $_POST['item_name']);
+ $events = $this->getDetails($GLOBALS['db'], $_POST['item_name']);
$event = $events[0];
$this->response->addJSON(
'name',
@@ -596,4 +601,45 @@ class Events
$this->response->addHTML($message->getDisplay());
}
+
+ /**
+ * Returns details about the EVENTs for a specific database.
+ *
+ * @param string $db db name
+ * @param string $name event name
+ *
+ * @return array information about EVENTs
+ */
+ public function getDetails(string $db, string $name = ''): array
+ {
+ if (! $GLOBALS['cfg']['Server']['DisableIS']) {
+ $query = QueryGenerator::getInformationSchemaEventsRequest(
+ $this->dbi->escapeString($db),
+ empty($name) ? null : $this->dbi->escapeString($name)
+ );
+ } else {
+ $query = 'SHOW EVENTS FROM ' . Util::backquote($db);
+ if ($name) {
+ $query .= " WHERE `Name` = '"
+ . $this->dbi->escapeString($name) . "'";
+ }
+ }
+
+ $result = [];
+ $events = $this->dbi->fetchResult($query);
+
+ foreach ($events as $event) {
+ $result[] = [
+ 'name' => $event['Name'],
+ 'type' => $event['Type'],
+ 'status' => $event['Status'],
+ ];
+ }
+
+ // Sort results by name
+ $name = array_column($result, 'name');
+ array_multisort($name, SORT_ASC, $result);
+
+ return $result;
+ }
}
diff --git a/libraries/classes/DatabaseInterface.php b/libraries/classes/DatabaseInterface.php
index a38e976a63..01ee453f23 100644
--- a/libraries/classes/DatabaseInterface.php
+++ b/libraries/classes/DatabaseInterface.php
@@ -1523,47 +1523,6 @@ class DatabaseInterface implements DbalInterface
return is_string($result) ? $result : null;
}
- /**
- * returns details about the EVENTs for a specific database
- *
- * @param string $db db name
- * @param string $name event name
- *
- * @return array information about EVENTs
- */
- public function getEvents(string $db, string $name = ''): array
- {
- if (! $GLOBALS['cfg']['Server']['DisableIS']) {
- $query = QueryGenerator::getInformationSchemaEventsRequest(
- $this->escapeString($db),
- empty($name) ? null : $this->escapeString($name)
- );
- } else {
- $query = 'SHOW EVENTS FROM ' . Util::backquote($db);
- if ($name) {
- $query .= " WHERE `Name` = '"
- . $this->escapeString($name) . "'";
- }
- }
-
- $result = [];
- $events = $this->fetchResult($query);
-
- foreach ($events as $event) {
- $result[] = [
- 'name' => $event['Name'],
- 'type' => $event['Type'],
- 'status' => $event['Status'],
- ];
- }
-
- // Sort results by name
- $name = array_column($result, 'name');
- array_multisort($name, SORT_ASC, $result);
-
- return $result;
- }
-
/**
* returns details about the TRIGGERs for a specific table or database
*
diff --git a/libraries/classes/Dbal/DbalInterface.php b/libraries/classes/Dbal/DbalInterface.php
index 999f973c3d..0d8ff5c266 100644
--- a/libraries/classes/Dbal/DbalInterface.php
+++ b/libraries/classes/Dbal/DbalInterface.php
@@ -461,16 +461,6 @@ interface DbalInterface
$link = DatabaseInterface::CONNECT_USER
): ?string;
- /**
- * returns details about the EVENTs for a specific database
- *
- * @param string $db db name
- * @param string $name event name
- *
- * @return array information about EVENTs
- */
- public function getEvents(string $db, string $name = ''): array;
-
/**
* returns details about the TRIGGERs for a specific table or database
*
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index a0ccaabc90..316db55f15 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -1965,6 +1965,11 @@ parameters:
count: 1
path: libraries/classes/Database/Events.php
+ -
+ message: "#^Method PhpMyAdmin\\\\Database\\\\Events\\:\\:getDetails\\(\\) return type has no value type specified in iterable type array\\.$#"
+ count: 1
+ path: libraries/classes/Database/Events.php
+
-
message: "#^Method PhpMyAdmin\\\\Database\\\\Events\\:\\:getEditorForm\\(\\) has parameter \\$item with no value type specified in iterable type array\\.$#"
count: 1
@@ -2535,11 +2540,6 @@ parameters:
count: 1
path: libraries/classes/DatabaseInterface.php
- -
- message: "#^Method PhpMyAdmin\\\\DatabaseInterface\\:\\:getEvents\\(\\) return type has no value type specified in iterable type array\\.$#"
- count: 1
- path: libraries/classes/DatabaseInterface.php
-
-
message: "#^Method PhpMyAdmin\\\\DatabaseInterface\\:\\:getProceduresOrFunctions\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
@@ -2680,11 +2680,6 @@ parameters:
count: 1
path: libraries/classes/Dbal/DbalInterface.php
- -
- message: "#^Method PhpMyAdmin\\\\Dbal\\\\DbalInterface\\:\\:getEvents\\(\\) return type has no value type specified in iterable type array\\.$#"
- count: 1
- path: libraries/classes/Dbal/DbalInterface.php
-
-
message: "#^Method PhpMyAdmin\\\\Dbal\\\\DbalInterface\\:\\:getProceduresOrFunctions\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 15db3f42fc..10d7af7486 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -4908,7 +4908,10 @@
$event['name']
$itemName
-
+
+ $event['Name']
+ $event['Status']
+ $event['Type']
$event['name']
@@ -4922,10 +4925,11 @@
$GLOBALS['errors'][]
$GLOBALS['errors'][]
-
+
$GLOBALS['errors']
$GLOBALS['errors']
$event
+ $event
$itemName
$item['item_original_name']
$retval[$index]
@@ -5630,10 +5634,7 @@
uksort($eachTables, 'strnatcasecmp')
usort($tables, 'strnatcasecmp')
-
- $event['Name']
- $event['Status']
- $event['Type']
+
$link
$oneShow['Db']
$oneShow['Name']
@@ -5680,13 +5681,12 @@
$this->links[$link]
$this->links[$link]
-
+
$aLength
$bLength
$database
$databaseName
$databases[$databaseName]['SCHEMA_NAME']
- $event
$grant
$grant
$keyIndex