From 7a8c48986bfa8be8216e5e5498a7548c30500721 Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Wed, 18 Sep 2024 09:23:19 +0200 Subject: [PATCH] fix: Prevent duplicate creation of print_exception function Signed-off-by: Louis Chemineau [skip ci] --- core/templates/exception.php | 15 +-------------- core/templates/print_exception.php | 21 +++++++++++++++++++++ core/templates/print_xml_exception.php | 16 ++++++++++++++++ core/templates/xml_exception.php | 10 +--------- 4 files changed, 39 insertions(+), 23 deletions(-) create mode 100644 core/templates/print_exception.php create mode 100644 core/templates/print_xml_exception.php diff --git a/core/templates/exception.php b/core/templates/exception.php index d26e9ff4f94ed..324724e67ace2 100644 --- a/core/templates/exception.php +++ b/core/templates/exception.php @@ -4,20 +4,7 @@ style('core', ['styles', 'header']); -function print_exception(Throwable $e, \OCP\IL10N $l): void { - print_unescaped('
');
-	p($e->getTraceAsString());
-	print_unescaped('
'); - - if ($e->getPrevious() !== null) { - print_unescaped('
'); - print_unescaped('

'); - p($l->t('Previous')); - print_unescaped('

'); - - print_exception($e->getPrevious(), $l); - } -} +require_once __DIR__ . '/print_exception.php'; ?>
diff --git a/core/templates/print_exception.php b/core/templates/print_exception.php new file mode 100644 index 0000000000000..2def6d4e9d904 --- /dev/null +++ b/core/templates/print_exception.php @@ -0,0 +1,21 @@ +'); + p($e->getTraceAsString()); + print_unescaped(''); + + if ($e->getPrevious() !== null) { + print_unescaped('
'); + print_unescaped('

'); + p($l->t('Previous')); + print_unescaped('

'); + + print_exception($e->getPrevious(), $l); + } +} diff --git a/core/templates/print_xml_exception.php b/core/templates/print_xml_exception.php new file mode 100644 index 0000000000000..94452d8ae9d3f --- /dev/null +++ b/core/templates/print_xml_exception.php @@ -0,0 +1,16 @@ +getTraceAsString()); + + if ($e->getPrevious() !== null) { + print_unescaped(''); + print_exception($e->getPrevious(), $l); + print_unescaped(''); + } +} diff --git a/core/templates/xml_exception.php b/core/templates/xml_exception.php index 342238d824bb7..ba808c88595c2 100644 --- a/core/templates/xml_exception.php +++ b/core/templates/xml_exception.php @@ -5,15 +5,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -function print_exception(Throwable $e, \OCP\IL10N $l): void { - p($e->getTraceAsString()); - - if ($e->getPrevious() !== null) { - print_unescaped(''); - print_exception($e->getPrevious(), $l); - print_unescaped(''); - } -} +require_once __DIR__ . '/print_xml_exception.php'; print_unescaped('' . "\n"); ?>