From 5e06727e4ef68589ff9e234829656a50c39a77d3 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Wed, 18 Jul 2018 15:24:33 -0700 Subject: [PATCH] Fixed #3111 better implementation for #3090 --- CHANGELOG-v3.md | 1 + src/helpers/StringHelper.php | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index 25b069c3056..16204b76a89 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -4,6 +4,7 @@ ### Fixed - Fixed a bug where the `orderBy` element query param wasn’t being respected when used in conjunction with a `with` param to eager-load elements in a specific order. ([#3109](https://github.com/craftcms/cms/issues/3109)) +- Fixed a bug where underscores were getting removed from slugs. ([#3111](https://github.com/craftcms/cms/issues/3111)) ## 3.0.16 - 2018-07-17 diff --git a/src/helpers/StringHelper.php b/src/helpers/StringHelper.php index 943696c9ef3..bb2d958be31 100644 --- a/src/helpers/StringHelper.php +++ b/src/helpers/StringHelper.php @@ -11,7 +11,6 @@ use Stringy\Stringy as BaseStringy; use yii\base\Exception; use yii\base\InvalidConfigException; -use yii\helpers\Inflector; /** * This helper class provides various multi-byte aware string related manipulation and encoding methods. @@ -1039,9 +1038,12 @@ public static function encodeMb4(string $string): string */ private static function _prepStringForCasing(string $string, bool $lower = true, bool $removePunctuation = true): array { + // Convert CamelCase to multiple words + $string = preg_replace('/(?