Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Compatibility with Laravel 9 #802

Merged
merged 9 commits into from
Mar 8, 2022
Merged

Conversation

erikgaal
Copy link
Contributor

There were some more changes required before getting the package to work with Laravel 9. I've added testing on L9 to the workflow so we can be sure it's compatible before we merge.

Thank you @CodeSkills for the work in your PR. I've made sure to add you as a co-author for the commit regarding the FilesystemTenancyBootstrapper.

@stancl
Copy link
Member

stancl commented Feb 14, 2022

Thanks for the PRs! I'm happy to merge #800 or #802, whichever adds the L9 support fully

With regards to the workflow changes you made, I think it'll fail now since Laravel 9 requires PHP 8. And it's trying to use it with PHP 7.4.

It'd probably be best to merge #793 first. There are a few changes remaining there, so if you could try implementing them, we'll be able to see how this PR works.

I just responded to a few reviews there.

composer.json Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Feb 14, 2022

Codecov Report

Merging #802 (e1ab850) into 3.x (9c79267) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##                3.x     #802      +/-   ##
============================================
+ Coverage     87.32%   87.33%   +0.01%     
- Complexity      383      384       +1     
============================================
  Files           103      103              
  Lines          1128     1129       +1     
============================================
+ Hits            985      986       +1     
  Misses          143      143              
Impacted Files Coverage Δ
...rc/Bootstrappers/FilesystemTenancyBootstrapper.php 100.00% <100.00%> (ø)
src/Middleware/CheckTenantForMaintenanceMode.php 80.00% <100.00%> (+7.27%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9c79267...e1ab850. Read the comment docs.


if ($root = str_replace(
if (!($root = str_replace(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CodeSkills could you explain the changes a bit?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to make sure this uses the root overrides correctly, as described here https://tenancyforlaravel.com/docs/v2/filesystem-tenancy/

I think I might add some assertions to the BootstrapperTest, assuming the PR can be set up locally

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was an IDE suggestion to negate the condition and remove the original if part. Because the original if part of the conditional (the setPathPrefix call) was no longer needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is just a simplification, it works the same way as before, since there is $this->app['config']["filesystems.disks.{$disk}.root"] = $root; at the end of the function. You dont have to do this $filesystemDisk->getAdapter()->setPathPrefix($finalPrefix = $root); because it changes the config itself.

Copy link
Member

@stancl stancl Feb 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed those test changes now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rewrite the if to not include the negation and assignment in the condition. You can make them separate

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can rewrite it to something like this, to make it more clear:

$root = str_replace(
    '%storage_path%',
    storage_path(),
    $this->app['config']["tenancy.filesystem.root_override.{$disk}"] ?? ''
);
// Default root
if (!$root) {
    $root = "{$root}/{$suffix}";
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've refactored the proposed changes to prevent overwriting used variables. It took me a while to fully understand what the code was doing, but this should clear it up.

tests/BootstrapperTest.php Outdated Show resolved Hide resolved
@stancl stancl mentioned this pull request Feb 15, 2022
@erikgaal
Copy link
Contributor Author

Looks good to me now :)

@stancl
Copy link
Member

stancl commented Feb 16, 2022

Do you think we can finish 793 as I wrote here? #802 (comment)

@colinmackinlay
Copy link

Do you think we can finish 793 as I wrote here? #802 (comment)

@stancl - would be great if this could be merged now if it is working. Even if you don't tag a release until #793 is done we could still pull it in via dev:master and run Laravel 9 upgrades :)

@stancl
Copy link
Member

stancl commented Feb 18, 2022

@colinmackinlay I can merge the PR sooner and tag a version after all of the other things are resolved, but there are still some reviews here that should be addressed before merging.

@SupianIDz
Copy link

@colinmackinlay I can merge the PR sooner and tag a version after all of the other things are resolved, but there are still some reviews here that should be addressed before merging.

is there any progress ? We have entered the tenancy stage of our program. I hope it's merged soon.

Thank you all for your hard work ❤️ .

@magarrent
Copy link

Hey! It's the package already compatible with L9? Or there are some pending issues? Maybe I can help

@stancl
Copy link
Member

stancl commented Feb 22, 2022

@CodeSkills
Copy link
Contributor

I have written there an update on how you could rewrite it. Hope it helps! (Someone should probably test it before since it has been changed from my PR, when somebody replaced the vars with {$root}, which I did not test.

@stancl stancl mentioned this pull request Mar 1, 2022
@oxiginedev
Copy link

hey! @stancl , please what's the update on support for laravel 9. Any help needed?

adam-code-labx added a commit to adam-code-labx/tenancy that referenced this pull request Mar 3, 2022
ref: [3.x] Compatibility with Laravel 9 archtechx#802
@stancl
Copy link
Member

stancl commented Mar 7, 2022

I'll probably finish and merge this later today 👍🏻

@stancl
Copy link
Member

stancl commented Mar 8, 2022

Thanks for the $finalPrefix refactor (as well as your work on all this) @erikgaal! It looks great now.

The only thing I'm unsure about is the review re: S3, but I'll merge this into 3.x anyway. I'd appreciate if people who use S3 could test that branch and report if there are any issues. If there are not, I'll tag a release tomorrow. I'll also try to revisit the logic tomorrow (in code, not prod) to see if it's okay.

So to use the dev branch locally, you can just run:

composer require stancl/tenancy:3.x-dev

And then switch it back to ^3.0 once this is released.

@stancl stancl merged commit 79e3d53 into archtechx:3.x Mar 8, 2022
@tkuhnert
Copy link

I just updated locally to L9 using 3.x-dev. Using flysystem-aws-s3-v3 in combination with a minio server. Everything works as expected so far. 👍

@stancl
Copy link
Member

stancl commented Mar 10, 2022

Thanks a lot for the testing!

@jtomek
Copy link

jtomek commented Mar 15, 2022

Hi, I also tested it on Vapor. All worked fine except the filesystem root url. I have described the issue and a hotfix here: #739 (comment)

@stancl
Copy link
Member

stancl commented Mar 15, 2022

@jtomek Can you confirm that this regression was introduced in the latest release (and therefore it all worked fine in 3.5.1)?

@jtomek
Copy link

jtomek commented Mar 17, 2022

@stancl, I will try my best to find a slot for it. This week is rather busy. I can share that I have been using and updating your package regularly for a long time and the issue at hand started with the Laravel 9 update.

@miketimeturner
Copy link

@jtomek Can you confirm that this regression was introduced in the latest release (and therefore it all worked fine in 3.5.1)?

I can confirm this is the case. I have the same issue and therefor tenant directories now reside in directory "/" this is also having an impact retrieving the media and you are met with a permission denied, probably due to an incorrect url.

The issue no longer exist after reverting to 3.5.1

@stancl
Copy link
Member

stancl commented Mar 21, 2022

Thanks for the testing! I'll try to get it fixed this week.

@trippo
Copy link

trippo commented Apr 7, 2022

Any news on this?
Are now production-ready v.3.5.2?

@stancl
Copy link
Member

stancl commented Apr 7, 2022

See the release notes

@trippo
Copy link

trippo commented Apr 7, 2022

Thanks seem that v3.5.5 solves all bugs.

Thanks

@erikgaal erikgaal deleted the patch-laravel-9 branch September 24, 2022 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet