Skip to content

Commit a02b7bc

Browse files
committed
fix: Prevent duplicate creation of print_exception function
Signed-off-by: Louis Chemineau <louis@chmn.me>
1 parent b124f19 commit a02b7bc

4 files changed

Lines changed: 39 additions & 23 deletions

File tree

core/templates/exception.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,7 @@
99

1010
style('core', ['styles', 'header', 'exception']);
1111

12-
function print_exception(Throwable $e, \OCP\IL10N $l): void {
13-
print_unescaped('<pre>');
14-
p($e->getTraceAsString());
15-
print_unescaped('</pre>');
16-
17-
if ($e->getPrevious() !== null) {
18-
print_unescaped('<br />');
19-
print_unescaped('<h4>');
20-
p($l->t('Previous'));
21-
print_unescaped('</h4>');
22-
23-
print_exception($e->getPrevious(), $l);
24-
}
25-
}
12+
require_once __DIR__ . '/print_exception.php';
2613

2714
?>
2815
<div class="guest-box wide">

core/templates/print_exception.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
4+
* SPDX-FileCopyrightText: 2012-2015 ownCloud, Inc.
5+
* SPDX-License-Identifier: AGPL-3.0-only
6+
*/
7+
8+
function print_exception(Throwable $e, \OCP\IL10N $l): void {
9+
print_unescaped('<pre>');
10+
p($e->getTraceAsString());
11+
print_unescaped('</pre>');
12+
13+
if ($e->getPrevious() !== null) {
14+
print_unescaped('<br />');
15+
print_unescaped('<h4>');
16+
p($l->t('Previous'));
17+
print_unescaped('</h4>');
18+
19+
print_exception($e->getPrevious(), $l);
20+
}
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
4+
* SPDX-FileCopyrightText: 2012-2015 ownCloud, Inc.
5+
* SPDX-License-Identifier: AGPL-3.0-only
6+
*/
7+
8+
function print_exception(Throwable $e, \OCP\IL10N $l): void {
9+
p($e->getTraceAsString());
10+
11+
if ($e->getPrevious() !== null) {
12+
print_unescaped('<s:previous-exception>');
13+
print_exception($e->getPrevious(), $l);
14+
print_unescaped('</s:previous-exception>');
15+
}
16+
}

core/templates/xml_exception.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,7 @@
55
* SPDX-License-Identifier: AGPL-3.0-only
66
*/
77

8-
function print_exception(Throwable $e, \OCP\IL10N $l): void {
9-
p($e->getTraceAsString());
10-
11-
if ($e->getPrevious() !== null) {
12-
print_unescaped('<s:previous-exception>');
13-
print_exception($e->getPrevious(), $l);
14-
print_unescaped('</s:previous-exception>');
15-
}
16-
}
8+
require_once __DIR__ . '/print_xml_exception.php';
179

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

0 commit comments

Comments
 (0)