[wp-trac] [WordPress Trac] #25259: Helper functions for mbstring.func_overload

WordPress Trac noreply at wordpress.org
Thu Sep 12 00:33:32 UTC 2013


#25259: Helper functions for mbstring.func_overload
--------------------------+-----------------------
 Reporter:  dd32          |       Owner:  dd32
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:  3.7
Component:  General       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+-----------------------

Comment (by dd32):

 > Would it make sense to have a function specifically for strlen() that
 does the switch, the measurement, and the restoration?

 I considered that, but, certain parts of the code use a bunch of other
 things, and I'd rather be consistent rather than using 2 different work
 arounds.

 `class-ftp.php` & `class-pclzip.php` for example needs
 `ereg_replace/strlen/substr/strstr/stristr` and a few others, as they're
 all operating on binary data, so a full switch needs to take place to
 remain compatible there.

 For things like `WP_HTTP`, `strlen` and `substr` are only needed (at
 present), and aside from the `ftpsockets``WP_Filesystem` transport, the
 rest only really need `strlen` at present.

 For those cases, we could do a compat function that looks something like:
 {{{
 function wp_strlen( $string ) {
   return function_exists( 'mb_strlen' ) ? mb_strlen( $string, 'ascii' ) :
 strlen( $string );
 }
 function wp_substr( $string, $start, $length ) {
   return function_exists( 'mb_substr' ) ? mb_substr( $string, $start,
 $length, 'ascii' ) : substr( $string, $start, $length );
 }
 }}}

 With the commit as-is, On most hosts these helpers will do absolutely
 nothing, it'll just be an extra function call, with a `if ( static var is
 false ) return`, on the rest of the hosts who have this stupid setting
 enabled, it'll use the fix we've been using for a while elsewhere..

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25259#comment:9>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list