Stamp org_id on tenant writes; scope public reads to the site org#8
Merged
Conversation
Content was never attributed to a tenant: CMS pages and blog articles saved with
org_id='' (the column default), while everything else set org_id explicitly. That
blocks a clean multi-site story and isn't honest attribution. Fix it in the base
model so it can't be forgotten per-module.
- Tiger_Model_Table: setOrg()/$_org + auto-stamp org_id on insert (mirrors the
created_by actor stamp) for any table with the column. Explicit org_id wins;
no org set (system/global) keeps the '' default. Authorization plugin wires
setOrg() from the authenticated org, next to setActor().
- Tiger_Model_Org::siteOrgId()/setSiteOrgId(): the org owning the public site —
configured tiger.site.org_id, else the founding (oldest) org. NB parent_org_id
is future (all orgs are root today), so it's not a distinguishing query.
- Reads: PageDispatch + blog article resolve pass siteOrgId(); _orgScope('')
resolves to it too, so blog lists / CMS datatable / redirects all scope to the
site without touching each caller. Scope stays [org, ''] → nothing 404s mid-
transition. This is the seam a multi-site module overrides by host.
- Migration 0033: backfill legacy page.org_id='' -> the site org.
Smoke now seeds an ORG-STAMPED published page and asserts its body dispatches at
its public URL — the guard for the write-stamp <-> read-scope path (a mismatch
404s there). Verifies base-model stamping end to end on a fresh install.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Content was never attributed to a tenant — CMS pages and blog articles saved with
org_id='', while everything else set it. That blocks a clean multi-site story and isn't honest attribution. Fixed in the base model so it can't be forgotten per-module.Write side
Tiger_Model_Table:setOrg()/$_org+ auto-stamporg_idon insert (mirrors thecreated_byactor stamp) for any table with the column. Explicitorg_idwins; no org set (system/global) keeps''. The Authorization plugin wiressetOrg()from the authenticated org, right next tosetActor().Read side
Tiger_Model_Org::siteOrgId()/setSiteOrgId()— the org that owns the public site: configuredtiger.site.org_id, else the founding (oldest) org. (NBparent_org_idis future — all orgs are root today — so it's not a distinguishing query.)PageDispatch+ blog article resolve passsiteOrgId();_orgScope('')resolves to it too, so blog lists / CMS datatable / redirects scope to the site without touching each caller. Scope stays[org, '']→ nothing 404s mid-transition. This is the exact seam a multi-site module overrides by host.Data
0033backfills legacypage.org_id=''→ the site org (callable migration; empty DBs no-op).Verification
0032's transform was unit-tested previously;0033uses the same callable-migrator path.Single-site behavior is unchanged (founding org = the one site); this is the groundwork the future multi-site module drops onto.
🤖 Generated with Claude Code