diff --git a/includes/class-plugin.php b/includes/class-plugin.php index 27b21042..0d02bbc2 100644 --- a/includes/class-plugin.php +++ b/includes/class-plugin.php @@ -80,6 +80,7 @@ private function __construct() { $this->screen = 'settings_page_redis-cache'; } + $this->run_migrations(); $this->add_actions_and_filters(); if ( is_admin() && ! wp_next_scheduled( 'rediscache_discard_metrics' ) ) { @@ -87,6 +88,18 @@ private function __construct() { } } + /** + * Run migrations + * + * @return void + */ + public function run_migrations() { + if ( WP_REDIS_VERSION === '2.0.16' && ! get_option( 'roc_migrated_2_0_16' ) ) { + wp_flush_cache(); + update_option( 'roc_migrated_2_0_16', true, true ); + } + } + /** * Adds all necessary hooks * diff --git a/includes/object-cache.php b/includes/object-cache.php index f8e2804b..627664d5 100644 --- a/includes/object-cache.php +++ b/includes/object-cache.php @@ -1976,7 +1976,7 @@ protected function maybe_unserialize( $original ) { return igbinary_unserialize( $original ); } - // Don't attempt to unserialize data that wasn't serialized going in. + // Unserialize data that was serialized if ( $this->is_serialized( $original ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize $value = @unserialize( $original ); @@ -2006,17 +2006,13 @@ protected function maybe_serialize( $data ) { return igbinary_serialize( $data ); } - if ( is_array( $data ) || is_object( $data ) ) { - // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize - return serialize( $data ); - } - + // Don't serialize data that's already serialized if ( $this->is_serialized( $data, false ) ) { - // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize - return serialize( $data ); + return $data; } - return $data; + // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize + return serialize( $data ); } /** @@ -2073,6 +2069,7 @@ protected function is_serialized( $data, $strict = true ) { return false; } } + $token = $data[0]; switch ( $token ) {