[wp-trac] [WordPress Trac] #23381: update_option() stores unserialized value in object cache

WordPress Trac noreply at wordpress.org
Fri Feb 22 07:05:12 UTC 2013


#23381: update_option() stores unserialized value in object cache
--------------------------+--------------------
 Reporter:  rmccue        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  3.6
Component:  Cache         |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |
--------------------------+--------------------
Changes (by hexalys):

 * version:  3.1 => trunk


Comment:

 Replying to [comment:5 SergeyBiryukov]:
 > The IRC chat log relevant to comment:3: [[BR]]
 > https://irclogs.wordpress.org/chanlog.php?channel=wordpress-
 dev&day=2013-02-04&sort=asc#m547662
 Thanks Sergey, I see it's more of a 'off the top of my head' thought than
 a rationale...

 What am trying to say here is that the options cache storage needs to be
 consistent. As for rboren's pointless serialization remark: For
 update_option() and add_option(), serialize() has to run anyway for the db
 query so there are no performance caveats there.

 I shall point to the more pointless unserialization with get_option()
 which has no process to copy its unserialized value to the
 $wp_object_cache->cache, on first unserialization...  Which means that
 with the basic wp object cache, get_option() has to run
 maybe_unserialize() and unserialize() for every other calls to the same
 serialized option, making get_option() quite redundant there.

 The "caching by groups" concept (e.g. alloptions) with the current
 implmentation of get_option() have unavoidable unserialization waste, one
 a way or another. And even with memory cache, because wp_load_alloptions()
 loads early, you cannot not store objects in the 'alloptions' groups for
 any plugins, if the cached options are stored as objects (or arrays of
 object), due the classes being no yet loaded. Having them serialized
 allows for just-in-time unserialization for plugins.

 It's not perfect but the current model is to store everything as
 serialized, not making them Arrays or Object ONLY on update_option() or
 add_option(), in a very inconsistent way like that.

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


More information about the wp-trac mailing list