WordPress.org

Make WordPress Core

Changeset 8421


Ignore:
Timestamp:
07/23/08 18:56:42 (7 years ago)
Author:
ryan
Message:

Work around fatal error caused by mbstring.func_overload = 2. Props codestyling . fixes #5599 for 2.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/wp-includes/streams.php

    r8117 r8421  
    5959    $this->_str = $str; 
    6060    $this->_pos = 0; 
     61    // If string functions are overloaded, we need to use the mb versions 
     62    $this->is_overloaded = ((ini_get("mbstring.func_overload") & 2) != 0) && function_exists('mb_substr'); 
     63  } 
     64 
     65  function _substr($string, $start, $length) { 
     66    if ($this->is_overloaded) { 
     67        return mb_substr($string,$start,$length,'ascii'); 
     68    } else { 
     69        return substr($string,$start,$length); 
     70    } 
     71  } 
     72 
     73  function _strlen($string) { 
     74    if ($this->is_overloaded) { 
     75        return mb_strlen($string,'ascii'); 
     76    } else { 
     77        return strlen($string); 
     78    } 
    6179  } 
    6280 
    6381  function read($bytes) { 
    64     $data = substr($this->_str, $this->_pos, $bytes); 
     82      $data = $this->_substr($this->_str, $this->_pos, $bytes); 
    6583    $this->_pos += $bytes; 
    66     if (strlen($this->_str)<$this->_pos) 
    67       $this->_pos = strlen($this->_str); 
     84    if ($this->_strlen($this->_str)<$this->_pos) 
     85      $this->_pos = $this->_strlen($this->_str); 
    6886 
    6987    return $data; 
     
    7290  function seekto($pos) { 
    7391    $this->_pos = $pos; 
    74     if (strlen($this->_str)<$this->_pos) 
    75       $this->_pos = strlen($this->_str); 
     92    if ($this->_strlen($this->_str)<$this->_pos) 
     93      $this->_pos = $this->_strlen($this->_str); 
    7694    return $this->_pos; 
    7795  } 
     
    82100 
    83101  function length() { 
    84     return strlen($this->_str); 
     102    return $this->_strlen($this->_str); 
    85103  } 
    86  
    87104} 
    88105 
     
    150167class CachedFileReader extends StringReader { 
    151168  function CachedFileReader($filename) { 
     169    parent::StringReader(); 
     170 
    152171    if (file_exists($filename)) { 
    153172 
     
    156175 
    157176      if (!$fd) { 
    158     $this->error = 3; // Cannot read file, probably permissions 
    159     return false; 
     177        $this->error = 3; // Cannot read file, probably permissions 
     178        return false; 
    160179      } 
    161180      $this->_str = fread($fd, $length); 
    162       $this->_pos = 0; 
    163181      fclose($fd); 
    164182 
Note: See TracChangeset for help on using the changeset viewer.