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

RFC: Avoid HTTPApplication for CLI #7509

Closed
sminnee opened this issue Oct 24, 2017 · 6 comments
Closed

RFC: Avoid HTTPApplication for CLI #7509

sminnee opened this issue Oct 24, 2017 · 6 comments

Comments

@sminnee
Copy link
Member

sminnee commented Oct 24, 2017

HTTPApplication is a system for processing URLs in a webserver environment.

In a CLI context, it only introduces distractions.

For CLI requests, we should generate a CoreKernel object but handle BuildTasks and database building without using SilverStripe/Control. This would probably be a good time to create it as a Symfony console tool, perhaps incorporating one of the existing tools in this space as opposed to reinventing the wheel.

A special "run URL" option could be used for those cases when do do actually want a URL, but it should be the exception rather than the rule.

I'd recommend this as a 4.1 change that preserves the existing behaviour as deprecated.

Note that the implication of this is that no HTTPMiddlewares would ever get run in CLI mode, which simplifies things such as #7492.

@tractorcow
Copy link
Contributor

Could it even be a separate tool, silverstripe/console perhaps?

@tractorcow
Copy link
Contributor

Note that the implication of this is that no HTTPMiddlewares would ever get run in CLI mode, which simplifies things such as #7492.

This sounds about right to me!

@tractorcow
Copy link
Contributor

tractorcow commented Oct 26, 2017

One thing to consider is what "simulated web-requests" would do. One example I can think of is rendering the error page template into assets/error-404.html. Perhaps we just don't do that anymore, thus eliminating that need?

@sminnee
Copy link
Member Author

sminnee commented Oct 27, 2017

One thing to consider is what "simulated web-requests" would do. One example I can think of is rendering the error page template into assets/error-404.html. Perhaps we just don't do that anymore, thus eliminating that need?

It's a good question, I'd probably leave it separate from this issue. I think we need to look at how middlewares are typically used before deciding whether they should be included in the default render of a staticpublisher page or a 404 error page. My guess is that it's better to exclude them by default, as they are typically used to handle log-in, session, redirection, flush, header mangling, request blocking, none of which apply in such a case.

The error page generator and staticpublisher could probably each have an extension hook where middlewares specific to those use cases could be attached, which by default would be empty.

@chillu
Copy link
Member

chillu commented Jun 9, 2021

This is rearing its ugly head again in a new use case: We want to generate the GraphQL schema during release packaging, which often happens in environments separate from the actual webserver (e.g. AWS CodeBuild or CircleCI). This happens through sake, but that kicks off all kinds of wrong assumptions about the state of the environment: Validate database credentials, execute middleware that relies on database queries, trigger HTTPOutputHandler to show errors. Its a good test case for our kernel architecture, but a bit of a rabbit hole.

@GuySartorelli
Copy link
Member

Closing as this will be done as part of #11341
The new sake will by default not use HTTPApplication nor HTTPRequest, though there is a sake navigate command that will essentially do what old sake did, for those who have a need to do that for whatever dark magic they're doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants