Skip to content

Commit cbbb991

Browse files
authored
Merge pull request #63114 from nextcloud/fix/fix-32bits-support-35
Fix errors from 32bits CI
2 parents 8a75509 + d9867d7 commit cbbb991

11 files changed

Lines changed: 90 additions & 60 deletions

File tree

.github/workflows/phpunit-32bits.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ jobs:
2929

3030
strategy:
3131
fail-fast: false
32-
matrix:
33-
php-versions: ['8.3', '8,5']
3432

3533
steps:
3634
- name: Checkout server
@@ -43,7 +41,7 @@ jobs:
4341
uses: docker://ghcr.io/nextcloud/continuous-integration-php8.4-32bit:latest
4442
with:
4543
args: /bin/sh -c "
46-
git config --global --add safe.directory /github/workspace &&
44+
git config --global --add safe.directory ${GITHUB_WORKSPACE} &&
4745
composer install --no-interaction"
4846

4947
- name: Set up Nextcloud

apps/sharing/lib/ResponseDefinitions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
* id: non-empty-string,
124124
* owner: SharingUser,
125125
* // Unix time in milliseconds
126-
* last_updated: non-negative-int,
126+
* last_updated: numeric-string,
127127
* state: SharingState,
128128
* sources: list<SharingSource>,
129129
* recipients: list<SharingRecipient>,

apps/sharing/openapi.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,8 @@
465465
"$ref": "#/components/schemas/User"
466466
},
467467
"last_updated": {
468-
"type": "integer",
469-
"format": "int64",
470-
"description": "Unix time in milliseconds",
471-
"minimum": 0
468+
"type": "string",
469+
"description": "Unix time in milliseconds"
472470
},
473471
"state": {
474472
"$ref": "#/components/schemas/State"

apps/sharing/tests/Command/CommandTest.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ protected function searchRecipients(ShareAccessContext $accessContext, ?array $f
164164
}
165165

166166
/**
167-
* @return array<string, mixed>
167+
* @return SharingShare
168168
*/
169169
#[Override]
170170
protected function createShare(ShareAccessContext $accessContext): array {
@@ -177,12 +177,12 @@ protected function createShare(ShareAccessContext $accessContext): array {
177177
],
178178
[],
179179
);
180-
/** @psalm-suppress MixedReturnStatement */
180+
/** @var SharingShare */
181181
return json_decode($stdout, true, 512, JSON_THROW_ON_ERROR);
182182
}
183183

184184
/**
185-
* @return array<string, mixed>
185+
* @return SharingShare
186186
*/
187187
#[Override]
188188
protected function updateShareState(ShareAccessContext $accessContext, string $id, ShareState $state): array {
@@ -195,12 +195,12 @@ protected function updateShareState(ShareAccessContext $accessContext, string $i
195195
],
196196
[],
197197
);
198-
/** @psalm-suppress MixedReturnStatement */
198+
/** @var SharingShare */
199199
return json_decode($stdout, true, 512, JSON_THROW_ON_ERROR);
200200
}
201201

202202
/**
203-
* @return array<string, mixed>
203+
* @return SharingShare
204204
*/
205205
#[Override]
206206
protected function addShareSource(ShareAccessContext $accessContext, string $id, ShareSource $source): array {
@@ -214,12 +214,12 @@ protected function addShareSource(ShareAccessContext $accessContext, string $id,
214214
],
215215
[],
216216
);
217-
/** @psalm-suppress MixedReturnStatement */
217+
/** @var SharingShare */
218218
return json_decode($stdout, true, 512, JSON_THROW_ON_ERROR);
219219
}
220220

221221
/**
222-
* @return array<string, mixed>
222+
* @return SharingShare
223223
*/
224224
#[Override]
225225
protected function removeShareSource(ShareAccessContext $accessContext, string $id, ShareSource $source): array {
@@ -233,12 +233,12 @@ protected function removeShareSource(ShareAccessContext $accessContext, string $
233233
],
234234
[],
235235
);
236-
/** @psalm-suppress MixedReturnStatement */
236+
/** @var SharingShare */
237237
return json_decode($stdout, true, 512, JSON_THROW_ON_ERROR);
238238
}
239239

240240
/**
241-
* @return array<string, mixed>
241+
* @return SharingShare
242242
*/
243243
#[Override]
244244
protected function addShareRecipient(ShareAccessContext $accessContext, string $id, ShareRecipient $recipient): array {
@@ -253,12 +253,12 @@ protected function addShareRecipient(ShareAccessContext $accessContext, string $
253253
],
254254
[],
255255
);
256-
/** @psalm-suppress MixedReturnStatement */
256+
/** @var SharingShare */
257257
return json_decode($stdout, true, 512, JSON_THROW_ON_ERROR);
258258
}
259259

