[wp-trac] [WordPress Trac] #18410: WP_Query should unserialize serialized data before matching

WordPress Trac wp-trac at lists.automattic.com
Mon Aug 15 12:17:50 UTC 2011


#18410: WP_Query should unserialize serialized data before matching
-------------------------+----------------------
 Reporter:  Doggie52     |       Owner:
     Type:  enhancement  |      Status:  closed
 Priority:  normal       |   Milestone:
Component:  Query        |     Version:  3.2.1
 Severity:  normal       |  Resolution:  wontfix
 Keywords:               |
-------------------------+----------------------

Comment (by dd32):

 > ou mention storing them under one key - that would still make it an
 array (albeit one with only one entry) and would still cause it to become
 serialized, right?

 Almost, Metakeys are not unique. For example, You can store multiple meta
 items, eg:
 {{{
 Post ID MetaName  MetaValue
   1       test     value1
   1       test     value2
   1       test     value3
 }}}

 calling get_post_meta(1, 'test') would then return  array(value1, value2,
 value3).

 > I was rather thinking of checking if the input is an array, if the DB
 entry is serialized and only if both are, unserializing the DB entry for
 matching.

 Take a step back, The querying/matching is done within the Database, ie.
 within the SQL. SQL doesnt understand PHP's serialized format, therefor,
 all SQL see's is a long string..
 In order to do what you're suggesting, It would require loading ALL meta
 keys into memory, unserializing them (well, some of them), and then
 implementing a Database-style comparison function in-WordPresss.. It's
 reinventing the wheel.

 It may be that you're using the wrong storage mechanism, You might for
 example, be better off storing it in a Taxonomy to allow easier querying..

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


More information about the wp-trac mailing list