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

[8.x] Bugfix passing errorlevel when command is run in background #37479

Merged
merged 2 commits into from
May 26, 2021
Merged

[8.x] Bugfix passing errorlevel when command is run in background #37479

merged 2 commits into from
May 26, 2021

Conversation

arjenvanoostrum
Copy link
Contributor

Hi Taylor,

Thanks for taking the time to look into #37423.
I guess it depends whether the callbacks are considered to only serve as event hooks (as you described in docs), or as part of the process. The proposed fix would of course differ from the behaviour of scheduled commands on Linux and on Windows when not executed in the background. And that is at least unwanted i guess.

Today I've spent a few hours to make it work, and came across a few particularities on my way (all tests started with schedule:run with a few commands due to start).

  1. Firstly I was pretty close when adding a flag /v to the command to signal the use of delayed expansion for the !ERRORLEVEL! variable. The commandline as passed to the Symfony Process component works when ran in a terminal
  2. However, the Symfony Process component wraps it in a cmd itself which makes it necessary to escape the exclamations. (^!ERRORLEVEL^!)
  3. With the exclamations escaped the wrapped command works when a single command instance of the command is scheduled to run at the time schedule:run is called.
  4. For some reason when the same command is started twice with a different argument value, and one is failing with a thrown exception, that failure is not reported. Neither as a succes nor as a failure.
    I was stunned until I discovered that when the handle method returns an exit code instead of a thrown Exception it does work. So as long as the developer does something like this, it works:
public function handle()
    {
        try {
            $this->something();
            return 0;
        }
        catch(\Exception $e) {
            // handle exception 
            return 1;
        }
    }

Notice that there are no quotes around the ^!ERRORLEVEL^! as this will not work..

@taylorotwell taylorotwell merged commit 235e52a into laravel:8.x May 26, 2021
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.

3 participants