fix(tenant): follow the merge before the UUID becomes a scope - #3336
Merged
Conversation
resolveMergeTarget() and findByUuidFollowingMerge() were built and then called by nothing, so a merge was recorded and never followed. A user whose active organisation had been merged away kept resolving to the row that was merged: it still loads, its queries still return rows, and every one of them runs under a tenant boundary that no longer applies. Both entries into fetchActiveOrganisationFromDatabase() walk it now. The stored active UUID is the obvious one. The auto-pick is the one that matters more: a user's membership list can still name a merged-away organisation, so without the walk there the first login after a merge writes the dead UUID straight back into config and re-creates the defect. The walk is guarded on isMerged(), because the flag lives on the row that was merged away and almost no row carries it, so the common case costs no query at all. Membership is then checked against the SURVIVOR, which fails closed: a user the merge did not carry over falls through to their own organisations rather than being handed a tenant on the strength of a membership that ended. An unresolvable survivor keeps the row already in hand and logs, because a read path is the wrong place to throw over a data defect.
Contributor
Quality Report — ConductionNL/openregister @
|
| Check | PHP | Vue | Security | License | Tests |
|---|---|---|---|---|---|
| lint | ✅ | ||||
| phpcs | ✅ | ||||
| phpmd | ✅ | ||||
| psalm | ✅ | ||||
| phpstan | ✅ | ||||
| phpmetrics | ✅ | ||||
| eslint | ✅ | ||||
| stylelint | ✅ | ||||
| build | ✅ | ||||
| check-specs | ✅ | ||||
| test-l10n | ✅ | ||||
| test-l10n-parity | ✅ | ||||
| format | ✅ | ||||
| check-schema-l10n | ✅ | ||||
| check-l10n-js | ✅ | ||||
| composer | ✅ | ✅ 174/174 | |||
| npm | ✅ | ✅ 543/543 | |||
| app:check-code | ⏭️ | ||||
| info.xml | ✅ | ||||
| REUSE | ❌ | ||||
| PHPUnit | ✅ | ||||
| Newman | ✅ | ||||
| Playwright | ⏭️ deferred — runs on the promotion into beta/main, not on a pull request into development | ||||
| Hydra gates | ✅ |
Quality workflow — 2026-09-02 11:55 UTC
Download the full PDF report from the workflow artifacts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
resolveMergeTarget()andfindByUuidFollowingMerge()landed in tasks 3.1 and 3.2 ofconsolidate-organisation-on-or, and then nothing called either of them. A merge was recorded and never followed.That is the quiet kind of defect. A merged-away organisation still loads, its scoped queries still return rows, and nothing anywhere reports an error. The rows just come back under a tenant boundary that no longer applies.
What changed
Both entries into
fetchActiveOrganisationFromDatabase()now walk the chain.The stored active UUID is the obvious one. The auto-pick is the one that matters more: a user's membership list can still name a merged-away organisation, so without a walk there, the first login after a merge writes the dead UUID straight back into config and re-creates the defect it just fixed.
Three properties worth calling out:
isMerged(). The flag lives on the row that was merged away, and almost no row carries it, so the common case costs no extra query.An unresolvable survivor keeps the row already in hand and logs a warning. A read path is the wrong place to throw over a data defect, and the row it already holds is real.
Verification
tests/Unit/Service/ActiveOrganisationFollowsMergeTest.php, including the negative case (an unmerged row is never walked) and the fail-closed case.Closes task 3.3 of
consolidate-organisation-on-or.