WordPress.org

Make WordPress Core

Ticket #7383: 7383.diff

File 7383.diff, 933 bytes (added by DD32, 10 years ago)
  • wp-includes/functions.php

     
    627641 * Serialize data, if needed.
    628642 *
    629643 * @param mixed $data Data that might be serialized.
    630  * @return mixed A scalar data
     644 * @return string Serialized data or a string if input was a non-serialized string
    631645 */
    632646function maybe_serialize( $data ) {
    633         if ( is_array( $data ) || is_object( $data ) )
    634                 return serialize( $data );
    635647
    636         if ( is_serialized( $data ) )
     648        if ( is_serialized( $data ) ) //In case a plugin has passed serialized data to update/add_option
    637649                return serialize( $data );
     650       
     651        if ( is_string( $data ) ) //Strings do not need to be serialized
     652                return $data;
    638653
    639         return $data;
     654        return serialize( $data ); //Arrays, Objects, Integers, and Classes need to be serialized.
    640655}
    641656
    642657