Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
12ba160d
Commit
12ba160d
authored
Nov 05, 2014
by
alexpott
Browse files
Issue
#2361797
by rpayanm, Palashvijay4O, er.pushpinderrana: Remove usage of drupal_strlen().
parent
55286952
Changes
19
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Mail/MailFormatHelper.php
View file @
12ba160d
...
...
@@ -9,6 +9,7 @@
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 @@ public static function htmlToText($string, $allowed_tags = NULL) {
// 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
;
}
}
...
...
core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php
View file @
12ba160d
...
...
@@ -99,7 +99,7 @@ public function getString() {
$strings
[]
=
$item
->
getString
();
}
// Remove any empty strings resulting from empty items.
return
implode
(
', '
,
array_filter
(
$strings
,
'
d
rupal
_
strlen'
));
return
implode
(
', '
,
array_filter
(
$strings
,
'
\D
rupal
\Component\Utility\Unicode::
strlen'
));
}
}
...
...
core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php
View file @
12ba160d
...
...
@@ -115,7 +115,7 @@ public function getString() {
$strings
[]
=
$property
->
getString
();
}
// Remove any empty strings resulting from empty items.
return
implode
(
', '
,
array_filter
(
$strings
,
'
d
rupal
_
strlen'
));
return
implode
(
', '
,
array_filter
(
$strings
,
'
\D
rupal
\Component\Utility\Unicode::
strlen'
));
}
/**
...
...
core/modules/filter/filter.module
View file @
12ba160d
...
...
@@ -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
.
'/'
;
...
...
core/modules/image/image.field.inc
View file @
12ba160d
...
...
@@ -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
;
}
...
...
core/modules/menu_ui/src/Tests/MenuTest.php
View file @
12ba160d
...
...
@@ -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 @@ function addCustomMenu() {
$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 @@ function addCustomMenu() {
$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
)));
...
...
core/modules/options/src/Plugin/Field/FieldType/ListStringItem.php
View file @
12ba160d
...
...
@@ -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 @@ protected function allowedValuesDescription() {
* {@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.'
);
}
}
...
...
core/modules/responsive_image/responsive_image.module
View file @
12ba160d
...
...
@@ -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.
...
...
core/modules/search/search.module
View file @
12ba160d
...
...
@@ -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
;
}
...
...
core/modules/search/src/SearchQuery.php
View file @
12ba160d
...
...
@@ -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 @@ protected function parseWord($word) {
$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
++
;
...
...
core/modules/search/src/Tests/SearchSimplifyTest.php
View file @
12ba160d
...
...
@@ -39,7 +39,7 @@ function testSearchSimplifyUnicode() {
// 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 @@ function testSearchSimplifyUnicode() {
}
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
...
...
core/modules/system/src/Tests/Mail/HtmlToTextTest.php
View file @
12ba160d
...
...
@@ -352,7 +352,7 @@ public function testVeryLongLineWrap() {
$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
));
}
...
...
core/modules/text/text.module
View file @
12ba160d
...
...
@@ -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
;
}
...
...
core/modules/user/src/AccountForm.php
View file @
12ba160d
...
...
@@ -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 @@ public function validate(array $form, FormStateInterface $form_state) {
// 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
)));
}
}
...
...
core/modules/user/src/Plugin/Validation/Constraint/UserNameConstraintValidator.php
View file @
12ba160d
...
...
@@ -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 @@ public function validate($items, Constraint $constraint) {
)
{
$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
));
}
}
...
...
core/modules/user/user.module
View file @
12ba160d
...
...
@@ -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
;
}
...
...
core/modules/views/src/Plugin/views/field/FieldPluginBase.php
View file @
12ba160d
...
...
@@ -1289,7 +1289,7 @@ public function renderText($alter) {
$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 @@ public function adminLabel($short = FALSE) {
* 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.+"
;
...
...
core/modules/views/src/Plugin/views/filter/InOperator.php
View file @
12ba160d
...
...
@@ -367,7 +367,7 @@ public function adminSummary() {
if
(
$values
!==
''
)
{
$values
.
=
', '
;
}
if
(
drupal_
strlen
(
$values
)
>
8
)
{
if
(
Unicode
::
strlen
(
$values
)
>
8
)
{
$values
=
Unicode
::
truncate
(
$values
,
8
,
FALSE
,
TRUE
);
break
;
}
...
...
core/modules/views_ui/views_ui.module
View file @
12ba160d
...
...
@@ -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
.
=
'...'
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment