Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Improve behavior with dates on 32bits and fix tests or skip them
We do not support events after 2038 on 32bits but still behave better
 when date range start/end is after 2038.

Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Feb 7, 2023
commit d315bce30041b8521db1433ea115a021b261ebf6
39 changes: 23 additions & 16 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 @@ -1635,10 +1633,19 @@ public function calendarQuery($calendarId, array $filters, $calendarType = self:
}

if ($timeRange && $timeRange['start']) {
$query->andWhere($query->expr()->gt('lastoccurence', $query->createNamedParameter($timeRange['start']->getTimeStamp())));
try {
$query->andWhere($query->expr()->gt('lastoccurence', $query->createNamedParameter($timeRange['start']->getTimeStamp())));
} catch (\ValueError) {
/* Will happen for dates too far in the future on 32bit, return no results */
return [];
}
}
if ($timeRange && $timeRange['end']) {
$query->andWhere($query->expr()->lt('firstoccurence', $query->createNamedParameter($timeRange['end']->getTimeStamp())));
try {
$query->andWhere($query->expr()->lt('firstoccurence', $query->createNamedParameter($timeRange['end']->getTimeStamp())));
} catch (\ValueError) {
/* Will happen for dates too far in the future on 32bit, ignore the limit in this case */
}
}

$stmt = $query->executeQuery();
Expand Down Expand Up @@ -1712,7 +1719,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 +1867,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 +2442,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
10 changes: 7 additions & 3 deletions apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ public function providesSharingData() {
* @dataProvider providesSharingData
*/
public function testCalendarSharing($userCanRead, $userCanWrite, $groupCanRead, $groupCanWrite, $add): void {

/** @var IL10N|\PHPUnit\Framework\MockObject\MockObject $l10n */
$l10n = $this->createMock(IL10N::class);
$l10n
Expand Down Expand Up @@ -423,7 +422,12 @@ public function testCalendarQuery($expectedEventsInResult, $propFilters, $compFi
$events[0] = $this->createEvent($calendarId, '20130912T130000Z', '20130912T140000Z');
$events[1] = $this->createEvent($calendarId, '20130912T150000Z', '20130912T170000Z');
$events[2] = $this->createEvent($calendarId, '20130912T173000Z', '20130912T220000Z');
$events[3] = $this->createEvent($calendarId, '21130912T130000Z', '22130912T130000Z');
if (PHP_INT_SIZE > 8) {
$events[3] = $this->createEvent($calendarId, '21130912T130000Z', '22130912T130000Z');
} else {
/* On 32bit we do not support events after 2038 */
$events[3] = $this->createEvent($calendarId, '20370912T130000Z', '20370912T130000Z');
}

$result = $this->backend->calendarQuery($calendarId, [
'name' => '',
Expand Down Expand Up @@ -471,7 +475,7 @@ public function providesCalendarQueryParameters() {
'only-events' => [[0, 1, 2, 3], [], [['name' => 'VEVENT', 'is-not-defined' => false, 'comp-filters' => [], 'time-range' => ['start' => null, 'end' => null], 'prop-filters' => []]],],
'start' => [[1, 2, 3], [], [['name' => 'VEVENT', 'is-not-defined' => false, 'comp-filters' => [], 'time-range' => ['start' => new DateTime('2013-09-12 14:00:00', new DateTimeZone('UTC')), 'end' => null], 'prop-filters' => []]],],
'end' => [[0], [], [['name' => 'VEVENT', 'is-not-defined' => false, 'comp-filters' => [], 'time-range' => ['start' => null, 'end' => new DateTime('2013-09-12 14:00:00', new DateTimeZone('UTC'))], 'prop-filters' => []]],],
'future' => [[3], [], [['name' => 'VEVENT', 'is-not-defined' => false, 'comp-filters' => [], 'time-range' => ['start' => new DateTime('2099-09-12 14:00:00', new DateTimeZone('UTC')), 'end' => null], 'prop-filters' => []]],],
'future' => [[3], [], [['name' => 'VEVENT', 'is-not-defined' => false, 'comp-filters' => [], 'time-range' => ['start' => new DateTime('2036-09-12 14:00:00', new DateTimeZone('UTC')), 'end' => null], 'prop-filters' => []]],],
];
}

Expand Down
5 changes: 4 additions & 1 deletion apps/files/tests/HelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ public function sortDataProvider() {
/**
* @dataProvider sortDataProvider
*/
public function testSortByName($sort, $sortDescending, $expectedOrder) {
public function testSortByName(string $sort, bool $sortDescending, array $expectedOrder) {
if (($sort === 'mtime') && (PHP_INT_SIZE < 8)) {
$this->skip('Skip mtime sorting on 32bit');
}
$files = self::getTestFileList();
$files = \OCA\Files\Helper::sortFiles($files, $sort, $sortDescending);
$fileNames = [];
Expand Down