Skip to content

Commit 4e969ef

Browse files
authored
Merge pull request #36120 from nextcloud/enh/32bits-support
Fix 32bit support and add workflow for 32bits testing
2 parents 17ed023 + 6e276ad commit 4e969ef

74 files changed

Lines changed: 363 additions & 207 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: PHPUnit
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "15 1 * * 1-6"
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: phpunit-32bits-${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
phpunit-32bits:
17+
runs-on: ubuntu-latest
18+
container: shivammathur/node:latest-i386
19+
20+
strategy:
21+
matrix:
22+
php-versions: ['8.0']
23+
24+
steps:
25+
- name: Checkout server
26+
uses: actions/checkout@v3
27+
with:
28+
submodules: true
29+
30+
- name: Install tools
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y ffmpeg imagemagick libmagickcore-6.q16-3-extra
34+
35+
- name: Set up php ${{ matrix.php-versions }}
36+
uses: shivammathur/setup-php@v2
37+
with:
38+
php-version: ${{ matrix.php-versions }}
39+
extensions: ctype, curl, dom, fileinfo, gd, imagick, intl, json, mbstring, openssl, pdo_sqlite, posix, sqlite, xml, zip, apcu
40+
tools: phpunit:9
41+
coverage: none
42+
ini-values:
43+
apc.enabled=on,
44+
apc.enable_cli=on
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: Set up Nextcloud
49+
env:
50+
DB_PORT: 4444
51+
run: |
52+
mkdir data
53+
./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=autotest --database-pass=rootpassword --admin-user admin --admin-pass admin
54+
php -f index.php
55+
56+
- name: PHPUnit
57+
working-directory: tests
58+
run: phpunit --configuration phpunit-autotest.xml --exclude-group PRIMARY-azure,PRIMARY-s3,PRIMARY-swift,Memcached,Redis,RoutingWeirdness

.github/workflows/smb-kerberos.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,9 @@ jobs:
6464
CONTENT=$(./client-cmd.sh ${{ env.DC_IP }} curl -b /shared/cookies/jar -s --negotiate -u testuser@DOMAIN.TEST: --delegation always http://httpd.domain.test/remote.php/webdav/smb/test.txt)
6565
CONTENT=$(echo $CONTENT | head -n 1 | tr -d '[:space:]')
6666
[[ $CONTENT == "testfile" ]]
67+
- name: Show logs
68+
if: failure()
69+
run: |
70+
docker exec --user 33 apache ./occ log:file
71+
FILEPATH=$(docker exec --user 33 apache ./occ log:file | grep "Log file:" | cut -d' ' -f3)
72+
docker exec --user 33 apache cat $FILEPATH

apps/dav/lib/CalDAV/CalDavBackend.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
use OCP\IConfig;
7373
use OCP\IDBConnection;
7474
use OCP\IGroupManager;
75-
use OCP\IUser;
7675
use OCP\IUserManager;
7776
use OCP\Security\ISecureRandom;
7877
use Psr\Log\LoggerInterface;
@@ -120,7 +119,6 @@
120119
* @package OCA\DAV\CalDAV
121120
*/
122121
class CalDavBackend extends AbstractBackend implements SyncSupport, SubscriptionSupport, SchedulingSupport {
123-
124122
use TTransactional;
125123

126124
public const CALENDAR_TYPE_CALENDAR = 0;
@@ -346,7 +344,7 @@ public function getCalendarsForUser($principalUri) {
346344
$row['principaluri'] = (string) $row['principaluri'];
347345
$components = [];
348346
if ($row['components']) {
349-
$components = explode(',',$row['components']);
347+
$components = explode(',', $row['components']);
350348
}
351349

352350
$calendar = [
@@ -420,7 +418,7 @@ public function getCalendarsForUser($principalUri) {
420418
$row['displayname'] = $row['displayname'] . ' (' . ($this->userManager->getDisplayName($name) ?? ($name ?? '')) . ')';
421419
$components = [];
422420
if ($row['components']) {
423-
$components = explode(',',$row['components']);
421+
$components = explode(',', $row['components']);
424422
}
425423
$calendar = [
426424
'id' => $row['id'],
@@ -469,7 +467,7 @@ public function getUsersOwnCalendars($principalUri) {
469467
$row['principaluri'] = (string) $row['principaluri'];
470468
$components = [];
471469
if ($row['components']) {
472-
$components = explode(',',$row['components']);
470+
$components = explode(',', $row['components']);
473471
}
474472
$calendar = [
475473
'id' => $row['id'],
@@ -521,7 +519,7 @@ public function getPublicCalendars() {
521519
$row['displayname'] = $row['displayname'] . "($name)";
522520
$components = [];
523521
if ($row['components']) {
524-
$components = explode(',',$row['components']);
522+
$components = explode(',', $row['components']);
525523
}
526524
$calendar = [
527525
'id' => $row['id'],
@@ -586,7 +584,7 @@ public function getPublicCalendar($uri) {
586584
$row['displayname'] = $row['displayname'] . ' ' . "($name)";
587585
$components = [];
588586
if ($row['components']) {
589-
$components = explode(',',$row['components']);
587+
$components = explode(',', $row['components']);
590588
}
591589
$calendar = [
592590
'id' => $row['id'],
@@ -639,7 +637,7 @@ public function getCalendarByUri($principal, $uri) {
639637
$row['principaluri'] = (string) $row['principaluri'];
640638
$components = [];
641639
if ($row['components']) {
642-
$components = explode(',',$row['components']);
640+
$components = explode(',', $row['components']);
643641
}
644642

645643
$calendar = [
@@ -687,7 +685,7 @@ public function getCalendarById(int $calendarId): ?array {
687685
$row['principaluri'] = (string) $row['principaluri'];
688686
$components = [];
689687
if ($row['components']) {
690-
$components = explode(',',$row['components']);
688+
$components = explode(',', $row['components']);
691689
}
692690

693691
$calendar = [
@@ -779,7 +777,7 @@ public function createCalendar($principalUri, $calendarUri, array $properties) {
779777
if (!($properties[$sccs] instanceof SupportedCalendarComponentSet)) {
780778
throw new DAV\Exception('The ' . $sccs . ' property must be of type: \Sabre\CalDAV\Property\SupportedCalendarComponentSet');
781779
}
782-
$values['components'] = implode(',',$properties[$sccs]->getValue());
780+
$values['components'] = implode(',', $properties[$sccs]->getValue());
783781
} elseif (isset($properties['components'])) {
784782
// Allow to provide components internally without having
785783
// to create a SupportedCalendarComponentSet object
@@ -797,7 +795,7 @@ public function createCalendar($principalUri, $calendarUri, array $properties) {
797795
}
798796
}
799797

800-
[$calendarId, $calendarData] = $this->atomic(function() use ($values) {
798+
[$calendarId, $calendarData] = $this->atomic(function () use ($values) {
801799
$query = $this->db->getQueryBuilder();
802800
$query->insert('calendars');
803801
foreach ($values as $column => $value) {
@@ -1712,7 +1710,7 @@ public function calendarSearch($principalUri, array $filters, $limit = null, $of
17121710
$query->expr()->eq('c.calendarid',
17131711
$query->createNamedParameter($id)),
17141712
$query->expr()->eq('c.calendartype',
1715-
$query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
1713+
$query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
17161714
}
17171715
foreach ($sharedCalendars as $id) {
17181716
$calendarExpressions[] = $query->expr()->andX(
@@ -1860,7 +1858,7 @@ public function search(array $calendarInfo, $pattern, array $searchProperties,
18601858
}
18611859
}
18621860

1863-
if(isset($options['uid'])) {
1861+
if (isset($options['uid'])) {
18641862
$outerQuery->andWhere($outerQuery->expr()->eq('uid', $outerQuery->createNamedParameter($options['uid'])));
18651863
}
18661864

@@ -2435,7 +2433,7 @@ public function createSubscription($principalUri, $uri, array $properties) {
24352433
}
24362434
}
24372435

2438-
[$subscriptionId, $subscriptionRow] = $this->atomic(function() use ($values) {
2436+
[$subscriptionId, $subscriptionRow] = $this->atomic(function () use ($values) {
24392437
$valuesToInsert = [];
24402438
$query = $this->db->getQueryBuilder();
24412439
foreach (array_keys($values) as $name) {

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function __construct(View $view, FileInfo $info, IManager $shareManager =
138138
public function put($data) {
139139
try {
140140
$exists = $this->fileView->file_exists($this->path);
141-
if ($this->info && $exists && !$this->info->isUpdateable()) {
141+
if ($exists && !$this->info->isUpdateable()) {
142142
throw new Forbidden();
143143
}
144144
} catch (StorageNotAvailableException $e) {
@@ -759,9 +759,6 @@ private function convertToSabreException(\Exception $e) {
759759
* @return string|null
760760
*/
761761
public function getChecksum() {
762-
if (!$this->info) {
763-
return null;
764-
}
765762
return $this->info->getChecksum();
766763
}
767764

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@
5353
use Sabre\DAV\Tree;
5454
use Sabre\HTTP\RequestInterface;
5555
use Sabre\HTTP\ResponseInterface;
56-
use Sabre\Uri;
5756

5857
class FilesPlugin extends ServerPlugin {
59-
6058
// namespace
6159
public const NS_OWNCLOUD = 'http://owncloud.org/ns';
6260
public const NS_NEXTCLOUD = 'http://nextcloud.org/ns';
@@ -352,7 +350,7 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
352350
$propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function () use ($node) {
353351
return json_encode($this->previewManager->isAvailable($node->getFileInfo()), JSON_THROW_ON_ERROR);
354352
});
355-
$propFind->handle(self::SIZE_PROPERTYNAME, function () use ($node): ?int {
353+
$propFind->handle(self::SIZE_PROPERTYNAME, function () use ($node): int|float {
356354
return $node->getSize();
357355
});
358356
$propFind->handle(self::MOUNT_TYPE_PROPERTYNAME, function () use ($node) {
@@ -382,7 +380,7 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
382380
});
383381
/**
384382
* Return file/folder name as displayname. The primary reason to
385-
* implement it this way is to avoid costly fallback to
383+
* implement it this way is to avoid costly fallback to
386384
* CustomPropertiesBackend (esp. visible when querying all files
387385
* in a folder).
388386
*/

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

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,12 @@
4444
use OCP\Files\FileInfo;
4545
use OCP\Files\IRootFolder;
4646
use OCP\Files\StorageNotAvailableException;
47-
use OCP\Share\IShare;
4847
use OCP\Share\Exceptions\ShareNotFound;
4948
use OCP\Share\IManager;
5049

5150
abstract class Node implements \Sabre\DAV\INode {
52-
5351
/**
54-
* @var \OC\Files\View
52+
* @var View
5553
*/
5654
protected $fileView;
5755

@@ -69,10 +67,7 @@ abstract class Node implements \Sabre\DAV\INode {
6967
*/
7068
protected $property_cache = null;
7169

72-
/**
73-
* @var \OCP\Files\FileInfo
74-
*/
75-
protected $info;
70+
protected FileInfo $info;
7671

7772
/**
7873
* @var IManager
@@ -83,10 +78,6 @@ abstract class Node implements \Sabre\DAV\INode {
8378

8479
/**
8580
* Sets up the node, expects a full path name
86-
*
87-
* @param \OC\Files\View $view
88-
* @param \OCP\Files\FileInfo $info
89-
* @param IManager $shareManager
9081
*/
9182
public function __construct(View $view, FileInfo $info, IManager $shareManager = null) {
9283
$this->fileView = $view;
@@ -109,8 +100,12 @@ public function __construct(View $view, FileInfo $info, IManager $shareManager =
109100
}
110101
}
111102

112-
protected function refreshInfo() {
113-
$this->info = $this->fileView->getFileInfo($this->path);
103+
protected function refreshInfo(): void {
104+
$info = $this->fileView->getFileInfo($this->path);
105+
if ($info === false) {
106+
throw new \Sabre\DAV\Exception('Failed to get fileinfo for '. $this->path);
107+
}
108+
$this->info = $info;
114109
$root = \OC::$server->get(IRootFolder::class);
115110
if ($this->info->getType() === FileInfo::TYPE_FOLDER) {
116111
$this->node = new Folder($root, $this->fileView, $this->path, $this->info);
@@ -145,7 +140,6 @@ public function getPath() {
145140
* @throws \Sabre\DAV\Exception\Forbidden
146141
*/
147142
public function setName($name) {
148-
149143
// rename is only allowed if the update privilege is granted
150144
if (!($this->info->isUpdateable() || ($this->info->getMountPoint() instanceof MoveableMount && $this->info->getInternalPath() === ''))) {
151145
throw new \Sabre\DAV\Exception\Forbidden();
@@ -233,9 +227,10 @@ public function setUploadTime(int $time) {
233227
/**
234228
* Returns the size of the node, in bytes
235229
*
236-
* @return integer
230+
* @psalm-suppress ImplementedReturnTypeMismatch \Sabre\DAV\IFile::getSize signature does not support 32bit
231+
* @return int|float
237232
*/
238-
public function getSize() {
233+
public function getSize(): int|float {
239234
return $this->info->getSize();
240235
}
241236

@@ -271,7 +266,6 @@ public function getInternalFileId() {
271266
* @return int
272267
*/
273268
public function getSharePermissions($user) {
274-
275269
// check of we access a federated share
276270
if ($user !== null) {
277271
try {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function beforeCopy(string $sourcePath, string $destinationPath): bool {
178178
* This method is called before any HTTP method and validates there is enough free space to store the file
179179
*
180180
* @param string $path relative to the users home
181-
* @param int $length
181+
* @param int|float|null $length
182182
* @throws InsufficientStorage
183183
* @return bool
184184
*/

apps/dav/lib/Direct/DirectFile.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ public function getETag() {
7777
return $this->file->getEtag();
7878
}
7979

80+
/**
81+
* @psalm-suppress ImplementedReturnTypeMismatch \Sabre\DAV\IFile::getSize signature does not support 32bit
82+
* @return int|float
83+
*/
8084
public function getSize() {
8185
$this->getFile();
8286

apps/dav/lib/Upload/UploadFile.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
use Sabre\DAV\IFile;
3030

3131
class UploadFile implements IFile {
32-
3332
/** @var File */
3433
private $file;
3534

@@ -53,6 +52,10 @@ public function getETag() {
5352
return $this->file->getETag();
5453
}
5554

55+
/**
56+
* @psalm-suppress ImplementedReturnTypeMismatch \Sabre\DAV\IFile::getSize signature does not support 32bit
57+
* @return int|float
58+
*/
5659
public function getSize() {
5760
return $this->file->getSize();
5861
}

0 commit comments

Comments
 (0)