260260
/**
261-
* @return array<string, mixed>
261+
* @return SharingShare
262262
*/
263263
#[Override]
264264
protected function removeShareRecipient(ShareAccessContext $accessContext, string $id, ShareRecipient $recipient): array {
@@ -273,12 +273,12 @@ protected function removeShareRecipient(ShareAccessContext $accessContext, strin
273273
],
274274
[],
275275
);
276-
/** @psalm-suppress MixedReturnStatement */
276+
/** @var SharingShare */
277277
return json_decode($stdout, true, 512, JSON_THROW_ON_ERROR);
278278
}
279279

280280
/**
281-
* @return array<string, mixed>
281+
* @return SharingShare
282282
*/
283283
#[Override]
284284
protected function updateShareRecipientSecret(ShareAccessContext $accessContext, string $id, ShareRecipient $recipient, string $secret): array {
@@ -294,12 +294,12 @@ protected function updateShareRecipientSecret(ShareAccessContext $accessContext,
294294
],
295295
[],
296296
);
297-
/** @psalm-suppress MixedReturnStatement */
297+
/** @var SharingShare */
298298
return json_decode($stdout, true, 512, JSON_THROW_ON_ERROR);
299299
}
300300

301301
/**
302-
* @return array<string, mixed>
302+
* @return SharingShare
303303
*/
304304
#[Override]
305305
protected function updateShareProperty(ShareAccessContext $accessContext, string $id, ShareProperty $property): array {
@@ -313,12 +313,12 @@ protected function updateShareProperty(ShareAccessContext $accessContext, string
313313
],
314314
[],
315315
);
316-
/** @psalm-suppress MixedReturnStatement */
316+
/** @var SharingShare */
317317
return json_decode($stdout, true, 512, JSON_THROW_ON_ERROR);
318318
}
319319

320320
/**
321-
* @return array<string, mixed>
321+
* @return SharingShare
322322
*/
323323
#[Override]
324324
protected function updateSharePermission(ShareAccessContext $accessContext, string $id, SharePermission $permission): array {
@@ -332,12 +332,12 @@ protected function updateSharePermission(ShareAccessContext $accessContext, stri
332332
],
333333
[],
334334
);
335-
/** @psalm-suppress MixedReturnStatement */
335+
/** @var SharingShare */
336336
return json_decode($stdout, true, 512, JSON_THROW_ON_ERROR);
337337
}
338338

339339
/**
340-
* @return array<string, mixed>
340+
* @return SharingShare
341341
*/
342342
#[Override]
343343
protected function selectSharePermissionPreset(ShareAccessContext $accessContext, string $id, string $permissionPresetClass): array {
@@ -350,7 +350,7 @@ protected function selectSharePermissionPreset(ShareAccessContext $accessContext
350350
],
351351
[],
352352
);
353-
/** @psalm-suppress MixedReturnStatement */
353+
/** @var SharingShare */
354354
return json_decode($stdout, true, 512, JSON_THROW_ON_ERROR);
355355
}
356356

@@ -379,7 +379,7 @@ protected function getShare(ShareAccessContext $accessContext, string $id): arra
379379
],
380380
[],
381381
);
382-
/** @psalm-suppress MixedReturnStatement */
382+
/** @var SharingShare */
383383
return json_decode($stdout, true, 512, JSON_THROW_ON_ERROR);
384384
}
385385

@@ -399,7 +399,7 @@ protected function getShares(ShareAccessContext $accessContext, ?string $filterS
399399
['limit', $limit],
400400
],
401401
);
402-
/** @psalm-suppress MixedReturnStatement */
402+
/** @var SharingShare[] */
403403
return json_decode($stdout, true, 512, JSON_THROW_ON_ERROR);
404404
}
405405
}

