-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Extracting the call handler for Spark commands from kernel. #6110
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
Conversation
I have not looked into this PR yet, but this is a big change. So could you please split |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the right direction. We have some big conversations going around CLI and the app so it is helpful to have an actual implementation to look at. Let's make this our general discussion place at well, just for the sake of having a common thread.
It seems there is no problem. |
I'm still in favor of this. The rest of the team is oddly quiet 😅 Let's get the User Guide and changelog updates done and then I will give them one last chance. |
|
||
return $this->app->useSafeOutput($useSafeOutput)->run(); | ||
return $runner->run($command, $params); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BaseCommand::run()
called by Commands::run()
returns void
although not strictly because not typehinted. However, most of our implementations of commands I think don't return anything either. So the $exit
in L85 in spark above will be null
so always exit on EXIT_SUCCESS
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out that exit (0), unless of course the developer forcibly returns the desired value of the exit code.
@@ -871,9 +847,7 @@ protected function createController() | |||
* CI4 supports three types of requests: | |||
* 1. Web: URI segments become parameters, sent to Controllers via Routes, | |||
* output controlled by Headers to browser | |||
* 2. Spark: accessed by CLI via the spark command, arguments are Command arguments, | |||
* sent to Commands by CommandRunner, output controlled by CLI class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is removed, does this mean that the CommandRunner
will be removed? Or deprecated, at least?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CommandRunner
class will be removed as there is no point in it. I'm already preparing changes.
@iRedds Thank you for updating the docs. One last thing, Upgrading Guide also needed. |
=================== | ||
|
||
By default, the command terminates with a success code of ``0``. To change the exit code, for example on error, | ||
the ``run()`` method must return an integer in the range 0 - 254. `PHP exit <https://www.php.net/manual/en/function.exit.php>`_. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of specifying the range, I think it would be better to use our constants for that?
CodeIgniter4/app/Config/Constants.php
Lines 70 to 79 in b3ebf5b
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors | |
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error | |
defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error | |
defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found | |
defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class | |
defined('EXIT_UNKNOWN_METHOD') || define('EXIT_UNKNOWN_METHOD', 6); // unknown class member | |
defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input | |
defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error | |
defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code | |
defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion! I forgot the constants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made changes. I hope this is similar to what you were talking about.
@kenjis I have doubts about the quality of the upgrade manual. |
Please add. --- a/user_guide_src/source/installation/upgrading.rst
+++ b/user_guide_src/source/installation/upgrading.rst
@@ -12,6 +12,7 @@ upgrading from.
.. toctree::
:titlesonly:
+ upgrade_430
upgrade_421
upgrade_420
upgrade_418 I think the upgrading is okay. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Description
This is the concept of extracting the call to Spark commands from processing via routing. Commands are called directly, as when using the
command()
function. This will reduce the load on the console application in the form of Request, Response, Filters and Routes services and more.In the beginning, the idea of creating an Application class was considered, from which the
CodeIniter
andConsole
classes would be inherited. This was necessary to initialize the application. But due to the fact that, at the request of one person, the core of the application turned into a service, there were difficulties with the implementation.Therefore, the initialization of the application through the
CodeIgniter
class is saved.The
Console
class now uses theServices::commands()
service directly instead of using theCommandRunner
class.The
CodeIgniter
class has been cleared of processing Spark commands, and theConsole
class no longer processesResponse
.Although this is not within the purview of the PR, I added theStreamFilterTrait
trait, which correctly adds and removes filters for capturing stream output, since the current implementation in the tests is not correct enough in my opinion.Depends on StreamFilterTrait #6112
Checklist: