get_option unserialization fail
-
I have been using this plugin on a few websites already and all was working fine until I have moved one of them to another server. On new server custom post types registered with plugin has not showed up and were not registered. After some debugging I found out that for some reason serialized string, which is stored in database (‘cpt_custom_post_types’), is retrieved to plugin function cpt_create_custom_taxonomies() unserialized, as string, but then you check it to be array:
//check if option value is an array before proceeding if ( is_array( $cpt_tax_types ) ) {
I have checked the string, its totally valid and unserialize() processing it without trouble, so must be under some conditions get_option fails to identify if it’s serialized. It’s not your bug, but considering how much support threads I see with disappearing post types and taxonomies, maybe you should counter this by checking the value received from get_option to be unserialized string:
if(!is_array($cpt_post_types)){ $test_serialize=unserialize($cpt_post_types); if($test_serialize){ $cpt_post_types=$test_serialize; } }
After I have set such check after every get_option call, plugin has fully restored its functionality. So this may be one of the reasons custom post types or taxonomies not working.
- The topic ‘get_option unserialization fail’ is closed to new replies.