Skip to content

fix(sharing): key shares by string when loading share permissions - #63291

Open
solracsf wants to merge 1 commit into
masterfrom
fix/sharing-backend-32bit-share-id
Open

fix(sharing): key shares by string when loading share permissions#63291
solracsf wants to merge 1 commit into
masterfrom
fix/sharing-backend-32bit-share-id

Conversation

@solracsf

@solracsf solracsf commented Aug 15, 2026

Copy link
Copy Markdown
Member

Summary

Fixes 32bits CI failures: https://github.com/nextcloud/server/actions/runs/31869049089/job/94981641073

list() builds the $shares array with (string)$row['share_id'], but the permission loading loop looked the same share up with (int)$row['share_id'].

share_id is a 64 bit snowflake. On 64 bit PHP a numeric string array key is normalised to an integer key, so the int lookup lands on the same entry and the mismatch is invisible. On 32 bit the value is larger than PHP_INT_MAX, so the key stays a string while the cast saturates to 2147483647 and every lookup misses.

The share then comes back with no permissions, ensureDefaults() decides the permission is missing and inserts it a second time, which fails with a unique constraint violation on sharing_share_permissions and leaves the transaction open.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@solracsf solracsf added this to the Nextcloud 35 milestone Aug 15, 2026
@solracsf
solracsf requested a review from a team as a code owner August 15, 2026 09:25
@solracsf solracsf added the bug label Aug 15, 2026
@solracsf
solracsf requested review from Altahrim, CarlSchwan and leftybournes and removed request for a team August 15, 2026 09:25
@solracsf solracsf added the feature: 32bits Bug specific to 32bits architectures label Aug 15, 2026
@solracsf
solracsf requested a review from come-nc August 15, 2026 09:25
@solracsf solracsf added the 3. to review Waiting for reviews label Aug 15, 2026
list() builds the $shares array with (string)$row['share_id'], but the
permission loading loop looked the same share up with (int)$row['share_id'].

share_id is a 64 bit snowflake. On 64 bit PHP a numeric string array key is
normalised to an integer key, so the int lookup lands on the same entry and
the mismatch is invisible. On 32 bit the value is larger than PHP_INT_MAX, so
the key stays a string while the cast saturates to 2147483647 and every
lookup misses.

The share then comes back with no permissions, ensureDefaults() decides the
permission is missing and inserts it a second time, which fails with a unique
constraint violation on sharing_share_permissions and leaves the transaction
open. That is the whole phpunit-32bits failure: 54 errors and 26 failures in
tests/lib/Sharing alone, cascading into 180 errors and 81 failures across the
suite once the leftover test users start colliding.

Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews bug feature: 32bits Bug specific to 32bits architectures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant