Fixes #16217: Fixed yii\console\controllers\HelpController to work well in Windows environment

This commit is contained in:
Alexander Makarov
2018-05-12 14:47:00 +03:00
committed by GitHub
parent 1945dc69c7
commit e4b559d720
3 changed files with 7 additions and 6 deletions

View File

@@ -30,6 +30,7 @@ install:
- echo extension=php_intl.dll >> php.ini - echo extension=php_intl.dll >> php.ini
- echo extension=php_mbstring.dll >> php.ini - echo extension=php_mbstring.dll >> php.ini
- echo extension=php_openssl.dll >> php.ini - echo extension=php_openssl.dll >> php.ini
- echo extension=php_pdo_sqlite.dll >> php.ini
- IF NOT EXIST C:\tools\composer.phar (cd C:\tools && appveyor DownloadFile https://getcomposer.org/download/1.4.1/composer.phar) - IF NOT EXIST C:\tools\composer.phar (cd C:\tools && appveyor DownloadFile https://getcomposer.org/download/1.4.1/composer.phar)
before_test: before_test:

View File

@@ -19,10 +19,10 @@ Yii Framework 2 Change Log
- Bug #16091: Make `yii\test\InitDbFixture` work with non-SQL DBMS (cebe) - Bug #16091: Make `yii\test\InitDbFixture` work with non-SQL DBMS (cebe)
- Bug #16184: Fixed `yii\base\Widget` to access `stack` property with `self` instead of `static` (yanggs07) - Bug #16184: Fixed `yii\base\Widget` to access `stack` property with `self` instead of `static` (yanggs07)
- Bug #16039: Fixed implicit conversion from `char` to `varbinnary` in MSSQL (vsivsivsi) - Bug #16039: Fixed implicit conversion from `char` to `varbinnary` in MSSQL (vsivsivsi)
- Bug #16217: Fixed `yii\console\controllers\HelpController` to work well in Windows environment (samdark)
- Bug #14636: Views can now use relative paths even when using themed views (sammousa) - Bug #14636: Views can now use relative paths even when using themed views (sammousa)
- Bug #16245: Fixed `__isset()` in `BaseActiveRecord` not catching errors (sammousa) - Bug #16245: Fixed `__isset()` in `BaseActiveRecord` not catching errors (sammousa)
- Enh #16191: Enhanced `yii\helpers\Inflector` to work correctly with UTF-8 (silverfire) - Enh #16191: Enhanced `yii\helpers\Inflector` to work correctly with UTF-8 (silverfire)
- Bug: Fixed bad instnaceof check in `yii\db\Schema::getTableMetadata()` (samdark) - Bug: Fixed bad instnaceof check in `yii\db\Schema::getTableMetadata()` (samdark)

View File

@@ -116,13 +116,13 @@ class HelpController extends Controller
} }
foreach ($controller->getActionArgsHelp($action) as $argument => $help) { foreach ($controller->getActionArgsHelp($action) as $argument => $help) {
$description = str_replace("\n", '', addcslashes($help['comment'], ':')) ?: $argument; $description = preg_replace("~\R~", '', addcslashes($help['comment'], ':')) ?: $argument;
$this->stdout($argument . ':' . $description . "\n"); $this->stdout($argument . ':' . $description . "\n");
} }
$this->stdout("\n"); $this->stdout("\n");
foreach ($controller->getActionOptionsHelp($action) as $argument => $help) { foreach ($controller->getActionOptionsHelp($action) as $argument => $help) {
$description = str_replace("\n", '', addcslashes($help['comment'], ':')); $description = preg_replace("~\R~", '', addcslashes($help['comment'], ':'));
$this->stdout('--' . $argument . ($description ? ':' . $description : '') . "\n"); $this->stdout('--' . $argument . ($description ? ':' . $description : '') . "\n");
} }
} }
@@ -251,16 +251,16 @@ class HelpController extends Controller
$file = $matches[0]; $file = $matches[0];
$relativePath = str_replace($controllerPath, '', $file); $relativePath = str_replace($controllerPath, '', $file);
$class = strtr($relativePath, [ $class = strtr($relativePath, [
DIRECTORY_SEPARATOR => '\\', '/' => '\\',
'.php' => '', '.php' => '',
]); ]);
$controllerClass = $module->controllerNamespace . $class; $controllerClass = $module->controllerNamespace . $class;
if ($this->validateControllerClass($controllerClass)) { if ($this->validateControllerClass($controllerClass)) {
$dir = ltrim(pathinfo($relativePath, PATHINFO_DIRNAME), DIRECTORY_SEPARATOR); $dir = ltrim(pathinfo($relativePath, PATHINFO_DIRNAME), '\\/');
$command = Inflector::camel2id(substr(basename($file), 0, -14), '-', true); $command = Inflector::camel2id(substr(basename($file), 0, -14), '-', true);
if (!empty($dir)) { if (!empty($dir)) {
$command = $dir . DIRECTORY_SEPARATOR . $command; $command = $dir . '/' . $command;
} }
$commands[] = $prefix . $command; $commands[] = $prefix . $command;
} }