Support » How-To and Troubleshooting » maybe_serialize( ) – a question about the code

maybe_serialize( ) – a question about the code

  • DrLightman


    Inside functions.php :

    function maybe_serialize( $data ) {
        if ( is_array( $data ) || is_object( $data ) )
            return serialize( $data );
        if ( is_serialized( $data ) )
            return serialize( $data );
        return $data;

    From the description:

    Serialize data, if needed

    So why these lines:

    if ( is_serialized( $data ) )
            return serialize( $data );

    Is it a double serialization, isn’t it? Or am I missing anything?

    Found this in MU 2.9.2 but WP 3.0.1 has also.

Viewing 1 replies (of 1 total)
  • Fvieville


    I think it is a double serialization.

    Does somebody know when it will be corrected ? (if it will be)

    This double serialization disturbs me. I’d like to import an already serialized value in a custom field and this double serialization avoid me to do it.

    Does somebody know if it is dangerous to replace :
    if( is_serialized( $data )
    if( !is_serialized( $data )

    Does the development team know about this double serialization ?

    Thanks for helping


Viewing 1 replies (of 1 total)
  • The topic ‘maybe_serialize( ) – a question about the code’ is closed to new replies.