summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-11-05 09:24:11 (GMT)
committerAlex Pott2014-11-05 09:24:11 (GMT)
commit12ba160d0a686c354c906503cb6f55eb13eaeaa0 (patch)
tree8d61dc1de9eb3c49b97b9339c41bc18c16619e5c
parent55286952b6cb45d6540ddf2ad6ef3d84931f74f1 (diff)
Issue #2361797 by rpayanm, Palashvijay4O, er.pushpinderrana: Remove usage of drupal_strlen().
-rw-r--r--core/lib/Drupal/Core/Mail/MailFormatHelper.php3
-rw-r--r--core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php2
-rw-r--r--core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php2
-rw-r--r--core/modules/filter/filter.module2
-rw-r--r--core/modules/image/image.field.inc3
-rw-r--r--core/modules/menu_ui/src/Tests/MenuTest.php5
-rw-r--r--core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php3
-rw-r--r--core/modules/responsive_image/responsive_image.module3
-rw-r--r--core/modules/search/search.module4
-rw-r--r--core/modules/search/src/SearchQuery.php3
-rw-r--r--core/modules/search/src/Tests/SearchSimplifyTest.php4
-rw-r--r--core/modules/system/src/Tests/Mail/HtmlToTextTest.php2
-rw-r--r--core/modules/text/text.module2
-rw-r--r--core/modules/user/src/AccountForm.php3
-rw-r--r--core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php3
-rw-r--r--core/modules/user/user.module2
-rw-r--r--core/modules/views/src/Plugin/views/field/FieldPluginBase.php4
-rw-r--r--core/modules/views/src/Plugin/views/filter/InOperator.php2
-rw-r--r--core/modules/views_ui/views_ui.module2
19 files changed, 31 insertions, 23 deletions
diff --git a/core/lib/Drupal/Core/Mail/MailFormatHelper.php b/core/lib/Drupal/Core/Mail/MailFormatHelper.php
index 2d8fe99..c17da77 100644
--- a/core/lib/Drupal/Core/Mail/MailFormatHelper.php
+++ b/core/lib/Drupal/Core/Mail/MailFormatHelper.php
@@ -9,6 +9,7 @@ namespace Drupal\Core\Mail;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\String;
+use Drupal\Component\Utility\Unicode;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Site\Settings;
@@ -264,7 +265,7 @@ class MailFormatHelper {
// Convert inline HTML text to plain text; not removing line-breaks or
// white-space, since that breaks newlines when sanitizing plain-text.
$value = trim(String::decodeEntities($value));
- if (drupal_strlen($value)) {
+ if (Unicode::strlen($value)) {
$chunk = $value;
}
}
diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php
index 54f3648..cdb7246 100644
--- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php
+++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php
@@ -99,7 +99,7 @@ class ItemList extends TypedData implements \IteratorAggregate, ListInterface {
$strings[] = $item->getString();
}
// Remove any empty strings resulting from empty items.
- return implode(', ', array_filter($strings, 'drupal_strlen'));
+ return implode(', ', array_filter($strings, '\Drupal\Component\Utility\Unicode::strlen'));
}
}
diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php
index bc699cc..abb1c9c 100644
--- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php
+++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php
@@ -115,7 +115,7 @@ class Map extends TypedData implements \IteratorAggregate, ComplexDataInterface
$strings[] = $property->getString();
}
// Remove any empty strings resulting from empty items.
- return implode(', ', array_filter($strings, 'drupal_strlen'));
+ return implode(', ', array_filter($strings, '\Drupal\Component\Utility\Unicode::strlen'));
}
/**
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index 7af6732..a14d730 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -784,7 +784,7 @@ function _filter_html_escape($text) {
function _filter_html_image_secure_process($text) {
// Find the path (e.g. '/') to Drupal root.
$base_path = base_path();
- $base_path_length = drupal_strlen($base_path);
+ $base_path_length = Unicode::strlen($base_path);
// Find the directory on the server where index.php resides.
$local_dir = DRUPAL_ROOT . '/';
diff --git a/core/modules/image/image.field.inc b/core/modules/image/image.field.inc
index 4668e26..3f44993 100644
--- a/core/modules/image/image.field.inc
+++ b/core/modules/image/image.field.inc
@@ -6,6 +6,7 @@
*/
use Drupal\Component\Utility\NestedArray;
+use Drupal\Component\Utility\Unicode;
use Drupal\Core\Render\Element;
/**
@@ -64,7 +65,7 @@ function template_preprocess_image_formatter(&$variables) {
$item = $variables['item'];
// Do not output an empty 'title' attribute.
- if (drupal_strlen($item->title) != 0) {
+ if (Unicode::strlen($item->title) != 0) {
$variables['image']['#title'] = $item->title;
}
diff --git a/core/modules/menu_ui/src/Tests/MenuTest.php b/core/modules/menu_ui/src/Tests/MenuTest.php
index c35d0d1..1b09615 100644
--- a/core/modules/menu_ui/src/Tests/MenuTest.php
+++ b/core/modules/menu_ui/src/Tests/MenuTest.php
@@ -8,6 +8,7 @@
namespace Drupal\menu_ui\Tests;
use Drupal\Component\Serialization\Json;
+use Drupal\Component\Utility\Unicode;
use Drupal\Core\Menu\MenuLinkInterface;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\system\Entity\Menu;
@@ -175,7 +176,7 @@ class MenuTest extends MenuWebTestBase {
$this->assertRaw(t('!name cannot be longer than %max characters but is currently %length characters long.', array(
'!name' => t('Menu name'),
'%max' => MENU_MAX_MENU_NAME_LENGTH_UI,
- '%length' => drupal_strlen($menu_name),
+ '%length' => Unicode::strlen($menu_name),
)));
// Change the menu_name so it no longer exceeds the maximum length.
@@ -187,7 +188,7 @@ class MenuTest extends MenuWebTestBase {
$this->assertNoRaw(t('!name cannot be longer than %max characters but is currently %length characters long.', array(
'!name' => t('Menu name'),
'%max' => MENU_MAX_MENU_NAME_LENGTH_UI,
- '%length' => drupal_strlen($menu_name),
+ '%length' => Unicode::strlen($menu_name),
)));
// Verify that the confirmation message is displayed.
$this->assertRaw(t('Menu %label has been added.', array('%label' => $label)));
diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php b/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php
index 37053c3..d74049a 100644
--- a/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php
+++ b/core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php
@@ -7,6 +7,7 @@
namespace Drupal\options\Plugin\Field\FieldType;
+use Drupal\Component\Utility\Unicode;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\TypedData\DataDefinition;
@@ -68,7 +69,7 @@ class ListStringItem extends ListItemBase {
* {@inheritdoc}
*/
protected static function validateAllowedValue($option) {
- if (drupal_strlen($option) > 255) {
+ if (Unicode::strlen($option) > 255) {
return t('Allowed values list: each key must be a string at most 255 characters long.');
}
}
diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module
index 7992815..bdb2a83 100644
--- a/core/modules/responsive_image/responsive_image.module
+++ b/core/modules/responsive_image/responsive_image.module
@@ -6,6 +6,7 @@
*/
use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Unicode;
use Drupal\Core\Routing\RouteMatchInterface;
use \Drupal\Core\Template\Attribute;
use Drupal\Core\Url;
@@ -144,7 +145,7 @@ function theme_responsive_image_formatter($variables) {
$responsive_image['#entity'] = $entity;
}
$responsive_image['#alt'] = $item->alt;
- if (drupal_strlen($item->title) != 0) {
+ if (Unicode::strlen($item->title) != 0) {
$responsive_image['#title'] = $item->title;
}
// @todo Add support for route names.
diff --git a/core/modules/search/search.module b/core/modules/search/search.module
index e780087..1ebe99d 100644
--- a/core/modules/search/search.module
+++ b/core/modules/search/search.module
@@ -306,7 +306,7 @@ function search_simplify($text, $langcode = NULL) {
function search_expand_cjk($matches) {
$min = \Drupal::config('search.settings')->get('index.minimum_word_size');
$str = $matches[0];
- $length = drupal_strlen($str);
+ $length = Unicode::strlen($str);
// If the text is shorter than the minimum word size, don't tokenize it.
if ($length <= $min) {
return ' ' . $str . ' ';
@@ -453,7 +453,7 @@ function search_index($sid, $type, $text, $langcode) {
// Add word to accumulator
$accum .= $word . ' ';
// Check wordlength
- if (is_numeric($word) || drupal_strlen($word) >= $minimum_word_size) {
+ if (is_numeric($word) || Unicode::strlen($word) >= $minimum_word_size) {
if (!isset($scored_words[$word])) {
$scored_words[$word] = 0;
}
diff --git a/core/modules/search/src/SearchQuery.php b/core/modules/search/src/SearchQuery.php
index b3e2cac..21c271b 100644
--- a/core/modules/search/src/SearchQuery.php
+++ b/core/modules/search/src/SearchQuery.php
@@ -9,6 +9,7 @@
namespace Drupal\search;
+use Drupal\Component\Utility\Unicode;
use Drupal\Core\Database\Query\SelectExtender;
use Drupal\Core\Database\StatementEmpty;
@@ -367,7 +368,7 @@ class SearchQuery extends SelectExtender {
$split = explode(' ', $word);
foreach ($split as $s) {
$num = is_numeric($s);
- if ($num || drupal_strlen($s) >= \Drupal::config('search.settings')->get('index.minimum_word_size')) {
+ if ($num || Unicode::strlen($s) >= \Drupal::config('search.settings')->get('index.minimum_word_size')) {
if (!isset($this->words[$s])) {
$this->words[$s] = $s;
$num_new_scores++;
diff --git a/core/modules/search/src/Tests/SearchSimplifyTest.php b/core/modules/search/src/Tests/SearchSimplifyTest.php
index 848f7b7..d1c2774 100644
--- a/core/modules/search/src/Tests/SearchSimplifyTest.php
+++ b/core/modules/search/src/Tests/SearchSimplifyTest.php
@@ -39,7 +39,7 @@ class SearchSimplifyTest extends SearchTestBase {
// Split this into 30-character chunks, so we don't run into limits
// of truncation in search_simplify().
$start = 0;
- while ($start < drupal_strlen($string)) {
+ while ($start < Unicode::strlen($string)) {
$newstr = Unicode::substr($string, $start, 30);
// Special case: leading zeros are removed from numeric strings,
// and there's one string in this file that is numbers starting with
@@ -54,7 +54,7 @@ class SearchSimplifyTest extends SearchTestBase {
}
foreach ($strings as $key => $string) {
$simplified = search_simplify($string);
- $this->assertTrue(drupal_strlen($simplified) >= drupal_strlen($string), "Nothing is removed from string $key.");
+ $this->assertTrue(Unicode::strlen($simplified) >= Unicode::strlen($string), "Nothing is removed from string $key.");
}
// Test the low-numbered ASCII control characters separately. They are not
diff --git a/core/modules/system/src/Tests/Mail/HtmlToTextTest.php b/core/modules/system/src/Tests/Mail/HtmlToTextTest.php
index f26b498..57de914 100644
--- a/core/modules/system/src/Tests/Mail/HtmlToTextTest.php
+++ b/core/modules/system/src/Tests/Mail/HtmlToTextTest.php
@@ -352,7 +352,7 @@ class HtmlToTextTest extends WebTestBase {
$maximum_line_length = 0;
foreach (explode($eol, $output) as $line) {
- // We must use strlen() rather than drupal_strlen() in order to count
+ // We must use strlen() rather than Unicode::strlen() in order to count
// octets rather than characters.
$maximum_line_length = max($maximum_line_length, strlen($line . $eol));
}
diff --git a/core/modules/text/text.module b/core/modules/text/text.module
index 0ea98e0..02140fe 100644
--- a/core/modules/text/text.module
+++ b/core/modules/text/text.module
@@ -91,7 +91,7 @@ function text_summary($text, $format = NULL, $size = NULL) {
}
// If we have a short body, the entire body is the summary.
- if (drupal_strlen($text) <= $size) {
+ if (Unicode::strlen($text) <= $size) {
return $text;
}
diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php
index a8f39aa..602f0e7 100644
--- a/core/modules/user/src/AccountForm.php
+++ b/core/modules/user/src/AccountForm.php
@@ -7,6 +7,7 @@
namespace Drupal\user;
+use Drupal\Component\Utility\Unicode;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\Query\QueryFactory;
@@ -379,7 +380,7 @@ abstract class AccountForm extends ContentEntityForm {
// automatic typed data validation in https://drupal.org/node/2227381.
$field_definitions = $this->entityManager->getFieldDefinitions('user', $this->getEntity()->bundle());
$max_length = $field_definitions['signature']->getSetting('max_length');
- if (drupal_strlen($form_state->getValue('signature')) > $max_length) {
+ if (Unicode::strlen($form_state->getValue('signature')) > $max_length) {
$form_state->setErrorByName('signature', $this->t('The signature is too long: it must be %max characters or less.', array('%max' => $max_length)));
}
}
diff --git a/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php b/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php
index 5b788ca..12d4fa3 100644
--- a/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php
+++ b/core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php
@@ -7,6 +7,7 @@
namespace Drupal\user\Plugin\Validation\Constraint;
+use Drupal\Component\Utility\Unicode;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
@@ -48,7 +49,7 @@ class UserNameConstraintValidator extends ConstraintValidator {
) {
$this->context->addViolation($constraint->illegalMessage);
}
- if (drupal_strlen($name) > USERNAME_MAX_LENGTH) {
+ if (Unicode::strlen($name) > USERNAME_MAX_LENGTH) {
$this->context->addViolation($constraint->tooLongMessage, array('%name' => $name, '%max' => USERNAME_MAX_LENGTH));
}
}
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 9c49486..6d3c6f3 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -556,7 +556,7 @@ function template_preprocess_username(&$variables) {
// their own shortening logic or add markup. If they do so, they must ensure
// that $variables['name'] is safe for printing.
$name = $variables['name_raw'] = $account->getUsername();
- if (drupal_strlen($name) > 20) {
+ if (Unicode::strlen($name) > 20) {
$name = Unicode::truncate($name, 15, FALSE, TRUE);
$variables['truncated'] = TRUE;
}
diff --git a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
index eb43726..f13b8db 100644
--- a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
+++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php
@@ -1289,7 +1289,7 @@ abstract class FieldPluginBase extends HandlerBase {
$base_path = base_path();
// Checks whether the path starts with the base_path.
if (strpos($more_link_path, $base_path) === 0) {
- $more_link_path = Unicode::substr($more_link_path, drupal_strlen($base_path));
+ $more_link_path = Unicode::substr($more_link_path, Unicode::strlen($base_path));
}
$more_link = _l($more_link_text, $more_link_path, array('attributes' => array('class' => array('views-more-link'))));
@@ -1705,7 +1705,7 @@ abstract class FieldPluginBase extends HandlerBase {
* The trimmed string.
*/
public static function trimText($alter, $value) {
- if (drupal_strlen($value) > $alter['max_length']) {
+ if (Unicode::strlen($value) > $alter['max_length']) {
$value = Unicode::substr($value, 0, $alter['max_length']);
if (!empty($alter['word_boundary'])) {
$regex = "(.*)\b.+";
diff --git a/core/modules/views/src/Plugin/views/filter/InOperator.php b/core/modules/views/src/Plugin/views/filter/InOperator.php
index 07bdf66..51468afa 100644
--- a/core/modules/views/src/Plugin/views/filter/InOperator.php
+++ b/core/modules/views/src/Plugin/views/filter/InOperator.php
@@ -367,7 +367,7 @@ class InOperator extends FilterPluginBase {
if ($values !== '') {
$values .= ', ';
}
- if (drupal_strlen($values) > 8) {
+ if (Unicode::strlen($values) > 8) {
$values = Unicode::truncate($values, 8, FALSE, TRUE);
break;
}
diff --git a/core/modules/views_ui/views_ui.module b/core/modules/views_ui/views_ui.module
index a6a51e3..7bf6e71 100644
--- a/core/modules/views_ui/views_ui.module
+++ b/core/modules/views_ui/views_ui.module
@@ -327,7 +327,7 @@ function views_ui_views_analyze(ViewExecutable $view) {
* This is often used in the UI to ensure long strings fit.
*/
function views_ui_truncate($string, $length) {
- if (drupal_strlen($string) > $length) {
+ if (Unicode::strlen($string) > $length) {
$string = Unicode::substr($string, 0, $length);
$string .= '...';
}