1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-05-06 21:44:06 +00:00
tenancy/src/Jobs
lukinovec 984911946a
Change tenant storage listeners into jobs (#1446)
The `CreateTenantStorage` and `DeleteTenantStorage` listeners were used
alongside JobPipelines. When the `TenantCreated` JobPipeline had
`shouldBeQueued(true)` and the `Listeners\CreateTenantStorage` was
uncommented, the listener would throw an exception
(`Stancl\Tenancy\Database\Exceptions\TenantDatabaseDoesNotExistException
Database tenantX.sqlite does not exist.`) because at the time of
executing the listener, the tenant DB wasn't created yet.

The same issue could likely also occur in the `DeleteTenantStorage`
listener as it uses `tenancy()->run()` to resolve the tenant's storage
path which wouldn't work if the tenant's database (or other resources)
was already deleted, making initialization impossible.

This PR changes `DeleteTenantStorage` into a job and puts it (commented)
into the job pipeline, so that it can be queued with the rest of the
jobs. It also removes `CreateTenantStorage` because it should be
redundant with the FilesystemTenancyBootstrapper creating the same paths
automatically when storage path is suffixed.

The old classes are kept but deprecated for backwards compatibility.

We've also added some edge case hardening to `DeleteTenantStorage` to
make sure it never deletes the central storage path directory, which
previously could in theory occur due to a misconfiguration if a user
enabled this job/listener but disabled storage path suffixing.

Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-04-22 16:45:54 +02:00
..
ClearPendingTenants.php Resource syncing rework (#30) 2024-02-10 19:08:37 +01:00
CreateDatabase.php Fix assert: run createDatabase() outside assert() 2025-10-16 01:10:07 +02:00
CreatePendingTenants.php Resource syncing rework (#30) 2024-02-10 19:08:37 +01:00
CreateStorageSymlinks.php Enable single_line_empty_body phpcsfixer rule 2024-04-02 04:31:03 +02:00
DeleteDatabase.php Enable single_line_empty_body phpcsfixer rule 2024-04-02 04:31:03 +02:00
DeleteDomains.php fix: drop tenant databases on migrate fresh without domains (#1282) 2025-01-01 20:31:47 +01:00
DeleteTenantStorage.php Change tenant storage listeners into jobs (#1446) 2026-04-22 16:45:54 +02:00
MigrateDatabase.php Enable single_line_empty_body phpcsfixer rule 2024-04-02 04:31:03 +02:00
RemoveStorageSymlinks.php Central routes without Route::domain(), configurable tenant/central routes by default for domain/subdomain identification, allow accessing central routes in early identification for path & request data middleware (#3) 2023-08-03 00:23:26 +02:00
SeedDatabase.php Enable single_line_empty_body phpcsfixer rule 2024-04-02 04:31:03 +02:00