WordPress.org

Make WordPress Core

Ticket #14429: 14429-strpbrk.2.patch

File 14429-strpbrk.2.patch, 907 bytes (added by hakre, 4 years ago)

Based on [15636], as previous but caches function_exists (as this is for performance)

  • wp-includes/functions.php

     
    228228 * @return bool False if not serialized and true if it was. 
    229229 */ 
    230230function is_serialized( $data ) { 
     231        static $strpbrk_exists; 
    231232        // if it isn't a string, it isn't serialized 
    232233        if ( !is_string( $data ) ) 
    233234                return false; 
    234235        $data = trim( $data ); 
    235236        if ( 'N;' == $data ) 
    236237                return true; 
    237         if ( function_exists('strpbrk') ) { 
    238                 if ( strlen($data) > 1 && strpbrk($data,'adObis') == $data && $data[1] == ':' ) { 
    239                         $badions = array(); 
     238        isset( $strpbrk_exists ) || $strpbrk_exists = function_exists( 'strpbrk' ); 
     239        if ( $strpbrk_exists ) { 
     240                if ( strlen( $data ) > 3 && strpbrk( $data, 'adObis' ) === $data && ':' === $data[1] ) { 
    240241                        $badions[1] = $data[0]; 
    241242                } else { 
    242243                        return false;