Skip to content

Commit 017951f

Browse files
authored
Merge pull request #48214 from nextcloud/backport/48205/stable29
[stable29] Ci fixes
2 parents c2170cf + b731f95 commit 017951f

20 files changed

Lines changed: 239 additions & 91 deletions

File tree

apps/dav/lib/Connector/Sabre/Server.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,27 @@ public function __construct($treeOrNode = null) {
4343
self::$exposeVersion = false;
4444
$this->enablePropfindDepthInfinity = true;
4545
}
46+
47+
// Copied from 3rdparty/sabre/dav/lib/DAV/Server.php
48+
// Should be them exact same without the exception output.
49+
public function start(): void {
50+
try {
51+
// If nginx (pre-1.2) is used as a proxy server, and SabreDAV as an
52+
// origin, we must make sure we send back HTTP/1.0 if this was
53+
// requested.
54+
// This is mainly because nginx doesn't support Chunked Transfer
55+
// Encoding, and this forces the webserver SabreDAV is running on,
56+
// to buffer entire responses to calculate Content-Length.
57+
$this->httpResponse->setHTTPVersion($this->httpRequest->getHTTPVersion());
58+
59+
// Setting the base url
60+
$this->httpRequest->setBaseUrl($this->getBaseUri());
61+
$this->invokeMethod($this->httpRequest, $this->httpResponse);
62+
} catch (\Throwable $e) {
63+
try {
64+
$this->emit('exception', [$e]);
65+
} catch (\Exception $ignore) {
66+
}
67+
}
68+
}
4669
}

