Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3885818
Add workflow for 32bits testing
come-nc Jan 12, 2023
e156f83
Revert "remove 32-bit workarounds"
come-nc Jan 12, 2023
b370fdb
Running all tests on 32bits to see what happens
come-nc Jan 16, 2023
2d8e696
Add apcu and ffmpeg to have less skipped tests
come-nc Jan 20, 2023
ff776a9
Strong type filesize related methods to ease 32bits problem findings
come-nc Jan 20, 2023
d9dbed9
Fix psalm errors related to filesizes
come-nc Jan 23, 2023
5cfab22
Improve test failure output for RouterTest.php
come-nc Jan 23, 2023
255f230
Fix bigsize support on 32bits in OC_Helper
come-nc Jan 23, 2023
0f8c34c
Fix filesize return type error in ViewTest
come-nc Jan 23, 2023
94ecae4
Add helper to cast to int|float, fix MemoryInfo on 32bits
come-nc Jan 23, 2023
7a628c0
Fix 32bits bigint support in Util/OC_Helper
come-nc Jan 23, 2023
0753be3
Fix a few tests that were using too big int values for 32bits
come-nc Jan 23, 2023
d00422b
Fix computerFileSize when called with a string without unit
come-nc Jan 23, 2023
5aed587
Fix setQuota on User on 32bits
come-nc Jan 23, 2023
5c1a0e0
Allow float sizes in FileInfo for 32bits
come-nc Jan 23, 2023
cd885b5
Type sizes as int|float throughout the code base
come-nc Jan 23, 2023
77c8c9c
Improve error output on failed Router test
come-nc Jan 23, 2023
110fc79
Silence errors of return type mismatch from Sabre for now
come-nc Jan 23, 2023
d315bce
Improve behavior with dates on 32bits and fix tests or skip them
come-nc Jan 23, 2023
b7d9e43
Put back string in $includeMounts as it actually does something
come-nc Jan 24, 2023
db80ac0
Fix name of skip method for phpunit
come-nc Jan 24, 2023
028c225
Fix psalm errors
come-nc Jan 24, 2023
1994554
Fix Sabre connector test
come-nc Jan 24, 2023
885e54e
Psalm easy fixes in apps/files/appinfo/routes.php
come-nc Jan 24, 2023
892e6c6
Skip buggy tests for 32bits CI
come-nc Jan 24, 2023
476d5dc
Skip tests that cannot succeed on 32bits
come-nc Jan 30, 2023
33b5207
Only run 32bit CI once a day
come-nc Jan 30, 2023
1765908
Document that size may be a float in new class VersionEntity
come-nc Jan 30, 2023
c4d90f3
Removed catch of ValueError as we cannot know if it’s >2038 or <1970
come-nc Feb 2, 2023
09a97ad
Move back typing to phpdoc to keep backward compatibility in OCP
come-nc Feb 6, 2023
308fcf4
Respect OCP interface in private classes
come-nc Feb 6, 2023
6e276ad
Show logs on smb-kerberos CI failure
come-nc Feb 7, 2023
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
58 changes: 58 additions & 0 deletions .github/workflows/phpunit-32bits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: PHPUnit

on:
workflow_dispatch:
schedule:
- cron: "15 1 * * 1-6"

permissions:
contents: read

concurrency:
group: phpunit-32bits-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
phpunit-32bits:
runs-on: ubuntu-latest
container: shivammathur/node:latest-i386

strategy:
matrix:
php-versions: ['8.0']

steps:
- name: Checkout server
uses: actions/checkout@v3
with:
submodules: true

- name: Install tools
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg imagemagick libmagickcore-6.q16-3-extra

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ctype, curl, dom, fileinfo, gd, imagick, intl, json, mbstring, openssl, pdo_sqlite, posix, sqlite, xml, zip, apcu
tools: phpunit:9
coverage: none
ini-values:
apc.enabled=on,
apc.enable_cli=on
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Nextcloud
env:
DB_PORT: 4444
run: |
mkdir data
./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
php -f index.php

