1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 07:36:44 +02:00

Make kill_process / process_list extendable

This commit is contained in:
salacr
2025-05-06 19:02:46 +02:00
committed by Jakub Vrana
parent 307fabaf22
commit ec5ad85470
4 changed files with 21 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
## Adminer dev ## Adminer dev
- Allow specifying operator in search anywhere - Allow specifying operator in search anywhere
- Plugins: Methods processList() and killProcess()
## Adminer 5.3.0 (released 2025-05-04) ## Adminer 5.3.0 (released 2025-05-04)
- Align numeric functions right - Align numeric functions right

View File

@@ -1067,11 +1067,11 @@ if (!defined('Adminer\DRIVER')) {
} }
/** Kill a process /** Kill a process
* @param numeric-string $val * @param numeric-string $id
* @return Result|bool * @return Result|bool
*/ */
function kill_process(string $val) { function kill_process(string $id) {
return queries("KILL " . number($val)); return queries("KILL " . number($id));
} }
/** Return query to get connection ID */ /** Return query to get connection ID */

View File

@@ -1115,4 +1115,19 @@ class Adminer {
} }
echo "</ul>\n"; echo "</ul>\n";
} }
/** Get process list
* @return list<string[]> [$row]
*/
function processList(): array {
return process_list();
}
/** Kill a process
* @param numeric-string $id
* @return Result|bool
*/
function killProcess(string $id) {
return kill_process($id);
}
} }

View File

@@ -5,7 +5,7 @@ if (support("kill")) {
if ($_POST && !$error) { if ($_POST && !$error) {
$killed = 0; $killed = 0;
foreach ((array) $_POST["kill"] as $val) { foreach ((array) $_POST["kill"] as $val) {
if (kill_process($val)) { if (adminer()->killProcess($val)) {
$killed++; $killed++;
} }
} }
@@ -23,7 +23,7 @@ page_header(lang('Process list'), $error);
echo script("mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true)});"); echo script("mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true)});");
// HTML valid because there is always at least one process // HTML valid because there is always at least one process
$i = -1; $i = -1;
foreach (process_list() as $i => $row) { foreach (adminer()->processList() as $i => $row) {
if (!$i) { if (!$i) {
echo "<thead><tr lang='en'>" . (support("kill") ? "<th>" : ""); echo "<thead><tr lang='en'>" . (support("kill") ? "<th>" : "");
foreach ($row as $key => $val) { foreach ($row as $key => $val) {