maybe_serialize( ) - a question about the code (2 posts)

  1. DrLightman
    Posted 5 years ago #

    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.

  2. Fvieville
    Posted 4 years ago #

    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


Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.