Repository navigation
feat: tenant-scoped audits, a hook around queued jobs, LocaleColumns::writeUsing - #3
Merged
Merged
Conversation
added 15 commits
November 29, 2026 18:30
…:writeUsing - Runs record their Filament tenant; the audit page, approvals and rejections are limited to the current tenant. HeadlessImport::tenant(). - ImportJobContext::around() wraps every queued review and import slice so apps can set up their own context before rows are read or written. - LocaleColumns::writeUsing() for translations stored outside the record. - ext-pdo_sqlite is optional: seen_store defaults to auto. - CI runs the suite on PostgreSQL and MySQL; Octane safety test. - Tests updated for Filament 5.12 (panel restored in queued import jobs, panel-origin check on nested Livewire components).
MySQL's JSON type reorders object keys, which changed the order of the preview's columns and of the error counts per column. Store the short-lived review slice payloads as text.
…keys inside their folder Chunked-upload endpoints were plain authenticated routes, so on a panel with tenancy no tenant was identified: uploads landed in the panel folder and the tenant's wizard silently refused them. They are now tenant routes (Filament checks the user's access to the tenant), and the wizard links to the current tenant's endpoints. Tenant keys that are not plain (containing '/', '..' or other characters) are hashed into the folder name, so they can never climb out of or into another tenant's folder.
…find users on workers ReviewSlice now remembers the Filament panel and tenant of the request that started the review and restores them while it runs (refusing a user who can no longer access the tenant), like Filament does for import jobs. Without this, ImportJobContext callbacks and rules saw no tenant on a real worker, and the documented callback skipped every review slice. Users are looked up through the auth guard's provider instead of app(Authenticatable::class), which Laravel binds to the current user: null on a queue worker and in the console, so parallel review crashed on real workers and import-wizard:run --user failed unless the app had rebound it.
The callbacks lived in a static property, so every application booted in the same process (each test of a host app, re-registering them in a service provider's boot()) added another copy and jobs ran inside them several times. They now belong to the application they were registered on.
…keeping their scope modifyExportQuery() was skipped for a relation passed to FileExport::query(), so resolveExportValue() ran on the wrong records. The relation's constrained query is now handed over. The contract and docs say to narrow the given query, which carries the tenant scope, rather than start a new one.
…ostgreSQL Rolling it back failed: PostgreSQL refuses to change text to json without a USING cast. Covered by a round-trip test with rows in place, which runs on SQLite, PostgreSQL and MySQL in CI.
Untenanted runs recorded before the upgrade, moved upload folders, the LocaleColumns::filler() signature, the optional pdo_sqlite extension, the morph class in tenant_type, Filament's failed-rows route (user check only) and what HeadlessImport::tenant() does and does not do.
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.
This PR adds four things the package needs to run inside a multi-tenant CMS, where each site is a Filament tenant. All four are generic, so any panel with tenancy can use them. Target release: 0.14.0.
Changes
tenant_type,tenant_idand an index.ImportApprovals::canDecide()refuses runs of another tenant, so the approve and reject actions are hidden and direct calls throw.HeadlessImport::tenant($model)records a tenant for headless runs.ImportJobContext::around(fn (JobRun $run, Closure $next) => …)wraps every queued review slice and import slice.JobRuncarries the stage (revieworimport), the importer, the options and theImport.$nextskips the slice.LocaleColumns::writeUsing(fn ($record, $locale, $value) => …)for translations stored outside the record's attributes, e.g. one row per language. Blank cells are still skipped.ext-pdo_sqliteis optional.seen_storenow defaults toauto: SQLite when the extension is loaded, else the database.CI gets a new
databasesjob that runs the whole suite on PostgreSQL 16 and MySQL 8.4.tests/OctaneSafetyTest.phpfails on any per-request static state. It also runs imports back to back and checks that no context leaks from one job into the next.Existing tests broken by Filament 5.12
maincurrently has 6 failing tests with the latest dependencies (Filament 5.12.1). This PR fixes them; it's a test-setup issue, not a package bug.ImportCsvjobs. For users that aren't aFilamentUserit only allows this whenapp.envislocal. The test suite's plain user is not aFilamentUser, so the suite now runs withapp.env=local.decimal,boolean, MySQL'svarchar(255)length), so they now normalize them.Checks
TenancyAndJobHooksTest.php(7) andOctaneSafetyTest.php(2)Upgrade
Run
php artisan migrate. Nothing else changes for apps without tenancy.One small behaviour change:
LocaleColumns::filler()is now an instance method. It's protected, so it only matters if you subclassedLocaleColumnsand overrode it.Docs: new
docs/multi-tenancy.md, plus updates totranslatable.md,configuration.md,installation.md,scaling.md, the README and the CHANGELOG.