Commit 154f2828 authored by catch's avatar catch

Issue #2849669 by alexpott, pwolanin, Munavijayalakshmi, dawehner: Fix...

Issue #2849669 by alexpott, pwolanin, Munavijayalakshmi, dawehner: Fix \Drupal\Component\Utility\Unicode() because of the Symfony mbstring polyfill
parent 2a7952f2
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
* *
* Correct: * Correct:
* @code * @code
* $my_substring = Unicode::substr($original_string, 0, 5); * $my_substring = mb_substr($original_string, 0, 5);
* @endcode * @endcode
* *
* @} * @}
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
*/ */
use Drupal\Component\FileSystem\FileSystem as ComponentFileSystem; use Drupal\Component\FileSystem\FileSystem as ComponentFileSystem;
use Drupal\Component\Utility\Unicode;
use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\UrlHelper;
use Drupal\Component\PhpStorage\FileStorage; use Drupal\Component\PhpStorage\FileStorage;
use Drupal\Component\Utility\Bytes; use Drupal\Component\Utility\Bytes;
...@@ -202,7 +201,7 @@ function file_create_url($uri) { ...@@ -202,7 +201,7 @@ function file_create_url($uri) {
// HTTP and to https://example.com/bar.jpg when viewing a HTTPS page) // HTTP and to https://example.com/bar.jpg when viewing a HTTPS page)
// Both types of relative URIs are characterized by a leading slash, hence // Both types of relative URIs are characterized by a leading slash, hence
// we can use a single check. // we can use a single check.
if (Unicode::substr($uri, 0, 1) == '/') { if (mb_substr($uri, 0, 1) == '/') {
return $uri; return $uri;
} }
else { else {
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Html;
use Drupal\Component\Render\MarkupInterface; use Drupal\Component\Render\MarkupInterface;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Config\Config; use Drupal\Core\Config\Config;
use Drupal\Core\Config\StorageException; use Drupal\Core\Config\StorageException;
...@@ -485,7 +484,7 @@ function theme_settings_convert_to_config(array $theme_settings, Config $config) ...@@ -485,7 +484,7 @@ function theme_settings_convert_to_config(array $theme_settings, Config $config)
$config->set('favicon.mimetype', $value); $config->set('favicon.mimetype', $value);
} }
elseif (substr($key, 0, 7) == 'toggle_') { elseif (substr($key, 0, 7) == 'toggle_') {
$config->set('features.' . Unicode::substr($key, 7), $value); $config->set('features.' . mb_substr($key, 7), $value);
} }
elseif (!in_array($key, ['theme', 'logo_upload'])) { elseif (!in_array($key, ['theme', 'logo_upload'])) {
$config->set($key, $value); $config->set($key, $value);
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
* Theming for maintenance pages. * Theming for maintenance pages.
*/ */
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Site\Settings; use Drupal\Core\Site\Settings;
/** /**
...@@ -29,7 +28,6 @@ function _drupal_maintenance_theme() { ...@@ -29,7 +28,6 @@ function _drupal_maintenance_theme() {
require_once __DIR__ . '/file.inc'; require_once __DIR__ . '/file.inc';
require_once __DIR__ . '/module.inc'; require_once __DIR__ . '/module.inc';
require_once __DIR__ . '/database.inc'; require_once __DIR__ . '/database.inc';
Unicode::check();
// Install and update pages are treated differently to prevent theming overrides. // Install and update pages are treated differently to prevent theming overrides.
if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) { if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
namespace Drupal\Component\Diff\Engine; namespace Drupal\Component\Diff\Engine;
use Drupal\Component\Utility\Unicode;
/** /**
* Class used internally by Diff to actually compute the diffs. * Class used internally by Diff to actually compute the diffs.
* *
...@@ -134,7 +132,7 @@ public function diff($from_lines, $to_lines) { ...@@ -134,7 +132,7 @@ public function diff($from_lines, $to_lines) {
* Returns the whole line if it's small enough, or the MD5 hash otherwise. * Returns the whole line if it's small enough, or the MD5 hash otherwise.
*/ */
protected function _line_hash($line) { protected function _line_hash($line) {
if (Unicode::strlen($line) > $this::MAX_XREF_LENGTH) { if (mb_strlen($line) > $this::MAX_XREF_LENGTH) {
return md5($line); return md5($line);
} }
else { else {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
namespace Drupal\Component\Diff\Engine; namespace Drupal\Component\Diff\Engine;
use Drupal\Component\Utility\Unicode;
/** /**
* Additions by Axel Boldt follow, partly taken from diff.php, phpwiki-1.3.3 * Additions by Axel Boldt follow, partly taken from diff.php, phpwiki-1.3.3
*/ */
...@@ -64,7 +62,7 @@ public function addWords($words, $tag = '') { ...@@ -64,7 +62,7 @@ public function addWords($words, $tag = '') {
} }
if ($word[0] == "\n") { if ($word[0] == "\n") {
$this->_flushLine($tag); $this->_flushLine($tag);
$word = Unicode::substr($word, 1); $word = mb_substr($word, 1);
} }
assert(!strstr($word, "\n")); assert(!strstr($word, "\n"));
$this->group .= $word; $this->group .= $word;
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace Drupal\Component\Diff; namespace Drupal\Component\Diff;
use Drupal\Component\Diff\Engine\HWLDFWordAccumulator; use Drupal\Component\Diff\Engine\HWLDFWordAccumulator;
use Drupal\Component\Utility\Unicode;
/** /**
* @todo document * @todo document
...@@ -35,7 +34,7 @@ protected function _split($lines) { ...@@ -35,7 +34,7 @@ protected function _split($lines) {
$words[] = "\n"; $words[] = "\n";
$stripped[] = "\n"; $stripped[] = "\n";
} }
if (Unicode::strlen($line) > $this::MAX_LINE_LENGTH) { if (mb_strlen($line) > $this::MAX_LINE_LENGTH) {
$words[] = $line; $words[] = $line;
$stripped[] = $line; $stripped[] = $line;
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"license": "GPL-2.0-or-later", "license": "GPL-2.0-or-later",
"require": { "require": {
"php": ">=5.5.9", "php": ">=5.5.9",
"drupal/core-utility": "^8.2" "symfony/polyfill-mbstring": "~1.0"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace Drupal\Component\Render; namespace Drupal\Component\Render;
use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Unicode;
use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\UrlHelper;
/** /**
...@@ -107,7 +106,7 @@ public function __toString() { ...@@ -107,7 +106,7 @@ public function __toString() {
* The length of the string. * The length of the string.
*/ */
public function count() { public function count() {
return Unicode::strlen($this->string); return mb_strlen($this->string);
} }
/** /**
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace Drupal\Component\Render; namespace Drupal\Component\Render;
use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Unicode;
/** /**
* Escapes HTML syntax characters to HTML entities for display in markup. * Escapes HTML syntax characters to HTML entities for display in markup.
...@@ -43,7 +42,7 @@ public function __toString() { ...@@ -43,7 +42,7 @@ public function __toString() {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function count() { public function count() {
return Unicode::strlen($this->string); return mb_strlen($this->string);
} }
/** /**
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
namespace Drupal\Component\Render; namespace Drupal\Component\Render;
use Drupal\Component\Utility\Unicode;
/** /**
* Implements MarkupInterface and Countable for rendered objects. * Implements MarkupInterface and Countable for rendered objects.
* *
...@@ -61,7 +59,7 @@ public function __toString() { ...@@ -61,7 +59,7 @@ public function __toString() {
* The length of the string. * The length of the string.
*/ */
public function count() { public function count() {
return Unicode::strlen($this->string); return mb_strlen($this->string);
} }
/** /**
......
...@@ -23,7 +23,7 @@ public static function validateHex($hex) { ...@@ -23,7 +23,7 @@ public static function validateHex($hex) {
// Hash prefix is optional. // Hash prefix is optional.
$hex = ltrim($hex, '#'); $hex = ltrim($hex, '#');
// Must be either RGB or RRGGBB. // Must be either RGB or RRGGBB.
$length = Unicode::strlen($hex); $length = mb_strlen($hex);
$valid = $valid && ($length === 3 || $length === 6); $valid = $valid && ($length === 3 || $length === 6);
// Must be a valid hex value. // Must be a valid hex value.
$valid = $valid && ctype_xdigit($hex); $valid = $valid && ctype_xdigit($hex);
......
...@@ -71,7 +71,7 @@ class Html { ...@@ -71,7 +71,7 @@ class Html {
public static function getClass($class) { public static function getClass($class) {
$class = (string) $class; $class = (string) $class;
if (!isset(static::$classes[$class])) { if (!isset(static::$classes[$class])) {
static::$classes[$class] = static::cleanCssIdentifier(Unicode::strtolower($class)); static::$classes[$class] = static::cleanCssIdentifier(mb_strtolower($class));
} }
return static::$classes[$class]; return static::$classes[$class];
} }
...@@ -215,7 +215,7 @@ public static function getUniqueId($id) { ...@@ -215,7 +215,7 @@ public static function getUniqueId($id) {
* @see self::getUniqueId() * @see self::getUniqueId()
*/ */
public static function getId($id) { public static function getId($id) {
$id = str_replace([' ', '_', '[', ']'], ['-', '-', '-', ''], Unicode::strtolower($id)); $id = str_replace([' ', '_', '[', ']'], ['-', '-', '-', ''], mb_strtolower($id));
// As defined in http://www.w3.org/TR/html4/types.html#type-name, HTML IDs can // As defined in http://www.w3.org/TR/html4/types.html#type-name, HTML IDs can
// only contain letters, digits ([0-9]), hyphens ("-"), underscores ("_"), // only contain letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
......
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
"require": { "require": {
"php": ">=5.5.9", "php": ">=5.5.9",
"paragonie/random_compat": "^1.0|^2.0", "paragonie/random_compat": "^1.0|^2.0",
"drupal/core-render": "^8.2" "drupal/core-render": "^8.2",
"symfony/polyfill-iconv": "~1.0",
"symfony/polyfill-mbstring": "~1.0"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
......
...@@ -119,7 +119,7 @@ public function loadFile($file, $optimize = NULL, $reset_basepath = TRUE) { ...@@ -119,7 +119,7 @@ public function loadFile($file, $optimize = NULL, $reset_basepath = TRUE) {
// If a BOM is found, convert the file to UTF-8, then use substr() to // If a BOM is found, convert the file to UTF-8, then use substr() to
// remove the BOM from the result. // remove the BOM from the result.
if ($encoding = (Unicode::encodingFromBOM($contents))) { if ($encoding = (Unicode::encodingFromBOM($contents))) {
$contents = Unicode::substr(Unicode::convertToUtf8($contents, $encoding), 1); $contents = mb_substr(Unicode::convertToUtf8($contents, $encoding), 1);
} }
// If no BOM, check for fallback encoding. Per CSS spec the regex is very strict. // If no BOM, check for fallback encoding. Per CSS spec the regex is very strict.
elseif (preg_match('/^@charset "([^"]+)";/', $contents, $matches)) { elseif (preg_match('/^@charset "([^"]+)";/', $contents, $matches)) {
......
...@@ -24,7 +24,7 @@ public function optimize(array $js_asset) { ...@@ -24,7 +24,7 @@ public function optimize(array $js_asset) {
// remove the BOM from the result. // remove the BOM from the result.
$data = file_get_contents($js_asset['data']); $data = file_get_contents($js_asset['data']);
if ($encoding = (Unicode::encodingFromBOM($data))) { if ($encoding = (Unicode::encodingFromBOM($data))) {
$data = Unicode::substr(Unicode::convertToUtf8($data, $encoding), 1); $data = mb_substr(Unicode::convertToUtf8($data, $encoding), 1);
} }
// If no BOM is found, check for the charset attribute. // If no BOM is found, check for the charset attribute.
elseif (isset($js_asset['attributes']['charset'])) { elseif (isset($js_asset['attributes']['charset'])) {
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
use Drupal\Core\Messenger\MessengerTrait; use Drupal\Core\Messenger\MessengerTrait;
use Drupal\Core\Plugin\ContextAwarePluginAssignmentTrait; use Drupal\Core\Plugin\ContextAwarePluginAssignmentTrait;
use Drupal\Core\Plugin\ContextAwarePluginBase; use Drupal\Core\Plugin\ContextAwarePluginBase;
use Drupal\Component\Utility\Unicode;
use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Plugin\PluginWithFormsInterface; use Drupal\Core\Plugin\PluginWithFormsInterface;
...@@ -246,7 +245,7 @@ public function getMachineNameSuggestion() { ...@@ -246,7 +245,7 @@ public function getMachineNameSuggestion() {
// \Drupal\system\MachineNameController::transliterate(), so it might make // \Drupal\system\MachineNameController::transliterate(), so it might make
// sense to provide a common service for the two. // sense to provide a common service for the two.
$transliterated = $this->transliteration()->transliterate($admin_label, LanguageInterface::LANGCODE_DEFAULT, '_'); $transliterated = $this->transliteration()->transliterate($admin_label, LanguageInterface::LANGCODE_DEFAULT, '_');
$transliterated = Unicode::strtolower($transliterated); $transliterated = mb_strtolower($transliterated);
$transliterated = preg_replace('@[^a-z0-9_.]+@', '', $transliterated); $transliterated = preg_replace('@[^a-z0-9_.]+@', '', $transliterated);
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace Drupal\Core\Config; namespace Drupal\Core\Config;
use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Crypt;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Config\Entity\ConfigDependencyManager; use Drupal\Core\Config\Entity\ConfigDependencyManager;
use Drupal\Core\Config\Entity\ConfigEntityDependency; use Drupal\Core\Config\Entity\ConfigEntityDependency;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
...@@ -344,7 +343,7 @@ public function installCollectionDefaultConfig($collection) { ...@@ -344,7 +343,7 @@ public function installCollectionDefaultConfig($collection) {
// Only install configuration for enabled extensions. // Only install configuration for enabled extensions.
$enabled_extensions = $this->getEnabledExtensions(); $enabled_extensions = $this->getEnabledExtensions();
$config_to_install = array_filter($storage->listAll(), function ($config_name) use ($enabled_extensions) { $config_to_install = array_filter($storage->listAll(), function ($config_name) use ($enabled_extensions) {
$provider = Unicode::substr($config_name, 0, strpos($config_name, '.')); $provider = mb_substr($config_name, 0, strpos($config_name, '.'));
return in_array($provider, $enabled_extensions); return in_array($provider, $enabled_extensions);
}); });
if (!empty($config_to_install)) { if (!empty($config_to_install)) {
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
namespace Drupal\Core\Config\Entity\Query; namespace Drupal\Core\Config\Entity\Query;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Entity\Query\ConditionBase; use Drupal\Core\Entity\Query\ConditionBase;
use Drupal\Core\Entity\Query\ConditionInterface; use Drupal\Core\Entity\Query\ConditionInterface;
use Drupal\Core\Entity\Query\QueryException; use Drupal\Core\Entity\Query\QueryException;
...@@ -32,10 +31,10 @@ public function compile($configs) { ...@@ -32,10 +31,10 @@ public function compile($configs) {
// Lowercase condition value(s) for case-insensitive matches. // Lowercase condition value(s) for case-insensitive matches.
if (is_array($condition['value'])) { if (is_array($condition['value'])) {
$condition['value'] = array_map('Drupal\Component\Utility\Unicode::strtolower', $condition['value']); $condition['value'] = array_map('mb_strtolower', $condition['value']);
} }
elseif (!is_bool($condition['value'])) { elseif (!is_bool($condition['value'])) {
$condition['value'] = Unicode::strtolower($condition['value']); $condition['value'] = mb_strtolower($condition['value']);
} }
$single_conditions[] = $condition; $single_conditions[] = $condition;
...@@ -164,7 +163,7 @@ protected function match(array $condition, $value) { ...@@ -164,7 +163,7 @@ protected function match(array $condition, $value) {
if (isset($value)) { if (isset($value)) {
// We always want a case-insensitive match. // We always want a case-insensitive match.
if (!is_bool($value)) { if (!is_bool($value)) {
$value = Unicode::strtolower($value); $value = mb_strtolower($value);
} }
switch ($condition['operator']) { switch ($condition['operator']) {
......
...@@ -212,7 +212,7 @@ protected function processField($field) { ...@@ -212,7 +212,7 @@ protected function processField($field) {
// Set the correct database-engine specific datatype. // Set the correct database-engine specific datatype.
// In case one is already provided, force it to uppercase. // In case one is already provided, force it to uppercase.
if (isset($field['mysql_type'])) { if (isset($field['mysql_type'])) {
$field['mysql_type'] = Unicode::strtoupper($field['mysql_type']); $field['mysql_type'] = mb_strtoupper($field['mysql_type']);
} }
else { else {
$map = $this->getFieldTypeMap(); $map = $this->getFieldTypeMap();
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
namespace Drupal\Core\Database\Driver\pgsql; namespace Drupal\Core\Database\Driver\pgsql;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Database\SchemaObjectExistsException; use Drupal\Core\Database\SchemaObjectExistsException;
use Drupal\Core\Database\SchemaObjectDoesNotExistException; use Drupal\Core\Database\SchemaObjectDoesNotExistException;
use Drupal\Core\Database\Schema as DatabaseSchema; use Drupal\Core\Database\Schema as DatabaseSchema;
...@@ -350,7 +349,7 @@ protected function processField($field) { ...@@ -350,7 +349,7 @@ protected function processField($field) {
// Set the correct database-engine specific datatype. // Set the correct database-engine specific datatype.
// In case one is already provided, force it to lowercase. // In case one is already provided, force it to lowercase.
if (isset($field['pgsql_type'])) { if (isset($field['pgsql_type'])) {
$field['pgsql_type'] = Unicode::strtolower($field['pgsql_type']); $field['pgsql_type'] = mb_strtolower($field['pgsql_type']);
} }
else { else {
$map = $this->getFieldTypeMap(); $map = $this->getFieldTypeMap();
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
namespace Drupal\Core\Database\Driver\sqlite; namespace Drupal\Core\Database\Driver\sqlite;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Database\SchemaObjectExistsException; use Drupal\Core\Database\SchemaObjectExistsException;
use Drupal\Core\Database\SchemaObjectDoesNotExistException; use Drupal\Core\Database\SchemaObjectDoesNotExistException;
use Drupal\Core\Database\Schema as DatabaseSchema; use Drupal\Core\Database\Schema as DatabaseSchema;
...@@ -131,7 +130,7 @@ protected function processField($field) { ...@@ -131,7 +130,7 @@ protected function processField($field) {
// Set the correct database-engine specific datatype. // Set the correct database-engine specific datatype.
// In case one is already provided, force it to uppercase. // In case one is already provided, force it to uppercase.
if (isset($field['sqlite_type'])) { if (isset($field['sqlite_type'])) {
$field['sqlite_type'] = Unicode::strtoupper($field['sqlite_type']); $field['sqlite_type'] = mb_strtoupper($field['sqlite_type']);
} }
else { else {
$map = $this->getFieldTypeMap(); $map = $this->getFieldTypeMap();
......
...@@ -375,7 +375,8 @@ protected function mapConditionOperator($operator) { ...@@ -375,7 +375,8 @@ protected function mapConditionOperator($operator) {
} }
else { else {
// We need to upper case because PHP index matches are case sensitive but // We need to upper case because PHP index matches are case sensitive but
// do not need the more expensive Unicode::strtoupper() because SQL statements are ASCII. // do not need the more expensive mb_strtoupper() because SQL statements
// are ASCII.
$operator = strtoupper($operator); $operator = strtoupper($operator);
$return = isset(static::$conditionOperatorMap[$operator]) ? static::$conditionOperatorMap[$operator] : []; $return = isset(static::$conditionOperatorMap[$operator]) ? static::$conditionOperatorMap[$operator] : [];
} }
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
use Composer\Autoload\ClassLoader; use Composer\Autoload\ClassLoader;
use Drupal\Component\Assertion\Handle; use Drupal\Component\Assertion\Handle;
use Drupal\Component\FileCache\FileCacheFactory; use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Component\Utility\Unicode;
use Drupal\Component\Utility\UrlHelper; use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Cache\DatabaseBackend; use Drupal\Core\Cache\DatabaseBackend;
use Drupal\Core\Config\BootstrapConfigStorageFactory; use Drupal\Core\Config\BootstrapConfigStorageFactory;
...@@ -1000,8 +999,9 @@ public static function bootEnvironment($app_root = NULL) { ...@@ -1000,8 +999,9 @@ public static function bootEnvironment($app_root = NULL) {
// numbers handling. // numbers handling.
setlocale(LC_ALL, 'C'); setlocale(LC_ALL, 'C');
// Detect string handling method. // Set appropriate configuration for multi-byte strings.
Unicode::check(); mb_internal_encoding('utf-8');
mb_language('uni');
// Indicate that code is operating in a test child site. // Indicate that code is operating in a test child site.
if (!defined('DRUPAL_TEST_IN_CHILD_SITE')) { if (!defined('DRUPAL_TEST_IN_CHILD_SITE')) {
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\RefinableCacheableDependencyTrait; use Drupal\Core\Cache\RefinableCacheableDependencyTrait;
use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException; use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException;
use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException; use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
...@@ -431,7 +430,7 @@ public function preSave(EntityStorageInterface $storage) { ...@@ -431,7 +430,7 @@ public function preSave(EntityStorageInterface $storage) {
// Check if this is an entity bundle. // Check if this is an entity bundle.
if ($this->getEntityType()->getBundleOf()) { if ($this->getEntityType()->getBundleOf()) {
// Throw an exception if the bundle ID is longer than 32 characters. // Throw an exception if the bundle ID is longer than 32 characters.
if (Unicode::strlen($this->id()) > EntityTypeInterface::BUNDLE_MAX_LENGTH) { if (mb_strlen($this->id()) > EntityTypeInterface::BUNDLE_MAX_LENGTH) {
throw new ConfigEntityIdLengthException("Attempt to create a bundle with an ID longer than " . EntityTypeInterface::BUNDLE_MAX_LENGTH . " characters: $this->id()."); throw new ConfigEntityIdLengthException("Attempt to create a bundle with an ID longer than " . EntityTypeInterface::BUNDLE_MAX_LENGTH . " characters: $this->id().");
} }
} }
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace Drupal\Core\Entity; namespace Drupal\Core\Entity;
use Drupal\Component\Plugin\Definition\PluginDefinition; use Drupal\Component\Plugin\Definition\PluginDefinition;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Entity\Exception\EntityTypeIdLengthException; use Drupal\Core\Entity\Exception\EntityTypeIdLengthException;
use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\StringTranslation\TranslatableMarkup;
...@@ -295,7 +294,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface { ...@@ -295,7 +294,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface {
*/ */
public function __construct($definition) { public function __construct($definition) {
// Throw an exception if the entity type ID is longer than 32 characters. // Throw an exception if the entity type ID is longer than 32 characters.
if (Unicode::strlen($definition['id']) > static::ID_MAX_LENGTH) { if (mb_strlen($definition['id']) > static::ID_MAX_LENGTH) {
throw new EntityTypeIdLengthException('Attempt to create an entity type with an ID longer than ' . static::ID_MAX_LENGTH . " characters: {$definition['id']}."); throw new EntityTypeIdLengthException('Attempt to create an entity type with an ID longer than ' . static::ID_MAX_LENGTH . " characters: {$definition['id']}.");
} }
...@@ -768,7 +767,7 @@ public function getLabel() { ...@@ -768,7 +767,7 @@ public function getLabel() {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getLowercaseLabel() { public function getLowercaseLabel() {
return Unicode::strtolower($this->getLabel()); return mb_strtolower($this->getLabel());
} }
/** /**
......