apps/dav/lib/Files/ErrorPagePlugin.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ public function generateBody(\Throwable $ex, int $httpCode): mixed {
109109
*/
110110
public function sendResponse() {
111111
$this->server->sapi->sendResponse($this->server->httpResponse);
112-
exit();
113112
}
114113

115114
private function acceptHtml(): bool {

apps/dav/tests/unit/Connector/Sabre/RequestTest/PartFileInRootUploadTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626
namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;
2727

28+
use OC\AllConfig;
2829
use OCP\IConfig;
2930

3031
/**
@@ -49,7 +50,7 @@ protected function setUp(): void {
4950
return $config->getSystemValue($key, $default);
5051
}
5152
});
52-
$this->overwriteService('AllConfig', $mockConfig);
53+
$this->overwriteService(AllConfig::class, $mockConfig);
5354
parent::setUp();
5455
}
5556

apps/files_sharing/tests/Controller/ShareAPIControllerTest.php

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,8 @@ public function dataGetShare() {
553553

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

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

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

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

@@ -626,6 +630,9 @@ public function dataGetShare() {
626630
'item_size' => 123465,
627631
'item_mtime' => 1234567890,
628632
'attributes' => null,
633+
'item_permissions' => 4,
634+
'is-mount-root' => false,
635+
'mount-type' => '',
629636
];
630637
$data[] = [$share, $expected];
631638

@@ -680,6 +687,9 @@ public function dataGetShare() {
680687
'item_size' => 123465,
681688
'item_mtime' => 1234567890,
682689
'attributes' => null,
690+
'item_permissions' => 4,
691+
'is-mount-root' => false,
692+
'mount-type' => '',
683693
];
684694
$data[] = [$share, $expected];
685695

@@ -740,6 +750,9 @@ public function dataGetShare() {
740750
'item_size' => 123465,
741751
'item_mtime' => 1234567890,
742752
'attributes' => null,
753+
'item_permissions' => 4,
754+
'is-mount-root' => false,
755+
'mount-type' => '',
743756
];
744757
$data[] = [$share, $expected];
745758

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

3761+
$mountPoint = $this->createMock(IMountPoint::class);
3762+
$mountPoint->method('getMountType')->willReturn('');
3763+
$file->method('getMountPoint')->willReturn($mountPoint);
3764+
$folder->method('getMountPoint')->willReturn($mountPoint);
3765+
$fileWithPreview->method('getMountPoint')->willReturn($mountPoint);
3766+
37483767
$file->method('getPath')->willReturn('file');
37493768
$folder->method('getPath')->willReturn('folder');
37503769
$fileWithPreview->method('getPath')->willReturn('fileWithPreview');
@@ -3842,6 +3861,9 @@ public function dataFormatShare() {
38423861
'item_size' => 123456,
38433862
'item_mtime' => 1234567890,
38443863
'attributes' => '[{"scope":"permissions","key":"download","enabled":true}]',
3864+
'item_permissions' => 1,
3865+
'is-mount-root' => false,
3866+
'mount-type' => '',
38453867
], $share, [], false
38463868
];
38473869
// User backend up
@@ -3881,6 +3903,9 @@ public function dataFormatShare() {
38813903
'item_size' => 123456,
38823904
'item_mtime' => 1234567890,
38833905
'attributes' => '[{"scope":"permissions","key":"download","enabled":true}]',
3906+
'item_permissions' => 1,
3907+
'is-mount-root' => false,
3908+
'mount-type' => '',
38843909
], $share, [
38853910
['owner', $owner],
38863911
['initiator', $initiator],
@@ -3938,6 +3963,7 @@ public function dataFormatShare() {
39383963
'is-mount-root' => false,
39393964
'mount-type' => '',
39403965
'attributes' => null,
3966+
'item_permissions' => 1,
39413967
], $share, [], false
39423968
];
39433969

@@ -3991,6 +4017,7 @@ public function dataFormatShare() {
39914017
'is-mount-root' => false,
39924018
'mount-type' => '',
39934019
'attributes' => null,
4020+
'item_permissions' => 11,
39944021
], $share, [], false
39954022
];
39964023

@@ -4045,6 +4072,7 @@ public function dataFormatShare() {
40454072
'is-mount-root' => false,
40464073
'mount-type' => '',
40474074
'attributes' => null,
4075+
'item_permissions' => 1,
40484076
], $share, [], false
40494077
];
40504078

@@ -4096,6 +4124,7 @@ public function dataFormatShare() {
40964124
'is-mount-root' => false,
40974125
'mount-type' => '',
40984126
'attributes' => null,
4127+
'item_permissions' => 1,
40994128
], $share, [], false
41004129
];
41014130

@@ -4154,6 +4183,7 @@ public function dataFormatShare() {
41544183
'is-mount-root' => false,
41554184
'mount-type' => '',
41564185
'attributes' => null,
4186+
'item_permissions' => 1,
41574187
], $share, [], false
41584188
];
41594189

@@ -4212,6 +4242,7 @@ public function dataFormatShare() {
42124242
'is-mount-root' => false,
42134243
'mount-type' => '',
42144244
'attributes' => null,
4245+
'item_permissions' => 1,
42154246
], $share, [], false
42164247
];
42174248

@@ -4264,6 +4295,7 @@ public function dataFormatShare() {
42644295
'is-mount-root' => false,
42654296
'mount-type' => '',
42664297
'attributes' => null,
4298+
'item_permissions' => 1,
42674299
], $share, [], false
42684300
];
42694301

@@ -4316,6 +4348,7 @@ public function dataFormatShare() {
43164348
'is-mount-root' => false,
43174349
'mount-type' => '',
43184350
'attributes' => null,
4351+
'item_permissions' => 1,
43194352
], $share, [], false
43204353
];
43214354

@@ -4371,6 +4404,7 @@ public function dataFormatShare() {
43714404
'is-mount-root' => false,
43724405
'mount-type' => '',
43734406
'attributes' => null,
4407+
'item_permissions' => 1,
43744408
], $share, [], false
43754409
];
43764410

@@ -4423,6 +4457,7 @@ public function dataFormatShare() {
44234457
'is-mount-root' => false,
44244458
'mount-type' => '',
44254459
'attributes' => null,
4460+
'item_permissions' => 1,
44264461
], $share, [], false
44274462
];
44284463

@@ -4475,6 +4510,7 @@ public function dataFormatShare() {
44754510
'is-mount-root' => false,
44764511
'mount-type' => '',
44774512
'attributes' => null,
4513+
'item_permissions' => 1,
44784514
], $share, [], false
44794515
];
44804516

@@ -4544,6 +4580,7 @@ public function dataFormatShare() {
45444580
'is-mount-root' => false,
45454581
'mount-type' => '',
45464582
'attributes' => null,
4583+
'item_permissions' => 1,
45474584
], $share, [], false
45484585
];
45494586

@@ -4599,6 +4636,7 @@ public function dataFormatShare() {
45994636
'is-mount-root' => false,
46004637
'mount-type' => '',
46014638
'attributes' => null,
4639+
'item_permissions' => 1,
46024640
], $share, [], false
46034641
];
46044642

@@ -4652,6 +4690,7 @@ public function dataFormatShare() {
46524690
'is-mount-root' => false,
46534691
'mount-type' => '',
46544692
'attributes' => null,
4693+
'item_permissions' => 11,
46554694
], $share, [], false
46564695
];
46574696

@@ -4816,6 +4855,7 @@ public function dataFormatRoomShare() {
48164855
'is-mount-root' => false,
48174856
'mount-type' => '',
48184857
'attributes' => null,
4858+
'item_permissions' => 1,
48194859
], $share, false, []
48204860
];
48214861

@@ -4867,6 +4907,7 @@ public function dataFormatRoomShare() {
48674907
'is-mount-root' => false,
48684908
'mount-type' => '',
48694909
'attributes' => null,
4910+
'item_permissions' => 9,
48704911
], $share, true, [
48714912
'share_with_displayname' => 'recipientRoomName'
48724913
]
@@ -4906,11 +4947,14 @@ public function testFormatRoomShare(array $expects, \OCP\Share\IShare $share, bo
49064947
->willReturn(true);
49074948

49084949
$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
4909-
->setMethods(['formatShare'])
4950+
->setMethods(['formatShare', 'canAccessShare'])
49104951
->getMock();
49114952
$helper->method('formatShare')
49124953
->with($share)
49134954
->willReturn($formatShareByHelper);
4955+
$helper->method('canAccessShare')
4956+
->with($share)
4957+
->willReturn(true);
49144958

49154959
$this->serverContainer->method('get')
49164960
->with('\OCA\Talk\Share\Helper\ShareAPIController')

apps/files_sharing/tests/Controller/ShareControllerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,8 @@ public function testShowShare() {
379379
'previewURL' => 'downloadURL',
380380
'note' => $note,
381381
'hideDownload' => false,
382-
'showgridview' => false
382+
'showgridview' => false,
383+
'filename' => $filename,
383384
];
384385

385386
$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();

apps/files_sharing/tests/External/CacheTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use OCP\Contacts\IManager;
3333
use OCP\EventDispatcher\IEventDispatcher;
3434
use OCP\Federation\ICloudIdManager;
35+
use OCP\Files\Cache\ICacheEntry;
3536
use OCP\ICacheFactory;
3637
use OCP\IURLGenerator;
3738
use OCP\IUserManager;
@@ -95,6 +96,7 @@ protected function setUp(): void {
9596
$this->storage,
9697
$this->cloudIdManager->getCloudId($this->remoteUser, 'http://example.com/owncloud')
9798
);
99+
$this->cache->insert('', ['size' => 0, 'mtime' => 0, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]);
98100
$this->cache->put(
99101
'test.txt',
100102
[

apps/files_trashbin/tests/StorageTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ public function testShouldMoveToTrash($mountPoint, $path, $userExists, $appDisab
616616
$event->expects($this->any())->method('shouldMoveToTrashBin')->willReturn(!$appDisablesTrash);
617617

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

621622
$storage = $this->getMockBuilder(Storage::class)

core/templates/exception.php

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

55
style('core', ['styles', 'header', 'exception']);
66

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

229
?>
2310
<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+
}

0 commit comments

Comments
 (0)