- name: PHPUnit
working-directory: tests
run: phpunit --configuration phpunit-autotest.xml --exclude-group PRIMARY-azure,PRIMARY-s3,PRIMARY-swift,Memcached,Redis,RoutingWeirdness
6 changes: 6 additions & 0 deletions .github/workflows/smb-kerberos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,9 @@ jobs:
CONTENT=$(./client-cmd.sh ${{ env.DC_IP }} curl -b /shared/cookies/jar -s --negotiate -u [email protected]: --delegation always http://httpd.domain.test/remote.php/webdav/smb/test.txt)
CONTENT=$(echo $CONTENT | head -n 1 | tr -d '[:space:]')
[[ $CONTENT == "testfile" ]]
- name: Show logs
if: failure()
run: |
docker exec --user 33 apache ./occ log:file
FILEPATH=$(docker exec --user 33 apache ./occ log:file | grep "Log file:" | cut -d' ' -f3)
docker exec --user 33 apache cat $FILEPATH
26 changes: 12 additions & 14 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Security\ISecureRandom;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -120,7 +119,6 @@
* @package OCA\DAV\CalDAV
*/
class CalDavBackend extends AbstractBackend implements SyncSupport, SubscriptionSupport, SchedulingSupport {

use TTransactional;

public const CALENDAR_TYPE_CALENDAR = 0;
Expand Down Expand Up @@ -346,7 +344,7 @@ public function getCalendarsForUser($principalUri) {
$row['principaluri'] = (string) $row['principaluri'];
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
$components = explode(',', $row['components']);
}

$calendar = [
Expand Down Expand Up @@ -420,7 +418,7 @@ public function getCalendarsForUser($principalUri) {
$row['displayname'] = $row['displayname'] . ' (' . ($this->userManager->getDisplayName($name) ?? ($name ?? '')) . ')';
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
$components = explode(',', $row['components']);
}
$calendar = [
'id' => $row['id'],
Expand Down Expand Up @@ -469,7 +467,7 @@ public function getUsersOwnCalendars($principalUri) {
$row['principaluri'] = (string) $row['principaluri'];
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
$components = explode(',', $row['components']);
}
$calendar = [
'id' => $row['id'],
Expand Down Expand Up @@ -521,7 +519,7 @@ public function getPublicCalendars() {
$row['displayname'] = $row['displayname'] . "($name)";
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
$components = explode(',', $row['components']);
}
$calendar = [
'id' => $row['id'],
Expand Down Expand Up @@ -586,7 +584,7 @@ public function getPublicCalendar($uri) {
$row['displayname'] = $row['displayname'] . ' ' . "($name)";
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
$components = explode(',', $row['components']);
}
$calendar = [
'id' => $row['id'],
Expand Down Expand Up @@ -639,7 +637,7 @@ public function getCalendarByUri($principal, $uri) {
$row['principaluri'] = (string) $row['principaluri'];
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
$components = explode(',', $row['components']);
}

$calendar = [
Expand Down Expand Up @@ -687,7 +685,7 @@ public function getCalendarById(int $calendarId): ?array {
$row['principaluri'] = (string) $row['principaluri'];
$components = [];
if ($row['components']) {
$components = explode(',',$row['components']);
$components = explode(',', $row['components']);
}

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

[$calendarId, $calendarData] = $this->atomic(function() use ($values) {
[$calendarId, $calendarData] = $this->atomic(function () use ($values) {
$query = $this->db->getQueryBuilder();
$query->insert('calendars');
foreach ($values as $column => $value) {
Expand Down Expand Up @@ -1712,7 +1710,7 @@ public function calendarSearch($principalUri, array $filters, $limit = null, $of
$query->expr()->eq('c.calendarid',
$query->createNamedParameter($id)),
$query->expr()->eq('c.calendartype',
$query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
$query->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
}
foreach ($sharedCalendars as $id) {
$calendarExpressions[] = $query->expr()->andX(
Expand Down Expand Up @@ -1860,7 +1858,7 @@ public function search(array $calendarInfo, $pattern, array $searchProperties,
}
}

if(isset($options['uid'])) {
if (isset($options['uid'])) {
$outerQuery->andWhere($outerQuery->expr()->eq('uid', $outerQuery->createNamedParameter($options['uid'])));
}

Expand Down Expand Up @@ -2435,7 +2433,7 @@ public function createSubscription($principalUri, $uri, array $properties) {
}
}

[$subscriptionId, $subscriptionRow] = $this->atomic(function() use ($values) {
[$subscriptionId, $subscriptionRow] = $this->atomic(function () use ($values) {
$valuesToInsert = [];
$query = $this->db->getQueryBuilder();
foreach (array_keys($values) as $name) {
Expand Down
5 changes: 1 addition & 4 deletions apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function __construct(View $view, FileInfo $info, IManager $shareManager =
public function put($data) {
try {
$exists = $this->fileView->file_exists($this->path);
if ($this->info && $exists && !$this->info->isUpdateable()) {
if ($exists && !$this->info->isUpdateable()) {
throw new Forbidden();
}
} catch (StorageNotAvailableException $e) {
Expand Down Expand Up @@ -759,9 +759,6 @@ private function convertToSabreException(\Exception $e) {
* @return string|null
*/
public function getChecksum() {
if (!$this->info) {
return null;
}
return $this->info->getChecksum();
}

Expand Down
6 changes: 2 additions & 4 deletions apps/dav/lib/Connector/Sabre/FilesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@
use Sabre\DAV\Tree;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
use Sabre\Uri;

class FilesPlugin extends ServerPlugin {

// namespace
public const NS_OWNCLOUD = 'http://owncloud.org/ns';
public const NS_NEXTCLOUD = 'http://nextcloud.org/ns';
Expand Down Expand Up @@ -352,7 +350,7 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
$propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function () use ($node) {
return json_encode($this->previewManager->isAvailable($node->getFileInfo()), JSON_THROW_ON_ERROR);
});
$propFind->handle(self::SIZE_PROPERTYNAME, function () use ($node): ?int {
$propFind->handle(self::SIZE_PROPERTYNAME, function () use ($node): int|float {
return $node->getSize();
});
$propFind->handle(self::MOUNT_TYPE_PROPERTYNAME, function () use ($node) {
Expand Down Expand Up @@ -382,7 +380,7 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
});
/**
* Return file/folder name as displayname. The primary reason to
* implement it this way is to avoid costly fallback to
* implement it this way is to avoid costly fallback to
* CustomPropertiesBackend (esp. visible when querying all files
* in a folder).
*/
Expand Down
28 changes: 11 additions & 17 deletions apps/dav/lib/Connector/Sabre/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@
use OCP\Files\FileInfo;
use OCP\Files\IRootFolder;
use OCP\Files\StorageNotAvailableException;
use OCP\Share\IShare;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;

abstract class Node implements \Sabre\DAV\INode {

/**
* @var \OC\Files\View
* @var View
*/
protected $fileView;

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

/**
* @var \OCP\Files\FileInfo
*/
protected $info;
protected FileInfo $info;

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

/**
* Sets up the node, expects a full path name
*
* @param \OC\Files\View $view
* @param \OCP\Files\FileInfo $info
* @param IManager $shareManager
*/
public function __construct(View $view, FileInfo $info, IManager $shareManager = null) {
$this->fileView = $view;
Expand All @@ -109,8 +100,12 @@ public function __construct(View $view, FileInfo $info, IManager $shareManager =
}
}

protected function refreshInfo() {
$this->info = $this->fileView->getFileInfo($this->path);
protected function refreshInfo(): void {
$info = $this->fileView->getFileInfo($this->path);
if ($info === false) {
throw new \Sabre\DAV\Exception('Failed to get fileinfo for '. $this->path);
}
$this->info = $info;
$root = \OC::$server->get(IRootFolder::class);
if ($this->info->getType() === FileInfo::TYPE_FOLDER) {
$this->node = new Folder($root, $this->fileView, $this->path, $this->info);
Expand Down Expand Up @@ -145,7 +140,6 @@ public function getPath() {
* @throws \Sabre\DAV\Exception\Forbidden
*/
public function setName($name) {

// rename is only allowed if the update privilege is granted
if (!($this->info->isUpdateable() || ($this->info->getMountPoint() instanceof MoveableMount && $this->info->getInternalPath() === ''))) {
throw new \Sabre\DAV\Exception\Forbidden();
Expand Down Expand Up @@ -233,9 +227,10 @@ public function setUploadTime(int $time) {
/**
* Returns the size of the node, in bytes
*
* @return integer
* @psalm-suppress ImplementedReturnTypeMismatch \Sabre\DAV\IFile::getSize signature does not support 32bit
* @return int|float
*/
public function getSize() {
public function getSize(): int|float {
return $this->info->getSize();
}

Expand Down Expand Up @@ -271,7 +266,6 @@ public function getInternalFileId() {
* @return int
*/
public function getSharePermissions($user) {

// check of we access a federated share
if ($user !== null) {
try {
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/QuotaPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function beforeCopy(string $sourcePath, string $destinationPath): bool {
* This method is called before any HTTP method and validates there is enough free space to store the file
*
* @param string $path relative to the users home
* @param int $length
* @param int|float|null $length
* @throws InsufficientStorage
* @return bool
*/
Expand Down
4 changes: 4 additions & 0 deletions apps/dav/lib/Direct/DirectFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public function getETag() {
return $this->file->getEtag();
}

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

Expand Down
5 changes: 4 additions & 1 deletion apps/dav/lib/Upload/UploadFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
use Sabre\DAV\IFile;

class UploadFile implements IFile {

/** @var File */
private $file;

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

/**
* @psalm-suppress ImplementedReturnTypeMismatch \Sabre\DAV\IFile::getSize signature does not support 32bit
* @return int|float
*/
public function getSize() {
return $this->file->getSize();
}
Expand Down
Loading