[wp-trac] [WordPress Trac] #37635: BUG in get_option

WordPress Trac noreply at wordpress.org
Thu Aug 11 08:11:59 UTC 2016


#37635: BUG in get_option
--------------------------+-----------------------------
 Reporter:  tazotodua     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 in wp_options, i had saved this large serialized string:

 http://pastebin.com/raw/hxwETuHX

 however, when i run `get_option("option_name")` it returns false...
 i have spent time and found out, that it's because that get_option tries
 to unserialize it and return the result, but it have problems while
 unserializing.

 then i decided to manually grab the value and unserialize by hand.. and i
 succeeded!

 {{{#!php

 $raw_data=$wpdb->get_var("Select option_value from wp_options Where
 option_name='option_name'");

 unserialize(Serialized_Fixer($raw_data));


 function Serialized_Fixer($serialized_string){
     // securities
     if ( !preg_match('/^[aOs]:/', $serialized_string) ) return
 $serialized_string;
     if ( @unserialize($serialized_string) !== false ) return
 $serialized_string;

         return
         preg_replace_callback(
                 '/s\:(\d+)\:\"(.*?)\";/s',
                 function ($matches){    return
 's:'.strlen($matches[2]).':"'.$matches[2].'";';  },
                 $serialized_string )
         ;
 }
 }}}


 and that worked!
 this is seriously a bug of WP!
 please fix it! thanks!

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37635>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list