Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable29] Ci fixes #48214

Merged
merged 16 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions apps/dav/lib/Connector/Sabre/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,27 @@ public function __construct($treeOrNode = null) {
self::$exposeVersion = false;
$this->enablePropfindDepthInfinity = true;
}

// Copied from 3rdparty/sabre/dav/lib/DAV/Server.php
// Should be them exact same without the exception output.
public function start(): void {
try {
// If nginx (pre-1.2) is used as a proxy server, and SabreDAV as an
// origin, we must make sure we send back HTTP/1.0 if this was
// requested.
// This is mainly because nginx doesn't support Chunked Transfer
// Encoding, and this forces the webserver SabreDAV is running on,
// to buffer entire responses to calculate Content-Length.
$this->httpResponse->setHTTPVersion($this->httpRequest->getHTTPVersion());

// Setting the base url
$this->httpRequest->setBaseUrl($this->getBaseUri());
$this->invokeMethod($this->httpRequest, $this->httpResponse);
} catch (\Throwable $e) {
try {
$this->emit('exception', [$e]);
} catch (\Exception $ignore) {
}
}
}
}
1 change: 0 additions & 1 deletion apps/dav/lib/Files/ErrorPagePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ public function generateBody(\Throwable $ex, int $httpCode): mixed {
*/
public function sendResponse() {
$this->server->sapi->sendResponse($this->server->httpResponse);
exit();
}

private function acceptHtml(): bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;

use OC\AllConfig;
use OCP\IConfig;

/**
Expand All @@ -49,7 +50,7 @@ protected function setUp(): void {
return $config->getSystemValue($key, $default);
}
});
$this->overwriteService('AllConfig', $mockConfig);
$this->overwriteService(AllConfig::class, $mockConfig);
parent::setUp();
}

Expand Down
46 changes: 45 additions & 1 deletion apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ public function dataGetShare() {

$parentFolder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
$parentFolder->method('getId')->willReturn(3);
$mountPoint = $this->createMock(IMountPoint::class);
$mountPoint->method('getMountType')->willReturn('');

$file = $this->getMockBuilder('OCP\Files\File')->getMock();
$file->method('getId')->willReturn(1);
Expand All @@ -562,6 +564,7 @@ public function dataGetShare() {
$file->method('getSize')->willReturn(123465);
$file->method('getMTime')->willReturn(1234567890);
$file->method('getMimeType')->willReturn('myMimeType');
$file->method('getMountPoint')->willReturn($mountPoint);

$folder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
$folder->method('getId')->willReturn(2);
Expand All @@ -571,6 +574,7 @@ public function dataGetShare() {
$folder->method('getSize')->willReturn(123465);
$folder->method('getMTime')->willReturn(1234567890);
$folder->method('getMimeType')->willReturn('myFolderMimeType');
$folder->method('getMountPoint')->willReturn($mountPoint);

[$shareAttributes, $shareAttributesReturnJson] = $this->mockShareAttributes();

Expand Down Expand Up @@ -626,6 +630,9 @@ public function dataGetShare() {
'item_size' => 123465,
'item_mtime' => 1234567890,
'attributes' => null,
'item_permissions' => 4,
'is-mount-root' => false,
'mount-type' => '',
];
$data[] = [$share, $expected];

Expand Down Expand Up @@ -680,6 +687,9 @@ public function dataGetShare() {
'item_size' => 123465,
'item_mtime' => 1234567890,
'attributes' => null,
'item_permissions' => 4,
'is-mount-root' => false,
'mount-type' => '',
];
$data[] = [$share, $expected];

Expand Down Expand Up @@ -740,6 +750,9 @@ public function dataGetShare() {
'item_size' => 123465,
'item_mtime' => 1234567890,
'attributes' => null,
'item_permissions' => 4,
'is-mount-root' => false,
'mount-type' => '',
];
$data[] = [$share, $expected];

Expand Down Expand Up @@ -3745,6 +3758,12 @@ public function dataFormatShare() {
$folder->method('getMimeType')->willReturn('myFolderMimeType');
$fileWithPreview->method('getMimeType')->willReturn('mimeWithPreview');

$mountPoint = $this->createMock(IMountPoint::class);
$mountPoint->method('getMountType')->willReturn('');
$file->method('getMountPoint')->willReturn($mountPoint);
$folder->method('getMountPoint')->willReturn($mountPoint);
$fileWithPreview->method('getMountPoint')->willReturn($mountPoint);

$file->method('getPath')->willReturn('file');
$folder->method('getPath')->willReturn('folder');
$fileWithPreview->method('getPath')->willReturn('fileWithPreview');
Expand Down Expand Up @@ -3842,6 +3861,9 @@ public function dataFormatShare() {
'item_size' => 123456,
'item_mtime' => 1234567890,
'attributes' => '[{"scope":"permissions","key":"download","enabled":true}]',
'item_permissions' => 1,
'is-mount-root' => false,
'mount-type' => '',
], $share, [], false
];
// User backend up
Expand Down Expand Up @@ -3881,6 +3903,9 @@ public function dataFormatShare() {
'item_size' => 123456,
'item_mtime' => 1234567890,
'attributes' => '[{"scope":"permissions","key":"download","enabled":true}]',
'item_permissions' => 1,
'is-mount-root' => false,
'mount-type' => '',
], $share, [
['owner', $owner],
['initiator', $initiator],
Expand Down Expand Up @@ -3938,6 +3963,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -3991,6 +4017,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 11,
], $share, [], false
];

Expand Down Expand Up @@ -4045,6 +4072,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4096,6 +4124,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4154,6 +4183,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4212,6 +4242,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4264,6 +4295,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4316,6 +4348,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4371,6 +4404,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4423,6 +4457,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4475,6 +4510,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4544,6 +4580,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4599,6 +4636,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4652,6 +4690,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 11,
], $share, [], false
];

Expand Down Expand Up @@ -4816,6 +4855,7 @@ public function dataFormatRoomShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, false, []
];

Expand Down Expand Up @@ -4867,6 +4907,7 @@ public function dataFormatRoomShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 9,
], $share, true, [
'share_with_displayname' => 'recipientRoomName'
]
Expand Down Expand Up @@ -4906,11 +4947,14 @@ public function testFormatRoomShare(array $expects, \OCP\Share\IShare $share, bo
->willReturn(true);

$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
->setMethods(['formatShare'])
->setMethods(['formatShare', 'canAccessShare'])
->getMock();
$helper->method('formatShare')
->with($share)
->willReturn($formatShareByHelper);
$helper->method('canAccessShare')
->with($share)
->willReturn(true);

$this->serverContainer->method('get')
->with('\OCA\Talk\Share\Helper\ShareAPIController')
Expand Down
3 changes: 2 additions & 1 deletion apps/files_sharing/tests/Controller/ShareControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ public function testShowShare() {
'previewURL' => 'downloadURL',
'note' => $note,
'hideDownload' => false,
'showgridview' => false
'showgridview' => false,
'filename' => $filename,
];

$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
Expand Down
2 changes: 2 additions & 0 deletions apps/files_sharing/tests/External/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use OCP\Contacts\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudIdManager;
use OCP\Files\Cache\ICacheEntry;
use OCP\ICacheFactory;
use OCP\IURLGenerator;
use OCP\IUserManager;
Expand Down Expand Up @@ -95,6 +96,7 @@ protected function setUp(): void {
$this->storage,
$this->cloudIdManager->getCloudId($this->remoteUser, 'http://example.com/owncloud')
);
$this->cache->insert('', ['size' => 0, 'mtime' => 0, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]);
$this->cache->put(
'test.txt',
[
Expand Down
1 change: 1 addition & 0 deletions apps/files_trashbin/tests/StorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ public function testShouldMoveToTrash($mountPoint, $path, $userExists, $appDisab
$event->expects($this->any())->method('shouldMoveToTrashBin')->willReturn(!$appDisablesTrash);

$userFolder->expects($this->any())->method('getById')->with($fileID)->willReturn([$node]);
$rootFolder->expects($this->any())->method('getById')->with($fileID)->willReturn([$node]);
$rootFolder->expects($this->any())->method('getUserFolder')->willReturn($userFolder);

$storage = $this->getMockBuilder(Storage::class)
Expand Down
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', 'exception']);

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
Loading
Loading