apps/sharing/tests/Controller/ApiV1ControllerTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,53 +95,63 @@ protected function searchRecipients(ShareAccessContext $accessContext, ?array $f
9595

9696
#[Override]
9797
protected function createShare(ShareAccessContext $accessContext): array {
98+
/** @var SharingShare */
9899
return $this->executeRequest($accessContext, fn (ApiV1Controller $controller): DataResponse => $controller->createShare());
99100
}
100101

101102
#[Override]
102103
protected function updateShareState(ShareAccessContext $accessContext, string $id, ShareState $state): array {
104+
/** @var SharingShare */
103105
return $this->executeRequest($accessContext, fn (ApiV1Controller $controller): DataResponse => $controller->updateShareState($id, $state->value));
104106
}
105107

106108
#[Override]
107109
protected function addShareSource(ShareAccessContext $accessContext, string $id, ShareSource $source): array {
110+
/** @var SharingShare */
108111
return $this->executeRequest($accessContext, fn (ApiV1Controller $controller): DataResponse => $controller->addShareSource($id, $source->class, $source->value));
109112
}
110113

111114
#[Override]
112115
protected function removeShareSource(ShareAccessContext $accessContext, string $id, ShareSource $source): array {
116+
/** @var SharingShare */
113117
return $this->executeRequest($accessContext, fn (ApiV1Controller $controller): DataResponse => $controller->removeShareSource($id, $source->class, $source->value));
114118
}
115119

116120
#[Override]
117121
protected function addShareRecipient(ShareAccessContext $accessContext, string $id, ShareRecipient $recipient): array {
122+
/** @var SharingShare */
118123
return $this->executeRequest($accessContext, fn (ApiV1Controller $controller): DataResponse => $controller->addShareRecipient($id, $recipient->class, $recipient->value, $recipient->instance));
119124
}
120125

121126
#[Override]
122127
protected function removeShareRecipient(ShareAccessContext $accessContext, string $id, ShareRecipient $recipient): array {
128+
/** @var SharingShare */
123129
return $this->executeRequest($accessContext, fn (ApiV1Controller $controller): DataResponse => $controller->removeShareRecipient($id, $recipient->class, $recipient->value, $recipient->instance));
124130
}
125131

126132
#[Override]
127133
protected function updateShareRecipientSecret(ShareAccessContext $accessContext, string $id, ShareRecipient $recipient, string $secret): array {
128134
/** @psalm-suppress ArgumentTypeCoercion */
135+
/** @var SharingShare */
129136
return $this->executeRequest($accessContext, fn (ApiV1Controller $controller): DataResponse => $controller->updateShareRecipientSecret($id, $recipient->class, $recipient->value, $recipient->instance, $secret));
130137
}
131138

132139
#[Override]
133140
protected function updateShareProperty(ShareAccessContext $accessContext, string $id, ShareProperty $property): array {
141+
/** @var SharingShare */
134142
return $this->executeRequest($accessContext, fn (ApiV1Controller $controller): DataResponse => $controller->updateShareProperty($id, $property->class, $property->value));
135143
}
136144

137145
#[Override]
138146
protected function updateSharePermission(ShareAccessContext $accessContext, string $id, SharePermission $permission): array {
147+
/** @var SharingShare */
139148
return $this->executeRequest($accessContext, fn (ApiV1Controller $controller): DataResponse => $controller->updateSharePermission($id, $permission->class, $permission->enabled));
140149
}
141150

142151
#[Override]
143152
protected function selectSharePermissionPreset(ShareAccessContext $accessContext, string $id, string $permissionPresetClass): array {
144153
/** @psalm-suppress ArgumentTypeCoercion */
154+
/** @var SharingShare */
145155
return $this->executeRequest($accessContext, fn (ApiV1Controller $controller): DataResponse => $controller->selectSharePermissionPreset($id, $permissionPresetClass));
146156
}
147157

@@ -150,11 +160,9 @@ protected function deleteShare(ShareAccessContext $accessContext, string $id): v
150160
$this->executeRequest($accessContext, fn (ApiV1Controller $controller): DataResponse => $controller->deleteShare($id));
151161
}
152162

153-
/**
154-
* @psalm-suppress MixedReturnTypeCoercion
155-
*/
156163
#[Override]
157164
protected function getShare(ShareAccessContext $accessContext, string $id): array {
165+
/** @var SharingShare */
158166
return $this->executeRequest(new ShareAccessContext($accessContext->currentUser, null, [], $accessContext->overrideChecks), fn (ApiV1Controller $controller): DataResponse => $controller->getShare($id, $accessContext->secret, $accessContext->arguments));
159167
}
160168

