fix: reindex array after array_diff to prevent malformed output (#11741)#11780
fix: reindex array after array_diff to prevent malformed output (#11741)#11780aakarsh12x wants to merge 5 commits intoappwrite:1.9.xfrom
Conversation
Greptile SummaryThis PR fixes a subtle but real PHP serialization bug in the GitHub pull request cleanup flow:
Confidence Score: 5/5Safe to merge — the fix is correct, minimal, and addresses a real data-integrity issue without introducing new risk. Single, well-understood one-line change that wraps No files require special attention.
|
| Filename | Overview |
|---|---|
| src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php | Single-line fix: wraps array_diff() with array_values() to reindex providerPullRequestIds before persisting, preventing sparse-array / JSON-object serialization issues. Change is correct and safe. |
Reviews (5): Last reviewed commit: "Merge branch 'appwrite:1.9.x' into fix/1..." | Re-trigger Greptile
|
@ChiragAgg5k could you please review this PR? |
Summary
This fixes an issue in the GitHub pull request cleanup flow where �rray_diff() was used without reindexing the result before storing it back on the repository document.
Root Cause
�rray_diff() preserves the original numeric keys. After removing a pull request ID from providerPullRequestIds, the resulting array could contain gaps in its indexes.
When that sparse array was stored, it could be serialized as an object-like structure instead of a proper JSON array, which can break downstream code expecting a sequential list.
Fix
Wrap the existing �rray_diff() call with �rray_values() in src/Appwrite/Platform/Modules/VCS/Http/GitHub/Events/Create.php so providerPullRequestIds is always reindexed before it is written back.
Why This Change Is Minimal
This keeps the patch intentionally small and follows the existing pattern already used elsewhere in the codebase for �rray_diff() results that are persisted or returned.