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

[5.x] Prevent autoloading addon files causing exception when called early #10875

Merged
merged 2 commits into from
Oct 1, 2024

Conversation

ryanmitchell
Copy link
Contributor

Since #9270 issues have been reported with add-ons that include console commands (#10873)

This PR updates the logic around the command autoloading to ensure we only run that once the app is booted.

Closes #10873

@jasonvarga
Copy link
Member

This feels like in some situations commands wouldn't get loaded at all? This condition is only evaluated one time.

@ryanmitchell
Copy link
Contributor Author

They still appeared for me and I ran artisan list and I could run the commands. I tested it by removing the commands from being manually registered.

@jasonvarga
Copy link
Member

I see the issue.

Spatie's Responsive Images addon is manually calling bootCommands() in their boot method. Then Statamic will call bootCommands again once Statamic is actually ready.

They don't need to call that method.

This isn't an issue with just commands, it would be an issue for any of the bootSomething methods if you call it in boot.

I think a better fix would be to catch NotBootedException within autoloadFilesFromFolder and return nothing.

@jasonvarga jasonvarga changed the title [5.x] Ensure we don't autoload commands until the app is booted [5.x] Prevent autoloading addon files causing exception when called early Oct 1, 2024
@jasonvarga jasonvarga merged commit d9d6b20 into statamic:5.x Oct 1, 2024
17 checks passed
@ryanmitchell ryanmitchell deleted the fix/issue-10873 branch October 1, 2024 16:28
@ryanmitchell
Copy link
Contributor Author

Nice catch. Thanks.

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.

Autoloading addon commands causes NotBootedException
2 participants