diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 6c5184f697..8a91d152bf 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -582,18 +582,44 @@ function get_weekstartend( $mysqlstring, $start_of_week = '' ) { } /** - * Unserialize value only if it was serialized. + * Serialize data, if needed. + * + * @since 2.0.5 + * + * @param string|array|object $data Data that might be serialized. + * @return mixed A scalar data. + */ +function maybe_serialize( $data ) { + if ( is_array( $data ) || is_object( $data ) ) { + return serialize( $data ); + } + + /* + * Double serialization is required for backward compatibility. + * See https://core.trac.wordpress.org/ticket/12930 + * Also the world will end. See WP 3.6.1. + */ + if ( is_serialized( $data, false ) ) { + return serialize( $data ); + } + + return $data; +} + +/** + * Unserialize data only if it was serialized. * * @since 2.0.0 * - * @param string $original Maybe unserialized original, if is needed. + * @param string $data Data that might be unserialized. * @return mixed Unserialized data can be any type. */ -function maybe_unserialize( $original ) { - if ( is_serialized( $original ) ) { // Don't attempt to unserialize data that wasn't serialized going in. - return @unserialize( $original ); +function maybe_unserialize( $data ) { + if ( is_serialized( $data ) ) { // Don't attempt to unserialize data that wasn't serialized going in. + return @unserialize( $data ); } - return $original; + + return $data; } /** @@ -695,31 +721,6 @@ function is_serialized_string( $data ) { } } -/** - * Serialize data, if needed. - * - * @since 2.0.5 - * - * @param string|array|object $data Data that might be serialized. - * @return mixed A scalar data - */ -function maybe_serialize( $data ) { - if ( is_array( $data ) || is_object( $data ) ) { - return serialize( $data ); - } - - /* - * Double serialization is required for backward compatibility. - * See https://core.trac.wordpress.org/ticket/12930 - * Also the world will end. See WP 3.6.1. - */ - if ( is_serialized( $data, false ) ) { - return serialize( $data ); - } - - return $data; -} - /** * Retrieve post title from XMLRPC XML. *