Skip to content

Commit

Permalink
fix: Prevent duplicate creation of print_exception function
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>

[skip ci]
  • Loading branch information
artonge authored and backportbot[bot] committed Sep 18, 2024
1 parent 83cbdbd commit 7a8c489
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 23 deletions.
15 changes: 1 addition & 14 deletions core/templates/exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,7 @@

style('core', ['styles', 'header']);

function print_exception(Throwable $e, \OCP\IL10N $l): void {
print_unescaped('<pre>');
p($e->getTraceAsString());
print_unescaped('</pre>');

if ($e->getPrevious() !== null) {
print_unescaped('<br />');
print_unescaped('<h4>');
p($l->t('Previous'));
print_unescaped('</h4>');

print_exception($e->getPrevious(), $l);
}
}
require_once __DIR__ . '/print_exception.php';

?>
<div class="guest-box wide">
Expand Down
21 changes: 21 additions & 0 deletions core/templates/print_exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2012-2015 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/

function print_exception(Throwable $e, \OCP\IL10N $l): void {
print_unescaped('<pre>');
p($e->getTraceAsString());
print_unescaped('</pre>');

if ($e->getPrevious() !== null) {
print_unescaped('<br />');
print_unescaped('<h4>');
p($l->t('Previous'));
print_unescaped('</h4>');

print_exception($e->getPrevious(), $l);
}
}
16 changes: 16 additions & 0 deletions core/templates/print_xml_exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2012-2015 ownCloud, Inc.
* 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('<s:previous-exception>');
print_exception($e->getPrevious(), $l);
print_unescaped('</s:previous-exception>');
}
}
10 changes: 1 addition & 9 deletions core/templates/xml_exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('<s:previous-exception>');
print_exception($e->getPrevious(), $l);
print_unescaped('</s:previous-exception>');
}
}
require_once __DIR__ . '/print_xml_exception.php';

print_unescaped('<?xml version="1.0" encoding="utf-8"?>' . "\n");
?>
Expand Down

0 comments on commit 7a8c489

Please sign in to comment.