Fixes #14307: Fixed PHP warning when yii\console\UnknownCommandException is thrown for empty command

This commit is contained in:
Robert Korulczyk
2017-06-18 17:40:15 +02:00
committed by Alexander Makarov
parent 118aa0a581
commit 8d05e81bd4
3 changed files with 4 additions and 2 deletions

View File

@ -6,6 +6,7 @@ Yii Framework 2 Change Log
- Bug #14248: `yii\console\controllers\MessageController` no longer outputs colorized filenames when console does not support text colorization (PowerGamer1) - Bug #14248: `yii\console\controllers\MessageController` no longer outputs colorized filenames when console does not support text colorization (PowerGamer1)
- Bug #14264: Fixed a bug where `yii\log\Logger::calculateTimings()` was not accepting messages with array tokens (bizley) - Bug #14264: Fixed a bug where `yii\log\Logger::calculateTimings()` was not accepting messages with array tokens (bizley)
- Bug #14307: Fixed PHP warning when `yii\console\UnknownCommandException` is thrown for empty command (rob006)
- Chg #14201: `yii\console\controllers\MessageController::extractMessagesFromTokens()` is now protected (faenir) - Chg #14201: `yii\console\controllers\MessageController::extractMessagesFromTokens()` is now protected (faenir)
- Enh #13787: Added `yii\db\Migration::$maxSqlOutputLength` that allows limiting number of characters for outputting SQL (thiagotalma) - Enh #13787: Added `yii\db\Migration::$maxSqlOutputLength` that allows limiting number of characters for outputting SQL (thiagotalma)
- Enh #14089: Added tests for `yii\base\Theme` (vladis84) - Enh #14089: Added tests for `yii\base\Theme` (vladis84)

View File

@ -67,7 +67,7 @@ class UnknownCommandException extends Exception
public function getSuggestedAlternatives() public function getSuggestedAlternatives()
{ {
$help = $this->application->createController('help'); $help = $this->application->createController('help');
if ($help === false) { if ($help === false || $this->command === '') {
return []; return [];
} }
/** @var $helpController HelpController */ /** @var $helpController HelpController */

View File

@ -14,7 +14,7 @@ use yiiunit\TestCase;
/** /**
* @group console * @group console
*/ */
class UnkownCommandExceptionTest extends TestCase class UnknownCommandExceptionTest extends TestCase
{ {
public function setUp() public function setUp()
{ {
@ -42,6 +42,7 @@ class UnkownCommandExceptionTest extends TestCase
['cach/fush', ['cache/flush']], ['cach/fush', ['cache/flush']],
['cach/fushall', ['cache/flush-all']], ['cach/fushall', ['cache/flush-all']],
['what?', []], ['what?', []],
['', []],
// test UTF 8 chars // test UTF 8 chars
['ёлка', []], ['ёлка', []],
// this crashes levenshtein because string is longer than 255 chars // this crashes levenshtein because string is longer than 255 chars