lib/private/ServerInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function getServerId(): int {
2525
if ($serverid < 1) {
2626
// Fallback: generates a server ID based on hostname
2727
/** @var int<0,max> */
28-
$serverid = PHP_INT_SIZE === 4
28+
$serverid = PHP_INT_SIZE === 8
2929
? hexdec(hash('xxh32', $this->getHostname()))
3030
// Makes sure it doesn't overflow 32 bits int
3131
: hexdec(substr(hash('xxh32', $this->getHostname()), -3));

lib/private/Sharing/SharingBackend.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,8 @@ public function setLastUpdated(array $ids, \DateTimeImmutable $lastUpdated): voi
543543

544544
$rowCount = $qb
545545
->update('sharing_share')
546-
->set('last_updated', $qb->createNamedParameter(SharingManager::timeToMs($lastUpdated), IQueryBuilder::PARAM_INT))
547-
->where($qb->expr()->in('id', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY)))
546+
->set('last_updated', $qb->createNamedParameter(SharingManager::timeToMs($lastUpdated)))
547+
->where($qb->expr()->in('id', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_STR_ARRAY)))
548548
->executeStatement();
549549
if ($rowCount !== count($chunk)) {
550550
throw new ShareNotFoundException();
@@ -618,7 +618,7 @@ private function list(ShareAccessContext $accessContext, ?string $filterShareID,
618618
}
619619

620620
// The key type is array-key, because PHP will automatically cast the value. We can't type it as integer though, because we need to also support 32 bit systems and there the autocasting doesn't happen, if the value is too large.
621-
/** @var array<array-key, array{id: non-empty-string, owner: ShareUser, last_updated: non-negative-int, state: ShareState, sources: list<ShareSource>, recipients: list<ShareRecipient>, properties: array<class-string<ISharePropertyType>, ShareProperty>, permissions: array<class-string<ISharePermissionType>, SharePermission>}> $shares */
621+
/** @var array<array-key, array{id: non-empty-string, owner: ShareUser, last_updated: numeric-string, state: ShareState, sources: list<ShareSource>, recipients: list<ShareRecipient>, properties: array<class-string<ISharePropertyType>, ShareProperty>, permissions: array<class-string<ISharePermissionType>, SharePermission>}> $shares */
622622
$shares = [];
623623
foreach ($queries as $qb) {
624624
$qb
@@ -672,8 +672,8 @@ private function list(ShareAccessContext $accessContext, ?string $filterShareID,
672672

673673
/** @var non-empty-string $id */
674674
$id = (string)$row['id'];
675-
/** @var non-negative-int $lastUpdated */
676-
$lastUpdated = (int)$row['last_updated'];
675+
/** @var numeric-string $lastUpdated */
676+
$lastUpdated = (string)$row['last_updated'];
677677
/** @var string $state */
678678
$state = $row['state'];
679679
$shares[$id] ??= [
@@ -718,10 +718,10 @@ private function list(ShareAccessContext $accessContext, ?string $filterShareID,
718718
'ss.source_value',
719719
)
720720
->from('sharing_share_sources', 'ss')
721-
->where($qb->expr()->in('ss.share_id', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY)));
721+
->where($qb->expr()->in('ss.share_id', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_STR_ARRAY)));
722722

723723
$result = $qb->executeQuery();
724-
/** @var array{source_class_id: mixed, source_value: non-empty-string, share_id: int}[] $rows */
724+
/** @var array{source_class_id: mixed, source_value: non-empty-string, share_id: string}[] $rows */
725725
$rows = $result->fetchAll();
726726

727727
foreach ($rows as $row) {
@@ -749,7 +749,7 @@ private function list(ShareAccessContext $accessContext, ?string $filterShareID,
749749
}
750750

751751
$value = $row['source_value'];
752-
$id = (string)$row['share_id'];
752+
$id = $row['share_id'];
753753
$shares[$id]['sources'][] = new ShareSource(
754754
$typeClass,
755755
$value,
@@ -777,7 +777,7 @@ private function list(ShareAccessContext $accessContext, ?string $filterShareID,
777777
'sr.initiator_instance',
778778
)
779779
->from('sharing_share_recipients', 'sr')
780-
->where($qb->expr()->in('sr.share_id', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY)));
780+
->where($qb->expr()->in('sr.share_id', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_STR_ARRAY)));
781781

782782
foreach ($qb->executeQuery()->fetchAll() as $row) {
783783
/** @var class-string<IShareRecipientType> $typeClass */
@@ -890,7 +890,7 @@ private function list(ShareAccessContext $accessContext, ?string $filterShareID,
890890
'sp.property_value',
891891
)
892892
->from('sharing_share_properties', 'sp')
893-
->where($qb->expr()->in('sp.share_id', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY)));
893+
->where($qb->expr()->in('sp.share_id', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_STR_ARRAY)));
894894

895895
$result = $qb->executeQuery();
896896
foreach ($result->fetchAll() as $row) {
@@ -961,7 +961,7 @@ private function list(ShareAccessContext $accessContext, ?string $filterShareID,
961961
'sp.permission_enabled',
962962
)
963963
->from('sharing_share_permissions', 'sp')
964-
->where($qb->expr()->in('sp.share_id', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY)));
964+
->where($qb->expr()->in('sp.share_id', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_STR_ARRAY)));
965965

966966
$result = $qb->executeQuery();
967967
foreach ($result->fetchAll() as $row) {
@@ -1110,7 +1110,7 @@ public function createSharePermissionDefaultValue(Share $share, string $permissi
11101110
return $share;
11111111
}
11121112

1113-
private static function parseTimestamp(int $timestampMs): \DateTimeImmutable {
1113+
private static function parseTimestamp(string $timestampMs): \DateTimeImmutable {
11141114
if (method_exists(\DateTimeImmutable::class, 'createFromTimestamp')) {
11151115
// with php 8.3 the method doesn't exist and psalm doesn't know the return type
11161116
/** @psalm-suppress MixedReturnStatement */

0 commit comments

Comments
 (0)