final touches on migration

This commit is contained in:
Peter Molnar 2013-03-22 10:36:42 +00:00
parent e6ad0029f3
commit fba2f85699
2 changed files with 34 additions and 14 deletions

View file

@ -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 Tags: cache, memcached, full page cache, NGiNX, memcache, page cache
Requires at least: 3.0 Requires at least: 3.0
Tested up to: 3.5.1 Tested up to: 3.5.1
Stable tag: 0.6.1 Stable tag: 1.0
License: GPLv3 License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html 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 1. settings screen, cache type and basic settings
2. debug and in depth-options 2. debug and in depth-options
3. cache exceptions 3. cache exceptions
4. apc settings 4. memcached servers settings
5. memcached servers settings 5. NGiNX example
6. NGiNX example
== Changelog == == Changelog ==
@ -78,9 +77,8 @@ You have to remove the default yum package, named `php-pecl-memcache` and instal
* APC entry compression support * 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 * optional NGiNX header preservation for shortlink, pingback and last-modified headers
= 0.6.1 = = 0.6.1 =
@ -208,7 +206,7 @@ Please post feature requests to [WP-FFPC feature request topic](http://wordpress
= Contribution = = 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. 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 * WordPress >= 3.0
and **at least one** of the following for storage backend: and **at least one** of the following for storage backend:

View file

@ -524,6 +524,7 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
* *
*/ */
public function plugin_hook_options_migrate( &$options ) { public function plugin_hook_options_migrate( &$options ) {
$migrated = false;
if ( $options['version'] != $this->plugin_version || !isset ( $options['version'] ) ) { if ( $options['version'] != $this->plugin_version || !isset ( $options['version'] ) ) {
@ -535,25 +536,46 @@ if ( ! class_exists( 'WP_FFPC' ) ) {
unlink ( $fname ); 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'] ) ) { if ( !empty ( $options['host'] ) ) {
$options['hosts'] = $options['host'] . ':' . $options['port']; $options['hosts'] = $options['host'] . ':' . $options['port'];
/* renamed options */ $migrated = true;
$options['log'] = $options['syslog'];
$options['response_header'] = $options['debug'];
} }
/* migrating from version 0.6.x */ /* migrating from version 0.6.x */
elseif ( is_array ( $options ) && array_key_exists ( $this->global_config_key , $options ) ) { elseif ( is_array ( $options ) && array_key_exists ( $this->global_config_key , $options ) ) {
$options = $options[ $this->global_config_key ]; $options = $options[ $this->global_config_key ];
/* renamed options */ $migrated = true;
$options['log'] = $options['syslog'];
$options['response_header'] = $options['debug'];
} }
/* migrating from something, drop previous config */ /* migrating from something, drop previous config */
else { else {
$options = array(); $options = array();
} }
if ( $migrated ) {
/* renamed options */
if ( isset ( $options['syslog'] ) )
$options['log'] = $options['syslog'];
if ( isset ( $options['debug'] ) )
$options['response_header'] = $options['debug'];
}
} }
} }