diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index ba8ba724c1..c3269b521c 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -91,6 +91,7 @@ Yii Framework 2 Change Log - Bug #4880: Return value of yii\web\Request::getPrefferedLanguage() was a normalized value instead of a valid language value from the input array (cebe) - Bug #4905: ActiveForm::$validationDelay doesn't delay after keyrelease when $validateOnType=true (qiangxue) - Bug #4920: `yii\filters\auth\CompositeAuth` should not trigger error as long as one of the methods succeeds (qiangxue) +- Bug #4926: Fixed `yii\console\controllers\MessageController` handles category name containing dot incorrectly (klimov-paul) - Bug #4938: When `yii\db\ActiveQuery` is used to build sub-queries, its WHERE clause is not correctly generated (qiangxue) - Bug #4954: MSSQL column comments are not retrieved correctly (SerjRamone) - Bug #4970: `joinWith()` called by a relation was ignored by `yii\db\ActiveQuery` (stepanselyuk) diff --git a/framework/console/controllers/MessageController.php b/framework/console/controllers/MessageController.php index 1e1b5f1c4b..7a1e335736 100644 --- a/framework/console/controllers/MessageController.php +++ b/framework/console/controllers/MessageController.php @@ -260,13 +260,9 @@ class MessageController extends Controller PREG_SET_ORDER ); for ($i = 0; $i < $n; ++$i) { - if (($pos = strpos($matches[$i][1], '.')) !== false) { - $category = substr($matches[$i][1], $pos + 1, -1); - } else { - $category = substr($matches[$i][1], 1, -1); - } + $category = substr($matches[$i][1], 1, -1); $message = $matches[$i][2]; - $messages[$category][] = eval("return $message;"); // use eval to eliminate quote escape + $messages[$category][] = eval("return {$message};"); // use eval to eliminate quote escape } } diff --git a/tests/unit/framework/console/controllers/BaseMessageControllerTest.php b/tests/unit/framework/console/controllers/BaseMessageControllerTest.php index 0295d4037f..1aadd62f7c 100644 --- a/tests/unit/framework/console/controllers/BaseMessageControllerTest.php +++ b/tests/unit/framework/console/controllers/BaseMessageControllerTest.php @@ -139,7 +139,7 @@ abstract class BaseMessageControllerTest extends TestCase public function testCreateTranslation() { - $category = 'test_category1'; + $category = 'test.category1'; $message = 'test message'; $sourceFileContent = "Yii::t('{$category}', '{$message}');"; $this->createSourceFile($sourceFileContent); @@ -200,7 +200,7 @@ abstract class BaseMessageControllerTest extends TestCase /** * @depends testMerge */ - public function testMarkObosoleteMessages() + public function testMarkObsoleteMessages() { $category = 'category'; @@ -223,7 +223,7 @@ abstract class BaseMessageControllerTest extends TestCase /** * @depends testMerge */ - public function removeObosoleteMessages() + public function removeObsoleteMessages() { $category = 'category';