[wp-trac] [WordPress Trac] #21109: maybe_unserialized fails to unserialize multibyte strings (contains solution)

WordPress Trac noreply at wordpress.org
Fri Dec 7 12:34:37 UTC 2012


#21109: maybe_unserialized fails to unserialize multibyte strings (contains
solution)
------------------------------------+------------------------------
 Reporter:  veedeezee               |       Owner:
     Type:  defect (bug)            |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  General                 |     Version:  3.4
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |
------------------------------------+------------------------------

Comment (by dReiska):

 This bug seems to be affecting Options API too. Database charset and table
 charset are both UTF-8. Tested with version 3.4.2.

 Code to reproduce:
 {{{
 $a = array('test' => 'Jotain tähän');
 update_option('test-test-test', $a);
 var_dump($a, get_option('test-test-test'));
 // Outputs: array(1) { ["test"]=> string(14) "Jotain tähän" } array(1) {
 ["test"]=> string(14) "Jotain tähän" } string(39)
 "a:1:{s:4:"test";s:14:"Jotain tähän";}"
 }}}
 and then remove update & run the code again to retrieve value from DB:
 {{{
 $a = array('test' => 'Jotain tähän');
 var_dump($a, get_option('test-test-test'));
 // Outputs: array(1) { ["test"]=> string(14) "Jotain tähän" } string(39)
 "a:1:{s:4:"test";s:14:"Jotain tähän";}"
 }}}
 Instead of an array, string of serialized array is returned. With non-
 UTF-8 characters this works very well, e.g. if the value of "test" is "Foo
 bar".

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


More information about the wp-trac mailing list