1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-06 06:37:33 +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

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

View File

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