Changeset 47453
- Timestamp:
- 03/13/2020 09:05:02 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r47430 r47453 583 583 584 584 /** 585 * Unserialize value only if it was serialized. 585 * Serialize data, if needed. 586 * 587 * @since 2.0.5 588 * 589 * @param string|array|object $data Data that might be serialized. 590 * @return mixed A scalar data. 591 */ 592 function maybe_serialize( $data ) { 593 if ( is_array( $data ) || is_object( $data ) ) { 594 return serialize( $data ); 595 } 596 597 /* 598 * Double serialization is required for backward compatibility. 599 * See https://core.trac.wordpress.org/ticket/12930 600 * Also the world will end. See WP 3.6.1. 601 */ 602 if ( is_serialized( $data, false ) ) { 603 return serialize( $data ); 604 } 605 606 return $data; 607 } 608 609 /** 610 * Unserialize data only if it was serialized. 586 611 * 587 612 * @since 2.0.0 588 613 * 589 * @param string $ original Maybe unserialized original, if is needed.614 * @param string $data Data that might be unserialized. 590 615 * @return mixed Unserialized data can be any type. 591 616 */ 592 function maybe_unserialize( $original ) { 593 if ( is_serialized( $original ) ) { // Don't attempt to unserialize data that wasn't serialized going in. 594 return @unserialize( $original ); 595 } 596 return $original; 617 function maybe_unserialize( $data ) { 618 if ( is_serialized( $data ) ) { // Don't attempt to unserialize data that wasn't serialized going in. 619 return @unserialize( $data ); 620 } 621 622 return $data; 597 623 } 598 624 … … 694 720 return true; 695 721 } 696 }697 698 /**699 * Serialize data, if needed.700 *701 * @since 2.0.5702 *703 * @param string|array|object $data Data that might be serialized.704 * @return mixed A scalar data705 */706 function maybe_serialize( $data ) {707 if ( is_array( $data ) || is_object( $data ) ) {708 return serialize( $data );709 }710 711 /*712 * Double serialization is required for backward compatibility.713 * See https://core.trac.wordpress.org/ticket/12930714 * Also the world will end. See WP 3.6.1.715 */716 if ( is_serialized( $data, false ) ) {717 return serialize( $data );718 }719 720 return $data;721 722 } 722 723
Note: See TracChangeset
for help on using the changeset viewer.