From da1083b5c5aa5b88c5f941e998f7434c1d908935 Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 3 Nov 2025 12:46:35 -0500 Subject: [PATCH 1/6] fix(public.php): Actually pass specified HTTP code for exceptions Signed-off-by: Josh --- public.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/public.php b/public.php index 8ae6deff203..d8cdd347170 100644 --- a/public.php +++ b/public.php @@ -89,10 +89,14 @@ try { $baseuri = OC::$WEBROOT . '/public.php/' . $service . '/'; require_once $file; } catch (Exception $ex) { - $status = 500; - if ($ex instanceof ServiceUnavailableException) { + if ($ex instanceof ServiceUnavailableException && $ex->getCode === 0) { $status = 503; } + if ($ex->getCode() > 0) { + $status = $ex->getCode(); + } else { + $status = 500; + } //show the user a detailed error page Server::get(LoggerInterface::class)->error($ex->getMessage(), ['app' => 'public', 'exception' => $ex]); Server::get(ITemplateManager::class)->printExceptionErrorPage($ex, $status); From a75751328004d431e33ee7565653391b157ef038 Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 3 Nov 2025 12:54:05 -0500 Subject: [PATCH 2/6] fix(remote.php): use status code in error handling Signed-off-by: Josh --- remote.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/remote.php b/remote.php index 2cfd9d818c8..3090bbee6a6 100644 --- a/remote.php +++ b/remote.php @@ -54,16 +54,20 @@ function handleException(Exception|Error $e): void { }); $server->exec(); } else { - $statusCode = 500; - if ($e instanceof ServiceUnavailableException) { - $statusCode = 503; - } if ($e instanceof RemoteException) { // we shall not log on RemoteException \OCP\Server::get(ITemplateManager::class)->printErrorPage($e->getMessage(), '', $e->getCode()); } else { + if ($ex instanceof ServiceUnavailableException && $e->getCode === 0) { + $status = 503; + } + if ($e->getCode() > 0) { + $status = $e->getCode(); + } else { + $status = 500; + } \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['app' => 'remote','exception' => $e]); - \OCP\Server::get(ITemplateManager::class)->printExceptionErrorPage($e, $statusCode); + \OCP\Server::get(ITemplateManager::class)->printExceptionErrorPage($e, $status); } } } catch (\Exception $e) { From 441f18dddce2d0e3d651aa742486ee2a31315d08 Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 3 Nov 2025 13:06:08 -0500 Subject: [PATCH 3/6] chore: oops one Signed-off-by: Josh --- public.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public.php b/public.php index d8cdd347170..b374d7cb71a 100644 --- a/public.php +++ b/public.php @@ -89,7 +89,7 @@ try { $baseuri = OC::$WEBROOT . '/public.php/' . $service . '/'; require_once $file; } catch (Exception $ex) { - if ($ex instanceof ServiceUnavailableException && $ex->getCode === 0) { + if ($ex instanceof ServiceUnavailableException && $ex->getCode() === 0) { $status = 503; } if ($ex->getCode() > 0) { From 55c20fe9d9815fc79922c3ac404344271321899f Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 3 Nov 2025 13:06:41 -0500 Subject: [PATCH 4/6] chore: oops two fix Signed-off-by: Josh --- remote.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote.php b/remote.php index 3090bbee6a6..656ec7458fa 100644 --- a/remote.php +++ b/remote.php @@ -58,7 +58,7 @@ function handleException(Exception|Error $e): void { // we shall not log on RemoteException \OCP\Server::get(ITemplateManager::class)->printErrorPage($e->getMessage(), '', $e->getCode()); } else { - if ($ex instanceof ServiceUnavailableException && $e->getCode === 0) { + if ($e instanceof ServiceUnavailableException && $e->getCode() === 0) { $status = 503; } if ($e->getCode() > 0) { From d24cedfadd063bc7cb1c61be93346b5f5876a2ac Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 10 Dec 2025 15:33:49 +0100 Subject: [PATCH 5/6] chore: simplify if condition Co-authored-by: Kate <26026535+provokateurin@users.noreply.github.com> Signed-off-by: Ferdinand Thiessen --- public.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/public.php b/public.php index b374d7cb71a..fce195ba00e 100644 --- a/public.php +++ b/public.php @@ -89,13 +89,10 @@ try { $baseuri = OC::$WEBROOT . '/public.php/' . $service . '/'; require_once $file; } catch (Exception $ex) { - if ($ex instanceof ServiceUnavailableException && $ex->getCode() === 0) { - $status = 503; - } if ($ex->getCode() > 0) { $status = $ex->getCode(); } else { - $status = 500; + $status = $ex instanceof ServiceUnavailableException ? 503 : 500; } //show the user a detailed error page Server::get(LoggerInterface::class)->error($ex->getMessage(), ['app' => 'public', 'exception' => $ex]); From 486b0167a4da2d00accc40167f2ac9250acecf26 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 10 Dec 2025 15:35:29 +0100 Subject: [PATCH 6/6] chore: simplify if condition Signed-off-by: Ferdinand Thiessen --- remote.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/remote.php b/remote.php index 656ec7458fa..27fb703c87c 100644 --- a/remote.php +++ b/remote.php @@ -58,13 +58,10 @@ function handleException(Exception|Error $e): void { // we shall not log on RemoteException \OCP\Server::get(ITemplateManager::class)->printErrorPage($e->getMessage(), '', $e->getCode()); } else { - if ($e instanceof ServiceUnavailableException && $e->getCode() === 0) { - $status = 503; - } if ($e->getCode() > 0) { $status = $e->getCode(); } else { - $status = 500; + $status = $e instanceof ServiceUnavailableException ? 503 : 500; } \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['app' => 'remote','exception' => $e]); \OCP\Server::get(ITemplateManager::class)->printExceptionErrorPage($e, $status);