From d2bf3613f6c9210a720bebdcf82284bbfc604319 Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Tue, 17 Sep 2024 17:32:33 +0200 Subject: [PATCH 1/6] fix: Drop unnecessary exit Signed-off-by: Louis Chemineau --- apps/dav/lib/Files/ErrorPagePlugin.php | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/dav/lib/Files/ErrorPagePlugin.php b/apps/dav/lib/Files/ErrorPagePlugin.php index ddf04d0f7632e..2b93f0e7a49ac 100644 --- a/apps/dav/lib/Files/ErrorPagePlugin.php +++ b/apps/dav/lib/Files/ErrorPagePlugin.php @@ -92,7 +92,6 @@ public function generateBody(\Throwable $ex, int $httpCode): mixed { */ public function sendResponse() { $this->server->sapi->sendResponse($this->server->httpResponse); - exit(); } private function acceptHtml(): bool { From 9a9dd10c0cadeedf4fc2fd156b3825a115908a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 17 Sep 2024 17:48:01 +0200 Subject: [PATCH 2/6] fix(tests): Remove deprecated tests for ServerTest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- tests/lib/ServerTest.php | 120 +++------------------------------------ 1 file changed, 7 insertions(+), 113 deletions(-) diff --git a/tests/lib/ServerTest.php b/tests/lib/ServerTest.php index 7f7d3125fddb9..eb9b1dab9f522 100644 --- a/tests/lib/ServerTest.php +++ b/tests/lib/ServerTest.php @@ -8,7 +8,6 @@ namespace Test; use OC\App\AppStore\Fetcher\AppFetcher; -use OC\App\AppStore\Fetcher\CategoryFetcher; use OCP\Comments\ICommentsManager; /** @@ -31,118 +30,13 @@ protected function setUp(): void { public function dataTestQuery() { return [ - ['ActivityManager', '\OC\Activity\Manager'], - ['ActivityManager', '\OCP\Activity\IManager'], - ['AllConfig', '\OC\AllConfig'], - ['AllConfig', '\OCP\IConfig'], - ['AppConfig', '\OC\AppConfig'], - ['AppConfig', '\OCP\IAppConfig'], - ['AppFetcher', AppFetcher::class], - ['AppManager', '\OC\App\AppManager'], - ['AppManager', '\OCP\App\IAppManager'], - ['AsyncCommandBus', '\OC\Command\AsyncBus'], - ['AsyncCommandBus', '\OCP\Command\IBus'], - ['AvatarManager', '\OC\Avatar\AvatarManager'], - ['AvatarManager', '\OCP\IAvatarManager'], - - ['CategoryFetcher', CategoryFetcher::class], - ['CapabilitiesManager', '\OC\CapabilitiesManager'], - ['ContactsManager', '\OC\ContactsManager'], - ['ContactsManager', '\OCP\Contacts\IManager'], - ['ContentSecurityPolicyManager', '\OC\Security\CSP\ContentSecurityPolicyManager'], - ['CommentsManager', '\OCP\Comments\ICommentsManager'], - ['Crypto', '\OC\Security\Crypto'], - ['Crypto', '\OCP\Security\ICrypto'], - ['CryptoWrapper', '\OC\Session\CryptoWrapper'], - ['CsrfTokenManager', '\OC\Security\CSRF\CsrfTokenManager'], - - ['DatabaseConnection', '\OC\DB\ConnectionAdapter'], - ['DatabaseConnection', '\OCP\IDBConnection'], - ['DateTimeFormatter', '\OC\DateTimeFormatter'], - ['DateTimeFormatter', '\OCP\IDateTimeFormatter'], - ['DateTimeZone', '\OC\DateTimeZone'], - ['DateTimeZone', '\OCP\IDateTimeZone'], - - ['EncryptionFileHelper', '\OC\Encryption\File'], - ['EncryptionFileHelper', '\OCP\Encryption\IFile'], - ['EncryptionKeyStorage', '\OC\Encryption\Keys\Storage'], - ['EncryptionKeyStorage', '\OCP\Encryption\Keys\IStorage'], - ['EncryptionManager', '\OC\Encryption\Manager'], - ['EncryptionManager', '\OCP\Encryption\IManager'], - ['EventLogger', '\OCP\Diagnostics\IEventLogger'], - - ['GroupManager', '\OC\Group\Manager'], - ['GroupManager', '\OCP\IGroupManager'], - - ['Hasher', '\OC\Security\Hasher'], - ['Hasher', '\OCP\Security\IHasher'], - ['HttpClientService', '\OC\Http\Client\ClientService'], - ['HttpClientService', '\OCP\Http\Client\IClientService'], - - ['IniWrapper', '\bantu\IniGetWrapper\IniGetWrapper'], - ['MimeTypeDetector', '\OCP\Files\IMimeTypeDetector'], - ['MimeTypeDetector', '\OC\Files\Type\Detection'], - - ['JobList', '\OC\BackgroundJob\JobList'], - ['JobList', '\OCP\BackgroundJob\IJobList'], - - ['L10NFactory', '\OC\L10N\Factory'], - ['L10NFactory', '\OCP\L10N\IFactory'], - ['LockingProvider', '\OCP\Lock\ILockingProvider'], - ['Logger', '\OC\Log'], - ['Logger', '\OCP\ILogger'], - - ['Mailer', '\OC\Mail\Mailer'], - ['Mailer', '\OCP\Mail\IMailer'], - ['MemCacheFactory', '\OC\Memcache\Factory'], - ['MemCacheFactory', '\OCP\ICacheFactory'], - ['MountConfigManager', '\OC\Files\Config\MountProviderCollection'], - ['MountConfigManager', '\OCP\Files\Config\IMountProviderCollection'], - - ['NavigationManager', '\OC\NavigationManager'], - ['NavigationManager', '\OCP\INavigationManager'], - ['NotificationManager', '\OC\Notification\Manager'], - ['NotificationManager', '\OCP\Notification\IManager'], - ['UserCache', '\OC\Cache\File'], - ['UserCache', '\OCP\ICache'], - - ['PreviewManager', '\OC\PreviewManager'], - ['PreviewManager', '\OCP\IPreview'], - - ['QueryLogger', '\OCP\Diagnostics\IQueryLogger'], - - ['Request', '\OC\AppFramework\Http\Request'], - ['Request', '\OCP\IRequest'], - ['RootFolder', '\OC\Files\Node\Root'], - ['RootFolder', '\OC\Files\Node\Folder'], - ['RootFolder', '\OCP\Files\IRootFolder'], - ['RootFolder', '\OCP\Files\Folder'], - ['Router', '\OCP\Route\IRouter'], - - ['SecureRandom', '\OC\Security\SecureRandom'], - ['SecureRandom', '\OCP\Security\ISecureRandom'], - ['ShareManager', '\OC\Share20\Manager'], - ['ShareManager', '\OCP\Share\IManager'], - ['SystemConfig', '\OC\SystemConfig'], - - ['URLGenerator', '\OC\URLGenerator'], - ['URLGenerator', '\OCP\IURLGenerator'], - ['UserManager', '\OC\User\Manager'], - ['UserManager', '\OCP\IUserManager'], - ['UserSession', '\OC\User\Session'], - ['UserSession', '\OCP\IUserSession'], - - ['TagMapper', '\OC\Tagging\TagMapper'], - ['TagMapper', '\OCP\AppFramework\Db\QBMapper'], - ['TagManager', '\OC\TagManager'], - ['TagManager', '\OCP\ITagManager'], - ['TempManager', '\OC\TempManager'], - ['TempManager', '\OCP\ITempManager'], - ['ThemingDefaults', '\OCA\Theming\ThemingDefaults'], - ['TrustedDomainHelper', '\OC\Security\TrustedDomainHelper'], - - ['SystemTagManager', '\OCP\SystemTag\ISystemTagManager'], - ['SystemTagObjectMapper', '\OCP\SystemTag\ISystemTagObjectMapper'], + ['\OCP\Activity\IManager', '\OC\Activity\Manager'], + ['\OCP\IConfig', '\OC\AllConfig'], + ['\OCP\IAppConfig', '\OC\AppConfig'], + [AppFetcher::class, AppFetcher::class], + ['\OCP\App\IAppManager', '\OC\App\AppManager'], + ['\OCP\Command\IBus', '\OC\Command\AsyncBus'], + ['\OCP\IAvatarManager', '\OC\Avatar\AvatarManager'], ]; } From 2bdc97741cd42843f85750421cba032942d860ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 17 Sep 2024 19:19:08 +0200 Subject: [PATCH 3/6] fix(tests): Fix Folder tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- tests/lib/Files/Node/FolderTest.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php index 5af409a1a93ce..3cc2623e04655 100644 --- a/tests/lib/Files/Node/FolderTest.php +++ b/tests/lib/Files/Node/FolderTest.php @@ -353,6 +353,8 @@ public function testSearchInRoot(): void { $storage->method('getCache') ->willReturn($cache); + $storage->method('getOwner') + ->willReturn('owner'); $cache->insert('files', ['size' => 200, 'mtime' => 55, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]); $cache->insert('files/foo', ['size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain']); @@ -391,6 +393,8 @@ public function testSearchInStorageRoot(): void { $storage->method('getCache') ->willReturn($cache); + $storage->method('getOwner') + ->willReturn('owner'); $cache->insert('foo', ['size' => 200, 'mtime' => 55, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]); $cache->insert('foo/qwerty', ['size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain']); @@ -442,9 +446,13 @@ public function testSearchSubStorages(): void { $storage->method('getCache') ->willReturn($cache); + $storage->method('getOwner') + ->willReturn('owner'); $subStorage->method('getCache') ->willReturn($subCache); + $subStorage->method('getOwner') + ->willReturn('owner'); $cache->insert('foo', ['size' => 200, 'mtime' => 55, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]); $cache->insert('foo/qwerty', ['size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain']); @@ -496,6 +504,8 @@ public function testGetById(): void { $storage->method('getCache') ->willReturn($cache); + $storage->method('getOwner') + ->willReturn('owner'); $this->userMountCache->expects($this->any()) ->method('getMountsForFileId') @@ -543,6 +553,8 @@ public function testGetByIdMountRoot(): void { $storage->method('getCache') ->willReturn($cache); + $storage->method('getOwner') + ->willReturn('owner'); $this->userMountCache->expects($this->any()) ->method('getMountsForFileId') @@ -586,6 +598,8 @@ public function testGetByIdOutsideFolder(): void { $storage->method('getCache') ->willReturn($cache); + $storage->method('getOwner') + ->willReturn('owner'); $this->userMountCache->expects($this->any()) ->method('getMountsForFileId') @@ -629,6 +643,8 @@ public function testGetByIdMultipleStorages(): void { $storage->method('getCache') ->willReturn($cache); + $storage->method('getOwner') + ->willReturn('owner'); $this->userMountCache->method('getMountsForFileId') ->with(1) @@ -644,9 +660,6 @@ public function testGetByIdMultipleStorages(): void { ), ]); - $storage->method('getCache') - ->willReturn($cache); - $cache->method('get') ->with(1) ->willReturn($fileInfo); @@ -948,9 +961,13 @@ public function testSearchSubStoragesLimitOffset(int $offset, int $limit, array $storage->method('getCache') ->willReturn($cache); + $storage->method('getOwner') + ->willReturn('owner'); $subStorage1->method('getCache') ->willReturn($subCache1); + $subStorage1->method('getOwner') + ->willReturn('owner'); $subMount2->method('getStorage') ->willReturn($subStorage2); @@ -960,6 +977,8 @@ public function testSearchSubStoragesLimitOffset(int $offset, int $limit, array $subStorage2->method('getCache') ->willReturn($subCache2); + $subStorage2->method('getOwner') + ->willReturn('owner'); $cache->insert('foo/foo1', ['size' => 200, 'mtime' => 10, 'mimetype' => 'text/plain']); $cache->insert('foo/foo2', ['size' => 200, 'mtime' => 20, 'mimetype' => 'text/plain']); From cfca7e7911568a7fd12c4c2116d77c126cff51ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 17 Sep 2024 19:20:13 +0200 Subject: [PATCH 4/6] fix(tests): Fix most obvious errors in ObjectStore tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some are still failing Signed-off-by: Côme Chilliet --- ...ObjectStoreStoragesDifferentBucketTest.php | 2 + .../ObjectStoreStoragesSameBucketTest.php | 2 + tests/lib/Files/Storage/StoragesTest.php | 112 +++++++++--------- 3 files changed, 60 insertions(+), 56 deletions(-) diff --git a/tests/lib/Files/ObjectStore/ObjectStoreStoragesDifferentBucketTest.php b/tests/lib/Files/ObjectStore/ObjectStoreStoragesDifferentBucketTest.php index 1915460777cf0..a0e18a5557b65 100644 --- a/tests/lib/Files/ObjectStore/ObjectStoreStoragesDifferentBucketTest.php +++ b/tests/lib/Files/ObjectStore/ObjectStoreStoragesDifferentBucketTest.php @@ -7,6 +7,8 @@ namespace Test\Files\ObjectStore; +use OC\Files\ObjectStore\StorageObjectStore; +use OC\Files\Storage\Temporary; use Test\Files\Storage\StoragesTest; /** diff --git a/tests/lib/Files/ObjectStore/ObjectStoreStoragesSameBucketTest.php b/tests/lib/Files/ObjectStore/ObjectStoreStoragesSameBucketTest.php index 71011451a531c..19a1f4b7bc5ad 100644 --- a/tests/lib/Files/ObjectStore/ObjectStoreStoragesSameBucketTest.php +++ b/tests/lib/Files/ObjectStore/ObjectStoreStoragesSameBucketTest.php @@ -7,6 +7,8 @@ namespace Test\Files\ObjectStore; +use OC\Files\ObjectStore\StorageObjectStore; +use OC\Files\Storage\Temporary; use Test\Files\Storage\StoragesTest; /** diff --git a/tests/lib/Files/Storage/StoragesTest.php b/tests/lib/Files/Storage/StoragesTest.php index a7578c24e3db7..d157d288f2c6e 100644 --- a/tests/lib/Files/Storage/StoragesTest.php +++ b/tests/lib/Files/Storage/StoragesTest.php @@ -33,76 +33,76 @@ protected function tearDown(): void { public function testMoveFileFromStorage() { $source = 'source.txt'; $target = 'target.txt'; - $storage2->file_put_contents($source, 'foo'); + $this->storage2->file_put_contents($source, 'foo'); - $storage1->moveFromStorage($storage2, $source, $target); + $this->storage1->moveFromStorage($this->storage2, $source, $target); - $this->assertTrue($storage1->file_exists($target), $target.' was not created'); - $this->assertFalse($storage2->file_exists($source), $source.' still exists'); - $this->assertEquals('foo', $storage1->file_get_contents($target)); + $this->assertTrue($this->storage1->file_exists($target), $target.' was not created'); + $this->assertFalse($this->storage2->file_exists($source), $source.' still exists'); + $this->assertEquals('foo', $this->storage1->file_get_contents($target)); } public function testMoveDirectoryFromStorage() { - $storage2->mkdir('source'); - $storage2->file_put_contents('source/test1.txt', 'foo'); - $storage2->file_put_contents('source/test2.txt', 'qwerty'); - $storage2->mkdir('source/subfolder'); - $storage2->file_put_contents('source/subfolder/test.txt', 'bar'); - - $storage1->moveFromStorage($storage2, 'source', 'target'); - - $this->assertTrue($storage1->file_exists('target')); - $this->assertTrue($storage1->file_exists('target/test1.txt')); - $this->assertTrue($storage1->file_exists('target/test2.txt')); - $this->assertTrue($storage1->file_exists('target/subfolder')); - $this->assertTrue($storage1->file_exists('target/subfolder/test.txt')); - - $this->assertFalse($storage2->file_exists('source')); - $this->assertFalse($storage2->file_exists('source/test1.txt')); - $this->assertFalse($storage2->file_exists('source/test2.txt')); - $this->assertFalse($storage2->file_exists('source/subfolder')); - $this->assertFalse($storage2->file_exists('source/subfolder/test.txt')); - - $this->assertEquals('foo', $storage1->file_get_contents('target/test1.txt')); - $this->assertEquals('qwerty', $storage1->file_get_contents('target/test2.txt')); - $this->assertEquals('bar', $storage1->file_get_contents('target/subfolder/test.txt')); + $this->storage2->mkdir('source'); + $this->storage2->file_put_contents('source/test1.txt', 'foo'); + $this->storage2->file_put_contents('source/test2.txt', 'qwerty'); + $this->storage2->mkdir('source/subfolder'); + $this->storage2->file_put_contents('source/subfolder/test.txt', 'bar'); + + $this->storage1->moveFromStorage($this->storage2, 'source', 'target'); + + $this->assertTrue($this->storage1->file_exists('target')); + $this->assertTrue($this->storage1->file_exists('target/test1.txt')); + $this->assertTrue($this->storage1->file_exists('target/test2.txt')); + $this->assertTrue($this->storage1->file_exists('target/subfolder')); + $this->assertTrue($this->storage1->file_exists('target/subfolder/test.txt')); + + $this->assertFalse($this->storage2->file_exists('source')); + $this->assertFalse($this->storage2->file_exists('source/test1.txt')); + $this->assertFalse($this->storage2->file_exists('source/test2.txt')); + $this->assertFalse($this->storage2->file_exists('source/subfolder')); + $this->assertFalse($this->storage2->file_exists('source/subfolder/test.txt')); + + $this->assertEquals('foo', $this->storage1->file_get_contents('target/test1.txt')); + $this->assertEquals('qwerty', $this->storage1->file_get_contents('target/test2.txt')); + $this->assertEquals('bar', $this->storage1->file_get_contents('target/subfolder/test.txt')); } public function testCopyFileFromStorage() { $source = 'source.txt'; $target = 'target.txt'; - $storage2->file_put_contents($source, 'foo'); + $this->storage2->file_put_contents($source, 'foo'); - $storage1->copyFromStorage($storage2, $source, $target); + $this->storage1->copyFromStorage($this->storage2, $source, $target); - $this->assertTrue($storage1->file_exists($target), $target.' was not created'); - $this->assertTrue($storage2->file_exists($source), $source.' was deleted'); - $this->assertEquals('foo', $storage1->file_get_contents($target)); + $this->assertTrue($this->storage1->file_exists($target), $target.' was not created'); + $this->assertTrue($this->storage2->file_exists($source), $source.' was deleted'); + $this->assertEquals('foo', $this->storage1->file_get_contents($target)); } public function testCopyDirectoryFromStorage() { - $storage2->mkdir('source'); - $storage2->file_put_contents('source/test1.txt', 'foo'); - $storage2->file_put_contents('source/test2.txt', 'qwerty'); - $storage2->mkdir('source/subfolder'); - $storage2->file_put_contents('source/subfolder/test.txt', 'bar'); - - $storage1->copyFromStorage($storage2, 'source', 'target'); - - $this->assertTrue($storage1->file_exists('target')); - $this->assertTrue($storage1->file_exists('target/test1.txt')); - $this->assertTrue($storage1->file_exists('target/test2.txt')); - $this->assertTrue($storage1->file_exists('target/subfolder')); - $this->assertTrue($storage1->file_exists('target/subfolder/test.txt')); - - $this->assertTrue($storage2->file_exists('source')); - $this->assertTrue($storage2->file_exists('source/test1.txt')); - $this->assertTrue($storage2->file_exists('source/test2.txt')); - $this->assertTrue($storage2->file_exists('source/subfolder')); - $this->assertTrue($storage2->file_exists('source/subfolder/test.txt')); - - $this->assertEquals('foo', $storage1->file_get_contents('target/test1.txt')); - $this->assertEquals('qwerty', $storage1->file_get_contents('target/test2.txt')); - $this->assertEquals('bar', $storage1->file_get_contents('target/subfolder/test.txt')); + $this->storage2->mkdir('source'); + $this->storage2->file_put_contents('source/test1.txt', 'foo'); + $this->storage2->file_put_contents('source/test2.txt', 'qwerty'); + $this->storage2->mkdir('source/subfolder'); + $this->storage2->file_put_contents('source/subfolder/test.txt', 'bar'); + + $this->storage1->copyFromStorage($this->storage2, 'source', 'target'); + + $this->assertTrue($this->storage1->file_exists('target')); + $this->assertTrue($this->storage1->file_exists('target/test1.txt')); + $this->assertTrue($this->storage1->file_exists('target/test2.txt')); + $this->assertTrue($this->storage1->file_exists('target/subfolder')); + $this->assertTrue($this->storage1->file_exists('target/subfolder/test.txt')); + + $this->assertTrue($this->storage2->file_exists('source')); + $this->assertTrue($this->storage2->file_exists('source/test1.txt')); + $this->assertTrue($this->storage2->file_exists('source/test2.txt')); + $this->assertTrue($this->storage2->file_exists('source/subfolder')); + $this->assertTrue($this->storage2->file_exists('source/subfolder/test.txt')); + + $this->assertEquals('foo', $this->storage1->file_get_contents('target/test1.txt')); + $this->assertEquals('qwerty', $this->storage1->file_get_contents('target/test2.txt')); + $this->assertEquals('bar', $this->storage1->file_get_contents('target/subfolder/test.txt')); } } From b124f197779a0a550730b928361f8e5b7e2f6028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 17 Sep 2024 19:34:44 +0200 Subject: [PATCH 5/6] fix(tests): Adapt tests to changes in RepairMimeTypes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- tests/lib/Repair/RepairMimeTypesTest.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/lib/Repair/RepairMimeTypesTest.php b/tests/lib/Repair/RepairMimeTypesTest.php index 0f1a945bd8d0b..45a555e0b9122 100644 --- a/tests/lib/Repair/RepairMimeTypesTest.php +++ b/tests/lib/Repair/RepairMimeTypesTest.php @@ -8,8 +8,11 @@ namespace Test\Repair; use OC\Files\Storage\Temporary; +use OC\Repair\RepairMimeTypes; use OCP\Files\IMimeTypeLoader; +use OCP\IAppConfig; use OCP\IConfig; +use OCP\IDBConnection; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; @@ -42,13 +45,21 @@ protected function setUp(): void { $config->method('getSystemValueString') ->with('version') ->willReturn('11.0.0.0'); - $config->method('getAppValue') + + $appConfig = $this->getMockBuilder(IAppConfig::class) + ->disableOriginalConstructor() + ->getMock(); + $appConfig->method('getValueString') ->with('files', 'mimetype_version') ->willReturn('11.0.0.0'); - $this->storage = new \OC\Files\Storage\Temporary([]); + $this->storage = new Temporary([]); - $this->repair = new \OC\Repair\RepairMimeTypes($config, \OC::$server->getDatabaseConnection()); + $this->repair = new RepairMimeTypes( + $config, + $appConfig, + \OCP\Server::get(IDBConnection::class), + ); } protected function tearDown(): void { From 4e75a3c55c56b575b4541db3f069a845f6ef3c72 Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Wed, 18 Sep 2024 09:23:19 +0200 Subject: [PATCH 6/6] fix: Prevent duplicate creation of print_exception function Signed-off-by: Louis Chemineau --- 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 5c907038ba2e4..44f9908c57cc6 100644 --- a/core/templates/exception.php +++ b/core/templates/exception.php @@ -9,20 +9,7 @@ style('core', ['styles', 'header', 'exception']); -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"); ?>