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

Return value from CommandController commands not outputted #658

Closed
mbrodala opened this issue Jan 9, 2018 · 6 comments
Closed

Return value from CommandController commands not outputted #658

mbrodala opened this issue Jan 9, 2018 · 6 comments
Labels

Comments

@mbrodala
Copy link
Contributor

mbrodala commented Jan 9, 2018

Q A
Bug report? yes
Feature request? no
TYPO3 version 8.7.9
TYPO3 Console version 5.0.2
TYPO3 Composer mode? yes

The return value of any Extbase CommandController command is not outputted anymore.

Given the following command:

<?php
namespace Vendor\Package\Command;

use TYPO3\CMS\Extbase\Mvc\Controller\CommandController;

class TestCommandController extends CommandController
{
    public function outputCommand()
    {
        return 'TEST';
    }
}

When I run this command:

typo3cms test:output

I get no output.

And I expected this output:

TEST
@mbrodala mbrodala added the Bug label Jan 9, 2018
@helhum
Copy link
Member

helhum commented Jan 9, 2018

Hm, I didn't even know this is possible ;)

Would you agree on fixing, but deprecating this and include it in a bugfix version? As this is what I would have done for 5.0.0 if I would have know about it.

@mbrodala
Copy link
Contributor Author

mbrodala commented Jan 9, 2018

It should be fixed for 5.x but I wouldn't go as far as deprecating it since that should be done in TYPO3 core first then.

@helhum
Copy link
Member

helhum commented Jan 9, 2018

but I wouldn't go as far as deprecating it since that should be done in TYPO3 core first then

Not sure why. I deprecated things like using options as arguments and vice versa in console, although the TYPO3 does not deprecate it.
I did so, because I think it does not make sense to mix both in the long run. There is no benefit but just confusion in supporting both.

This is similar. How do you think it is beneficial to convert a returned string to output?

It is just a different way of doing things.

return 'Here is my final output';

vs.

$this->outputLine('Here is my final output');

I don't see how implicit is any better than explicit.
On contrary. You need deep inside knowledge of how command dispatching works to understand the first, while the latter is directly "documented" in the CommandController API.

@mbrodala
Copy link
Contributor Author

mbrodala commented Jan 9, 2018

It's not really limited to CLI, the same works for web requests and always has in Extbase which would lead to an inconsistency:

  1. Returning strings in web controller actions is fine.
  2. Returning strings in command controller commands is deprecated.

We should keep this in mind too.

@helhum
Copy link
Member

helhum commented Jan 9, 2018

It's not really limited to CLI, the same works for web requests and always has in Extbase

Imho one of the major flaws in the CommandController concept is exactly that it tries to mimik
a web request, while it is a totally different domain. Web requests have no interaction, so there won't be any output when a request is running and of course no input.

With the integration of symfony/console into command controllers (long time ago and also in Flow) the previously existing view logic was basically made obsolete, as symfony just directly prints out everything directly.

So yes, command controllers are different, because the domain is different. Trying to apply concepts from web requests to the command line does not help.

And: you can change your command controllers to use $this->outputLine() and it will work with or without TYPO3 Console. It would even work in TYPO3 6.2

@mbrodala
Copy link
Contributor Author

mbrodala commented Jan 9, 2018

Sure thing (and I'll fix my command), just wanted to make sure we don't forget anything here. Personally I'm fine to use the (superior) output API.

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

No branches or pull requests

2 participants