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

[BUGFIX] Output command method return value, but deprecate it #661

Merged
merged 1 commit into from
Jan 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions Classes/Mvc/Controller/CommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,10 @@ protected function callCommandMethod()
$preparedArguments[] = $argument->getValue();
}
$commandResult = $this->{$this->commandMethodName}(...$preparedArguments);
if (is_string($commandResult) && $commandResult !== '') {
$this->response->appendContent($commandResult);
} elseif (is_object($commandResult) && method_exists($commandResult, '__toString')) {
$this->response->appendContent((string)$commandResult);
if ($commandResult !== null) {
$this->outputLine((string)$commandResult);
$this->outputLine('<warning>Returning a string from a command method is deprecated.</warning>');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This not a good solution since it changes the output of commands. If you e.g. use the output of a command for another command, this would be broken. This should use the regular deprecation logic of TYPO3 instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, now I'm lost. Can you create a ticket with a use case you see failing? Or re-open the existing ticket?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple usecase:

curl -sS bin/typo3cms foo:geturl

Whereas foo:geturl normally only returns an URL, it now returns additional lines with a warning and thus breaks the web request.

$this->outputLine('<warning>Please use $this->outputLine() instead.</warning>');
}
}

Expand Down