This change was prompted by a phpstan failure after a recent update.
While making this change, I noticed we don't need the macro anymore
as useAssetOrigin() was added to the UrlGenerator earlier this year,
simplifying our implementation.
This is because the CreateTenantStorage listener only runs when
a tenant is created, but in multi-server setups the directory may
need to be created each time a tenant is *used*, not just created.
Also changed the listeners to use TenantEvent instead of specific
events, to make it possible to use them with other events, such as
TenancyBootstrapped.
Also update permission bits in a few mkdir() calls to better scope
data to the current OS user.
Also fix a typo in CacheTenancyBootstrapper (exception message).
* cleanup, resolve todos, add immediate todos
* Improve path_identification_middleware docblock
* rename leave() method in tests
* wip fix hardcoded values making assumptions about the parameters used in routing
* defaultParameterNames
* fix CreatesDatabaseUsers return values
* $tenant -> tenant()
* resolve more todos
* make comment block a complete block
* Correct useTenantRoutesInFortify(), delete unused import
* test fixes
* remove todos
* remove JobPipeline todo
* simplify comment example
* remove todo
* fix VERSION_PREFIX in queue.yml
---------
Co-authored-by: lukinovec <lukinovec@gmail.com>
* Run cache tests on all supported drivers
* update ci healthcheck for memcached
* remove memcached healthcheck
* fix typos in test comments, expand internal.md [ci skip]
* add empty line [ci skip]
* switch to using $store->setPrefix()
* add dynamodb
* refactor try-finally to try-catch
* remove unnecessary clearResolvedInstances() call
* add dual Cache:: and cache() assertions
* add apc
* Flush APCu cache in test setup
* Revert "add dual Cache:: and cache() assertions"
This reverts commit a0bab162fbe2dd0d25e7056ceca4fb7ce54efc77.
* phpstan fix
* Add logic for scoping 'file' disks to FilesystemTenancyBootstrapper
* minor changes, add todos
* refactor how the session.connection is used in the DB session bootstrapper
* add session forgery prevention logic to the db session bootstrapper
* only use the fs bootstrapper for file disk in 'cache data is separated' dataset
* minor session scoping test changes
* Add session scoping logic to FilesystemTenancyBootstrapper, correctly update disk roots even with storage_path_tenancy disabled
* Fix code style (php-cs-fixer)
* update docblock
* make not-null check more explicit
* separate bootstrapper tests, fix swapped test names for two tests
* refactor cache bootstrapper tests
* resolve global cache todo
* expand tests: session separation tests, more filesystem separation assertions; change prefix_base-type config keys to templates/formats
* add apc session scoping test, various session separation bugfixes
* phpstan + minor logic fixes
* prefix_format -> prefix
* fix database session separation test
* revert composer.json changes, update laravel dependencies to expected next release
* only run session scoping logic in cache bootstrapper for redis, memcached, dynamodb, apc; update gitattributes
* tenancy.central_domains -> tenancy.identification.central_domains
* db session separation test: add datasets
---------
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
* Make asset_helper_tenancy false by default
* Make tenant_asset() respect ASSET_URL
* Set asset helper tenancy to true in tests where needed
* If the `asset_helper_tenancy` key is missing, default to false in filesystem bootstrapper
* Make temporary clone action changes
* Make tenancy asset route universal
* Make the asset controller's asset method behave differently if path ID MW is the default
* Test that asset helper works with path identification
* Fix code style (php-cs-fixer)
* Delete path traversal attack prevention
* Fix code style (php-cs-fixer)
* Skip cloning of stancl.tenancy.asset route in some tests
* Fix code style (php-cs-fixer)
* Clone asset route in TSP stub
* Add cloning only the passed route
* Clone asset route in tenant asset test beforeEach
* Skip asset route cloning by default
* Fix typo
* Change public method back to protected
* Remove cloning of specific routes, skip cloning routes flagged as tenant
* Delete constructor from asset controiler, change asset method to invoke
* Update asset route registration, add prefixed asest route for path identification
* Use default middleware from config instead of `tenancy()->defaultMiddleware()`
* Delete old code from TSP stub
* Revert TSP stub change
* Revert FilesystemTenancyBootstrapper changes
* Suffix asset url in tenant_asset()
* Simplify `tenant_asset()`
* Ensure the base asset url is always suffixed with '/'
* remove unnecessary ?? false
---------
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Test if Storage::url() works correctly after reverting to central context
* Fix typo in code
* Access originalPaths using dot notation using `data_get()`
* This adds support for tenancy aware Storage::url() method
* Trigger CI build
* Fixed Link command for Laravel v6, added StorageLink Events, more StorageLink tests, added RemoveStorageSymlinks Job, added Storage Jobs to TenancyServiceProvider stub, renamed misleading config example.
* Fix typo
* Fix code style (php-cs-fixer)
* Update config comments
* Format code in Link command, make writing more concise
* Change "symLinks" to "symlinks"
* Refactor Link command
* Fix test name typo
* Test fetching files using the public URL
* Extract Link command logic into actions
* Fix code style (php-cs-fixer)
* Check if closure is null in CreateStorageSymlinksAction
* Stop using command terminology in CreateStorageSymlinksAction
* Separate the Storage::url() test cases
* Update url_override comments
* Remove afterLink closures, add types, move actions, add usage explanation to the symlink trait
* Fix code style (php-cs-fixer)
* Update public storage URL test
* Fix issue with using str()
* Improve url_override comment, add todos
* add todo comment
* fix docblock style
* Add link command tests back
* Add types to $tenants in the action handle() methods
* Fix typo, update variable name formatting
* Add tests for the symlink actions
* Change possibleTenantSymlinks not to prefix the paths twice while tenancy is initialized
* Fix code style (php-cs-fixer)
* Stop testing storage directory existence in symlink test
* Don't specify full namespace for Tenant model annotation
* Don't specify full namespace in ActionTest
* Remove "change to DI" todo
* Remove possibleTenantSymlinks return annotation
* Remove symlink-related jobs, instantiate and use actions
* Revert "Remove symlink-related jobs, instantiate and use actions"
This reverts commit 547440c887.
* Add a comment line about the possible tenant symlinks
* Correct storagePath and publicPath variables
* Revert "Correct storagePath and publicPath variables"
This reverts commit e3aa8e2086.
* add a todo
Co-authored-by: Martin Vlcek <martin@dontfreakout.eu>
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
* Let the user pass the tenant suffix by %tenant%
In this PR we let the user pass an additional parameter using `%tenant%` so the user can additionally pass the folder corresponding to each tenant.
This is my proposal, because if I try to use %storage_path% within Linux, I get the full path to the project when I use Google Cloud Storage
* Missing missing updates
Moving from $subject to $root when %storage_path% has been replaced
* Test on Laravel 9
* Don't extend final Kernel class
* Make FilesystemTenancyBootstrapper compatible with Flysystem v3
Co-authored-by: George <jiri.zizka@funfirst.cz>
* Update tenant maintenance mode te be in line with Laravel
* Exclude PHP 7.4 <> L9 combination from testing
* add root_override-related assertions
* getPrefix -> getPathPrefix
* handle / inconsistency in s3 prefix
* Refactor Storage facade changes
Co-authored-by: George <jiri.zizka@funfirst.cz>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* PHP 8 support, test workflow syntax
* Try using a custom data structure in the workflow
* Try using matrix include
* Default PHP target
* single include
* fix composer package name
* [WIP] Try using dev-master for valuestore
* Update spatie/valuestore constraint to be stable