From e4b559d720168b43c70233b08ca1a30514c7ed59 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sat, 12 May 2018 14:47:00 +0300 Subject: [PATCH] Fixes #16217: Fixed `yii\console\controllers\HelpController` to work well in Windows environment --- .appveyor.yml | 1 + framework/CHANGELOG.md | 2 +- framework/console/controllers/HelpController.php | 10 +++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index ad34461ebf..d9a7f7e0cd 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -30,6 +30,7 @@ install: - echo extension=php_intl.dll >> php.ini - echo extension=php_mbstring.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) before_test: diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index bc11f1c94a..792f796c94 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -19,10 +19,10 @@ Yii Framework 2 Change Log - 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 #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 #16245: Fixed `__isset()` in `BaseActiveRecord` not catching errors (sammousa) - Enh #16191: Enhanced `yii\helpers\Inflector` to work correctly with UTF-8 (silverfire) - - Bug: Fixed bad instnaceof check in `yii\db\Schema::getTableMetadata()` (samdark) diff --git a/framework/console/controllers/HelpController.php b/framework/console/controllers/HelpController.php index 5bb5040ff7..20d695fb0e 100644 --- a/framework/console/controllers/HelpController.php +++ b/framework/console/controllers/HelpController.php @@ -116,13 +116,13 @@ class HelpController extends Controller } 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("\n"); 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"); } } @@ -251,16 +251,16 @@ class HelpController extends Controller $file = $matches[0]; $relativePath = str_replace($controllerPath, '', $file); $class = strtr($relativePath, [ - DIRECTORY_SEPARATOR => '\\', + '/' => '\\', '.php' => '', ]); $controllerClass = $module->controllerNamespace . $class; 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); if (!empty($dir)) { - $command = $dir . DIRECTORY_SEPARATOR . $command; + $command = $dir . '/' . $command; } $commands[] = $prefix . $command; }