From fba2f85699b603fd592379b7d10295f184a1f94b Mon Sep 17 00:00:00 2001 From: Peter Molnar Date: Fri, 22 Mar 2013 10:36:42 +0000 Subject: [PATCH] final touches on migration --- readme.txt | 12 +++++------- wp-ffpc-class.php | 36 +++++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/readme.txt b/readme.txt index 180e95c..bdaf321 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i Tags: cache, memcached, full page cache, NGiNX, memcache, page cache Requires at least: 3.0 Tested up to: 3.5.1 -Stable tag: 0.6.1 +Stable tag: 1.0 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -49,9 +49,8 @@ You have to remove the default yum package, named `php-pecl-memcache` and instal 1. settings screen, cache type and basic settings 2. debug and in depth-options 3. cache exceptions -4. apc settings -5. memcached servers settings -6. NGiNX example +4. memcached servers settings +5. NGiNX example == Changelog == @@ -78,9 +77,8 @@ You have to remove the default yum package, named `php-pecl-memcache` and instal * APC entry compression support -**Planned features for next major release** +**Planned features** -* support for Redis backend * optional NGiNX header preservation for shortlink, pingback and last-modified headers = 0.6.1 = @@ -208,7 +206,7 @@ Please post feature requests to [WP-FFPC feature request topic](http://wordpress = Contribution = In order to make contributions a lot easier, I've moved the plugin development to [GitHub](https://github.com/petermolnar/wp-ffpc "GitHub"), feel free to fork and put shiny, new things in it. -== Requirements == += Requirements = * WordPress >= 3.0 and **at least one** of the following for storage backend: diff --git a/wp-ffpc-class.php b/wp-ffpc-class.php index a5142b5..945d54e 100644 --- a/wp-ffpc-class.php +++ b/wp-ffpc-class.php @@ -524,6 +524,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) { * */ public function plugin_hook_options_migrate( &$options ) { + $migrated = false; if ( $options['version'] != $this->plugin_version || !isset ( $options['version'] ) ) { @@ -535,25 +536,46 @@ if ( ! class_exists( 'WP_FFPC' ) ) { unlink ( $fname ); } - /* updating from version 0.4.x */ + /* look for previous config leftovers */ + $try = get_site_option( $this->plugin_constant ); + /* network option key changed, remove & migrate the leftovers if there's any */ + if ( !empty ( $try ) && $this->network ) { + /* clean it up, we don't use it anymore */ + delete_site_option ( $this->plugin_constant ); + + if ( empty ( $options ) && array_key_exists ( $this->global_config_key, $try ) ) { + $options = $try [ $this->global_config_key ]; + $migrated = true; + } + elseif ( empty ( $options ) && array_key_exists ( 'host', $try ) ) { + $options = $try; + $migrated = true; + } + } + + /* updating from version <= 0.4.x */ if ( !empty ( $options['host'] ) ) { $options['hosts'] = $options['host'] . ':' . $options['port']; - /* renamed options */ - $options['log'] = $options['syslog']; - $options['response_header'] = $options['debug']; + $migrated = true; } /* migrating from version 0.6.x */ elseif ( is_array ( $options ) && array_key_exists ( $this->global_config_key , $options ) ) { $options = $options[ $this->global_config_key ]; - /* renamed options */ - $options['log'] = $options['syslog']; - $options['response_header'] = $options['debug']; + $migrated = true; } /* migrating from something, drop previous config */ else { $options = array(); } + if ( $migrated ) { + /* renamed options */ + if ( isset ( $options['syslog'] ) ) + $options['log'] = $options['syslog']; + if ( isset ( $options['debug'] ) ) + $options['response_header'] = $options['debug']; + } + } }