Skip to content

fix(sharing): Reindex sharing group lists when a group is deleted - #67684

Open
kukanggg89 wants to merge 1 commit into
nextcloud:masterfrom
kukanggg89:fix-group-deleted-exclude-groups-json-67451
Open

kukanggg89 wants to merge 1 commit into
nextcloud:masterfrom
kukanggg89:fix-group-deleted-exclude-groups-json-67451

Conversation

@kukanggg89

Copy link
Copy Markdown
Contributor

Summary

Deleting a group ran shareapi_exclude_groups_list through array_diff(), which keeps the original array keys. Removing any group but the last one left the stored value as a JSON object ({"1": "b"}) instead of a list, and the admin sharing settings hand that value to the frontend as a string[], so the excluded-groups selection could show wrong values.

Share20\Manager::groupDeleted() now removes the deleted group through a shared helper, removeGroupFromSharingGroupList(), which re-indexes the list with array_values() before writing it back. The helper also cleans the deleted group out of the other three sharing group lists (shareapi_allow_links_exclude_groups, shareapi_enforce_links_password_excluded_groups, shareapi_only_share_with_group_members_exclude_group_list), since those kept the ids of deleted groups too. A list the group was never in is left alone, and an empty or invalid stored value is skipped.

tests/lib/Share20/ManagerTest.php gets three new tests: deleting group a stores ["b"] for the exclude list, ["c"] for the link-exclude list, and [] for the group-members-only list while the password-exclude list is untouched; deleting a group that is in no list writes nothing; and an invalid stored value writes nothing.

Verification: the new tests were not run locally, there is no PHP on the machine this change was made on, so CI has to run them. The re-indexing was checked by reading the code path, not by running the suite.

TODO

No open TODOs.

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Tests (unit, integration, api and/or acceptance) are included
  • Screenshots before/after for front-end changes (n/a: no front-end change)
  • Documentation (manuals or wiki) has been updated or is not required (n/a: bugfix, no user-facing behavior change beyond the fix)
  • Backports requested where applicable (ex: critical bugfixes) (n/a: bugfix, not critical)
  • Labels added where applicable (ex: bug/enhancement, 3. to review, feature component) (n/a: maintainers set labels)
  • Milestone added for target branch/version (ex: 32.x for stable32) (n/a: maintainers set the milestone)

AI (if applicable)

Drafted with help from Claude. I reviewed and revised every change myself before opening this PR.

array_diff() keeps the original array keys, so deleting any
group but the last one left shareapi_exclude_groups_list
stored as a JSON object ({"1": "b"}) instead of a list,
which the admin sharing settings pass on to the frontend
as a string[]. Re-index the list with array_values()
after removing the deleted group, and clean the deleted
group out of the other three sharing group lists too.
Lists the group was never in are left untouched.

Fixes nextcloud#67451

Signed-off-by: parel <farelalfarizi89@gmail.com>

Assisted-by: Muse:Muse Spark 1.3
@kukanggg89
kukanggg89 requested review from a team as code owners December 4, 2026 07:34
@kukanggg89
kukanggg89 requested review from Altahrim, GhassenKefi, icewind1991 and vlotysh and removed request for a team December 4, 2026 07:34

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deleting a group stores the "exclude groups from sharing" list as a JSON object

1 participant