Skip to content

Missing array_values() after array_diff() in VCS GitHub PR cleanup causes malformed array storage #11741

Closed

Description

@zaidxshaikh

Description

In src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php (line 237), when a pull request is closed and external contribution cleanup runs, array_diff() is used to remove the PR ID from providerPullRequestIds without wrapping in array_values().

Problem

array_diff() preserves the original numeric keys after removing elements. For example:

$ids = ['101', '102', '103'];
$result = array_diff($ids, ['102']);
// Result: [0 => '101', 2 => '103'] — gap at index 1

When this is stored in the database (JSON-encoded), PHP produces a JSON object {"0":"101","2":"103"} instead of a JSON array ["101","103"]. This can cause type mismatches when the data is read back and expected to be a sequential array.

Evidence

Other parts of the codebase correctly use array_values() after array_diff():

  • src/Appwrite/Platform/Modules/Databases/Workers/Databases.php:368 — \array_values(\array_diff(...))
  • src/Appwrite/Platform/Modules/Account/Http/Account/MFA/Challenges/Update.php:150 — \array_values(\array_diff(...))

Fix

Wrap the array_diff() call with array_values() to reindex the array:

$providerPullRequestIds = \array_values(\array_diff($providerPullRequestIds, [$providerPullRequestId]));

Activity

  1. added
    product / databases
    product / messaging
    product / storage
    on Apr 1, 2026
  2. elijahsanders152-stack commented on Apr 5, 2026

    @elijahsanders152-stack
  3. zaidxshaikh commented on Apr 5, 2026

    @zaidxshaikh
    Author

    Thanks for your interest @InderjeetSingh4! I've already submitted a PR for this fix — #11742. It's currently under review.

  4. HarshMN2345 commented on Sep 8, 2026

    @HarshMN2345
    Member

    fixed in #13530, closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    product / databasesproduct / messagingproduct / storage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions