From 04c08b586f10e16447ba4a201ec8cee94b10e598 Mon Sep 17 00:00:00 2001 From: "Simon L." Date: Fri, 27 Feb 2026 14:55:16 +0100 Subject: [PATCH] wip Signed-off-by: Simon L. --- php/src/Controller/DockerController.php | 8 ++++++-- php/src/Docker/DockerActionManager.php | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/php/src/Controller/DockerController.php b/php/src/Controller/DockerController.php index cc7012fb..21076129 100644 --- a/php/src/Controller/DockerController.php +++ b/php/src/Controller/DockerController.php @@ -286,8 +286,12 @@ readonly class DockerController { } public function SystemPrune(Request $request, Response $response, array $args) : Response { - $this->dockerActionManager->SystemPrune(); - return $response->withStatus(201)->withHeader('Location', '.'); + $results = $this->dockerActionManager->SystemPrune(); + $body = $response->getBody(); + $body->write(json_encode($results)); + return $response + ->withStatus(200) + ->withHeader('Content-Type', 'application/json; charset=utf-8'); } public function stopTopContainer() : void { diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index bbf0d53b..af10a9b8 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -984,7 +984,7 @@ readonly class DockerActionManager { } } - public function SystemPrune(): void { + public function SystemPrune(): array { $endpoints = [ // Remove stopped containers 'containers/prune', @@ -998,6 +998,7 @@ readonly class DockerActionManager { 'build/prune', ]; + $results = []; foreach ($endpoints as $endpoint) { // Special-case images prune to include the dangling filter as requested if ($endpoint === 'images/prune') { @@ -1008,11 +1009,21 @@ readonly class DockerActionManager { } try { - $this->guzzleClient->post($url); + $resp = $this->guzzleClient->post($url); + $body = (string)$resp->getBody(); + $json = null; + try { + $json = json_decode($body, true, 512, JSON_THROW_ON_ERROR); + } catch (\Throwable $e) { + // Non-JSON body, keep raw + $json = $body; + } + $results[$endpoint] = $json; } catch (RequestException $e) { error_log(sprintf('Docker prune (%s) failed: %s', $endpoint, $e->getMessage())); + $results[$endpoint] = ['error' => $e->getMessage()]; // continue with next prune step } } + return $results; } -}