Make WordPress Core

Changeset 28808


Ignore:
Timestamp:
06/23/2014 10:20:23 PM (10 years ago)
Author:
SergeyBiryukov
Message:

Remove mbstring_binary_safe_strlen(). Use mbstring_binary_safe_encoding() and reset_mbstring_encoding() directly.

fixes #28162.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/image.php

    r28806 r28808  
    290290                $caption = trim( $iptc['2#120'][0] );
    291291                if ( empty( $meta['title'] ) ) {
     292                    mbstring_binary_safe_encoding();
     293                    $caption_length = strlen( $caption );
     294                    reset_mbstring_encoding();
     295
    292296                    // Assume the title is stored in 2:120 if it's short.
    293                     if ( mbstring_binary_safe_strlen( $caption ) < 80 )
     297                    if ( $caption_length < 80 ) {
    294298                        $meta['title'] = $caption;
    295                     else
     299                    } else {
    296300                        $meta['caption'] = $caption;
     301                    }
    297302                } elseif ( $caption != $meta['title'] ) {
    298303                    $meta['caption'] = $caption;
     
    328333
    329334        if ( ! empty( $exif['ImageDescription'] ) ) {
    330             if ( empty( $meta['title'] ) && mbstring_binary_safe_strlen( $exif['ImageDescription'] ) < 80 ) {
     335            mbstring_binary_safe_encoding();
     336            $description_length = strlen( $exif['ImageDescription'] );
     337            reset_mbstring_encoding();
     338
     339            if ( empty( $meta['title'] ) && $description_length < 80 ) {
    331340                // Assume the title is stored in ImageDescription
    332341                $meta['title'] = trim( $exif['ImageDescription'] );
  • trunk/src/wp-includes/formatting.php

    r28806 r28808  
    482482 */
    483483function seems_utf8($str) {
    484     $length = mbstring_binary_safe_strlen($str);
     484    mbstring_binary_safe_encoding();
     485    $length = strlen($str);
     486    reset_mbstring_encoding();
    485487    for ($i=0; $i < $length; $i++) {
    486488        $c = ord($str[$i]);
     
    706708    $unicode_length = 0;
    707709
    708     $string_length = mbstring_binary_safe_strlen( $utf8_string );
     710    mbstring_binary_safe_encoding();
     711    $string_length = strlen( $utf8_string );
     712    reset_mbstring_encoding();
     713
    709714    for ($i = 0; $i < $string_length; $i++ ) {
    710715
  • trunk/src/wp-includes/functions.php

    r28806 r28808  
    44064406
    44074407/**
    4408  * Uses a binary-safe encoding to get the length of a string in bytes if func_overload is enabled.
    4409  *
    4410  * @see mbstring_binary_safe_encoding()
    4411  *
    4412  * @since 4.0.0
    4413  *
    4414  * @param string $string The string to get the length of.
    4415  * @return int The length of the string in bytes.
    4416  */
    4417 function mbstring_binary_safe_strlen( $string ) {
    4418     mbstring_binary_safe_encoding();
    4419     $length = strlen( $string );
    4420     reset_mbstring_encoding();
    4421 
    4422     return $length;
    4423 }
    4424 
    4425 /**
    44264408 * Alternative to filter_var( $var, FILTER_VALIDATE_BOOLEAN )
    44274409 *
Note: See TracChangeset for help on using the changeset viewer.