+
{{ 'There are no routines to display.'|trans|notice }}
-
+
|
diff --git a/src/Controllers/Database/RoutinesController.php b/src/Controllers/Database/RoutinesController.php
index f67927ec16..820f2b44a8 100644
--- a/src/Controllers/Database/RoutinesController.php
+++ b/src/Controllers/Database/RoutinesController.php
@@ -145,7 +145,7 @@ class RoutinesController extends AbstractController
'new_row',
$this->template->render('database/routines/row', $this->routines->getRow($routine)),
);
- $this->response->addJSON('insert', ! empty($routine));
+ $this->response->addJSON('insert', true);
$this->response->addJSON('message', $output);
$this->response->addJSON('tableType', 'routines');
@@ -484,7 +484,7 @@ class RoutinesController extends AbstractController
$this->render('database/routines/index', [
'db' => Current::$database,
'table' => Current::$table,
- 'items' => $items,
+ 'has_any_routines' => $items !== [],
'rows' => $rows,
'has_privilege' => Util::currentUserHasPrivilege('CREATE ROUTINE', Current::$database, Current::$table),
]);
diff --git a/src/Database/Routine.php b/src/Database/Routine.php
new file mode 100644
index 0000000000..dc6370288f
--- /dev/null
+++ b/src/Database/Routine.php
@@ -0,0 +1,15 @@
+type,
+ Util::backquote($routine->name),
);
// this is for our purpose to decide whether to
// show the edit link or not, so we need the DEFINER for the routine
$where = 'ROUTINE_SCHEMA ' . Util::getCollateForIS() . '=' . $this->dbi->quoteString(Current::$database)
- . ' AND SPECIFIC_NAME=' . $this->dbi->quoteString($routine['name'])
- . ' AND ROUTINE_TYPE=' . $this->dbi->quoteString($routine['type']);
+ . ' AND SPECIFIC_NAME=' . $this->dbi->quoteString($routine->name)
+ . ' AND ROUTINE_TYPE=' . $this->dbi->quoteString($routine->type);
$query = 'SELECT `DEFINER` FROM INFORMATION_SCHEMA.ROUTINES WHERE ' . $where . ';';
$routineDefiner = $this->dbi->fetchValue($query);
@@ -1152,10 +1151,10 @@ 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']);
+ if ($routine->type === 'FUNCTION') {
+ $definition = self::getFunctionDefinition($this->dbi, Current::$database, $routine->name);
} else {
- $definition = self::getProcedureDefinition($this->dbi, Current::$database, $routine['name']);
+ $definition = self::getProcedureDefinition($this->dbi, Current::$database, $routine->name);
}
$executeAction = '';
@@ -1166,12 +1165,12 @@ class Routines
/** @var CreateStatement $stmt */
$stmt = $parser->statements[0];
- $params = Routine::getParameters($stmt);
+ $params = RoutineUtils::getParameters($stmt);
if ($hasExecutePrivilege) {
$executeAction = 'execute_routine';
for ($i = 0; $i < $params['num']; $i++) {
- if ($routine['type'] === 'PROCEDURE' && $params['dir'][$i] === 'OUT') {
+ if ($routine->type === 'PROCEDURE' && $params['dir'][$i] === 'OUT') {
continue;
}
@@ -1223,7 +1222,7 @@ class Routines
* @param string|null $which PROCEDURE | FUNCTION or null for both
* @param string $name name of the routine (to fetch a specific routine)
*
- * @return mixed[] information about PROCEDUREs or FUNCTIONs
+ * @return Routine[]
*/
public static function getDetails(
DatabaseInterface $dbi,
@@ -1261,14 +1260,9 @@ class Routines
}
$ret = [];
+ /** @var array{Name:string, Type:string, DTD_IDENTIFIER:string|null} $routine */
foreach ($routines as $routine) {
- $ret[] = [
- 'db' => $routine['Db'],
- 'name' => $routine['Name'],
- 'type' => $routine['Type'],
- 'definer' => $routine['Definer'],
- 'returns' => $routine['DTD_IDENTIFIER'] ?? '',
- ];
+ $ret[] = new Routine($routine['Name'], $routine['Type'], $routine['DTD_IDENTIFIER'] ?? '');
}
// Sort results by name
diff --git a/src/Server/Privileges.php b/src/Server/Privileges.php
index 371084a4ea..38cbb16035 100644
--- a/src/Server/Privileges.php
+++ b/src/Server/Privileges.php
@@ -1727,11 +1727,11 @@ class Privileges
$routines = [];
foreach ($routineData as $routine) {
- if (in_array($routine['name'], $foundRows, true)) {
+ if (in_array($routine->name, $foundRows, true)) {
continue;
}
- $routines[] = $routine['name'];
+ $routines[] = $routine->name;
}
$data['routines'] = $routines;
@@ -3224,8 +3224,8 @@ class Privileges
$routineName = mb_strtolower($routineName);
foreach ($routineData as $routine) {
- if (mb_strtolower($routine['name']) === $routineName) {
- return $routine['type'];
+ if (mb_strtolower($routine->name) === $routineName) {
+ return $routine->type;
}
}