fix(sharing): set STATUS_ACCEPTED when creating USERGROUP subshare on…#59813
fix(sharing): set STATUS_ACCEPTED when creating USERGROUP subshare on…#59813miaulalala wants to merge 1 commit into
Conversation
630f3b2 to
1e03eff
Compare
c479d14 to
96fd848
Compare
provokateurin
left a comment
There was a problem hiding this comment.
This should only be part of the migration and not available outside.
| ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP, IQueryBuilder::PARAM_INT))) | ||
| ->andWhere($qb->expr()->eq('accepted', $qb->createNamedParameter(IShare::STATUS_PENDING, IQueryBuilder::PARAM_INT))) | ||
| ->andWhere($qb->expr()->neq('permissions', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT))) |
There was a problem hiding this comment.
Are you sure this will only match those broken shares? There must not be any false positives.
There was a problem hiding this comment.
I wanted to give admins the option to restore already broken shares. Some admins may not want to have that.
And yes, any oC share will have a permission other than 0 if it wasn't rejected. So only oC shares that were accepted but haven't had the update for the new column will be in that state.
96fd848 to
aa49469
Compare
|
@provokateurin re: "This should only be part of the migration and not available outside" - an automatic repair step would silently restore shares that recipients may not have seen for weeks or months. From their perspective, files would suddenly reappear with no explanation, which seems like the wrong default for instances that have been running in the broken state for a while. The opt-in The actual root cause (missing |
aa49469 to
c1e173a
Compare
…shares When an ownCloud-migrated group share (which has no per-user USERGROUP subshare) is renamed for the first time, DefaultShareProvider::move() inserted a new USERGROUP row without setting `accepted`. The column defaulted to 0 (STATUS_PENDING), causing MountProvider to skip the share on the next login — the shared file disappeared for the recipient. Fix: set accepted = STATUS_ACCEPTED explicitly on the INSERT in DefaultShareProvider::move() for the TYPE_GROUP branch. Secondary fix: SharedMount::moveMount() silently returned true when updateFileTarget() threw (e.g. group no longer exists on an OC-migrated instance). Set $result = false in the catch block so View::rename() propagates the failure instead of silently corrupting VFS state. An opt-in occ command (sharing:fix-owncloud-group-shares) with --dry-run support is included to repair existing broken instances. It targets only TYPE_USERGROUP subshares with accepted=STATUS_PENDING and permissions!=0 (shares that were accepted but broken by the missing column default), leaving explicitly declined shares (permissions=0) untouched. AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Anna Larch <anna@nextcloud.com>
c1e173a to
9a4427c
Compare
Root cause
When an ownCloud-migrated group share (which has no per-user USERGROUP subshare) is renamed for the first time,
DefaultShareProvider::move()inserts a new USERGROUP row without settingaccepted. The column defaults to 0 (STATUS_PENDING), causingMountProviderto skip the share on the next request — the file disappears for the recipient.Native Nextcloud group shares are unaffected because the accept flow always creates the USERGROUP subshare and immediately sets
accepted = STATUS_ACCEPTEDbefore the user can rename.A second bug compounded this:
SharedMount::moveMount()was catching exceptions fromupdateFileTarget()(e.g.Manager::moveShare()rejecting an orphaned group share because the original group no longer exists in Nextcloud) but always returningtrue. This causedView::rename()to believe the rename succeeded, update\$this->pathto the new location, and then fail with HTTP 500 onrefreshInfo()— making the file appear to vanish with no clean error.Fixes
DefaultShareProvider::move()— setaccepted = STATUS_ACCEPTEDwhen inserting a new USERGROUP subshare on first rename, soMountProviderdoes not skip it on the next load.SharedMount::moveMount()— set\$result = falsein the catch block so rename failures propagate cleanly instead of corrupting virtual filesystem state.updateFileTarget()widened fromprivatetoprotectedto allow unit testing.occ sharing:fix-owncloud-group-shares— opt-in repair command for instances that already hit the bug before this fix was deployed. Finds USERGROUP subshares stuck atSTATUS_PENDINGwith non-zero permissions and restores them toSTATUS_ACCEPTED. Supports--dry-run. Deliberately not an automatic repair step — admins should run this consciously, as shares that have been invisible for some time will reappear for recipients.Tests
DefaultShareProviderTest::testMoveGroupShare()— assertsSTATUS_ACCEPTEDafter both first and second move (INSERT and UPDATE paths).SharedMountTest::testMoveOwncloudMigratedGroupShareRemainsVisibleAfterRename()— integration test simulating the full OC migration state: GROUP share withaccepted = STATUS_ACCEPTEDand no USERGROUP subshare; verifies the share is still visible after rename and re-login.SharedMountTest::testMoveMountReturnsFalseWhenUpdateFileTargetThrows()— unit test verifyingmoveMount()returnsfalsewhenupdateFileTarget()throws.FixOwncloudGroupSubshareStatusTest— covers fix, dry-run, declined shares (permissions=0), already-accepted shares, non-USERGROUP shares, and multiple rows.Fixes: #59791
AI-Assisted-By: Claude Sonnet 4.6 noreply@anthropic.com