[wp-trac] [WordPress Trac] #26521: maybe_unserialize() don't need to use is_serialized()

WordPress Trac noreply at wordpress.org
Tue Dec 10 16:06:14 UTC 2013


#26521: maybe_unserialize() don't need to use is_serialized()
-------------------------+-----------------------------
 Reporter:  kkarpieszuk  |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Performance  |    Version:  trunk
 Severity:  normal       |   Keywords:
-------------------------+-----------------------------
 Hi, this is my first submission to Trac, so I hope I will fo everything
 well ;)

 I am profiling (with xdebug) our plugin (WPML) for performance bottlenecks
 and I stumbled onto some small issue in WordPress core.

 I see that wp-includes/functions.php::maybe_unserialize() could be written
 to work faster. It doesn't actually need to run is_serialized(), because
 PHP checks this in PHP::unserialize().

 My proposition of this function (added also as attachment):


 {{{
 function maybe_unserialize( $original ) {
     $unserialized = @unserialize($original);
     return $unserialized ? $unserialized : $original;
 }
 }}}

 And now profiling tests on some site (tested on few others, number of
 course were different but relation is quite the same):

 Original function:

 function maybe_unserialize() was called 1776 times. It took '''0.087393'''
 second, self: 0.023378 s.


 My function:

 function maybe_unserialize() was called 1776 times. It took '''0.031895'''
 second, self: 0.020972 s.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/26521>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list