From 9c4c36ee72c01629ecd3eb899afa551b18dc565c Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sat, 30 Jul 2022 15:32:29 +0300 Subject: [PATCH] Fix #19467: Revert changes in `Inflector::camel2words()` (#19495) * Fix #19467: Revert changes in `Inflector::camel2words()` introduced in #19204 * Add UPGRADE note --- framework/CHANGELOG.md | 1 + framework/UPGRADE.md | 6 ++++++ framework/helpers/BaseInflector.php | 2 +- tests/framework/helpers/InflectorTest.php | 3 --- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index c5c3d545ff..31597a208e 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,6 +4,7 @@ Yii Framework 2 Change Log 2.0.46 under development ------------------------ +- Bug #19467: Revert changes in `Inflector::camel2words()` introduced in #19204 (samdark) - Bug #19471: Enable console commands on hostings with disabled `exec()` function (WinterSilence, lubosdz) - Bug #19469: Fix a virtual relation not working because of new isset checks in `\yii\db\ActiveRelationTrait` (wvanheumen) - Bug #19380: Fix PHP 8.1 passing non string to trim() in `yii\db\Query` (wa1kb0y) diff --git a/framework/UPGRADE.md b/framework/UPGRADE.md index 81a09a6ad0..19a6a78160 100644 --- a/framework/UPGRADE.md +++ b/framework/UPGRADE.md @@ -51,6 +51,12 @@ if you want to upgrade from version A to version C and there is version B between A and C, you need to follow the instructions for both A and B. +Upgrade from Yii 2.0.45 +----------------------- + +* Changes in `Inflector::camel2words()` introduced in 2.0.45 were reverted so it works as in pre-2.0.45. If you need + 2.0.45 behavior, [introduce your own method](https://github.com/yiisoft/yii2/pull/19495/files). + Upgrade from Yii 2.0.44 ----------------------- diff --git a/framework/helpers/BaseInflector.php b/framework/helpers/BaseInflector.php index d46aa7ad26..30c1464e85 100644 --- a/framework/helpers/BaseInflector.php +++ b/framework/helpers/BaseInflector.php @@ -388,7 +388,7 @@ class BaseInflector } // Add a space before any uppercase letter preceded by a lowercase letter (xY => x Y) // and any uppercase letter preceded by an uppercase letter and followed by a lowercase letter (XYz => X Yz) - $label = preg_replace('/(?<=\p{Ll})\p{Lu}|(?<=[\p{L}\d])\p{Lu}(?=\p{Ll})|(\d+)/u', ' \0', $name); + $label = preg_replace('/(?<=\p{Ll})\p{Lu}|(?<=\p{L})\p{Lu}(?=\p{Ll})/u', ' \0', $name); $label = mb_strtolower(trim(str_replace(['-', '_', '.'], ' ', $label)), self::encoding()); diff --git a/tests/framework/helpers/InflectorTest.php b/tests/framework/helpers/InflectorTest.php index 5a9199691b..dd56d86e59 100644 --- a/tests/framework/helpers/InflectorTest.php +++ b/tests/framework/helpers/InflectorTest.php @@ -121,9 +121,6 @@ class InflectorTest extends TestCase $this->assertEquals('Foo Bar', Inflector::camel2words('foo BAR')); $this->assertEquals('Foo Bar', Inflector::camel2words('Foo Bar')); $this->assertEquals('Foo Bar', Inflector::camel2words('FOO BAR')); - $this->assertEquals('Order 4 Other Phones', Inflector::camel2words('Order4OtherPhones')); - $this->assertEquals('I Have 23 Dogs', Inflector::camel2words('IHave23Dogs')); - $this->assertEquals('Con Chó Cười 34 Lần', Inflector::camel2words('ConChóCười34Lần')); } public function testCamel2id()