From 2b2345c763ec6913aa56f2d1b89496f34a662a09 Mon Sep 17 00:00:00 2001 From: Peter Molnar Date: Fri, 22 Aug 2014 11:55:25 +0100 Subject: [PATCH] version 1.6.0, see changelog --- readme.txt | 35 ++++++++++++++--- wp-common | 2 +- wp-ffpc-acache.php | 12 +++++- wp-ffpc-backend.php | 12 +++++- wp-ffpc-class.php | 93 ++++++++++++++++++++++++++++----------------- wp-ffpc.php | 8 ++-- 6 files changed, 115 insertions(+), 47 deletions(-) diff --git a/readme.txt b/readme.txt index d292c93..ffa8f50 100644 --- a/readme.txt +++ b/readme.txt @@ -3,8 +3,8 @@ Contributors: cadeyrn Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XU3DG7LLA76WC Tags: cache, page cache, full page cache, nginx, memcached, apc, speed Requires at least: 3.0 -Tested up to: 3.9.1 -Stable tag: 1.5.0 +Tested up to: 4.0 +Stable tag: 1.6.0 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -17,14 +17,14 @@ It can be configured to join forces with [NGiNX](http://NGiNX.org "NGiNX")'s bui = Features: = * Wordpress Network support * fully supported domain/subdomain based WordPress Networks on per site setup as well - * will work in Network Enabled mode only for subdirectory based Multisites ( no per site setting possibility ) -* supports variable backends + * will work in Network Enabled mode only for subdirectory based Multisites ( per site settings will not work in this case ) +* supports various backends * memcached with [PHP Memcached](http://php.net/manual/en/book.memcached.php "Memcached") * memcached with [PHP Memcache](http://php.net/manual/en/book.memcache.php "Memcache") * [APC](http://php.net/manual/en/book.apc.php "APC") * [APCu](http://pecl.php.net/package/APCu "APC User Cache") * [Xcache](http://xcache.lighttpd.net/ "Xcache") - not stable yet, volunteer testers required! -* cache exclude possibilities ( home, feeds, archieves, pages, singles ) +* cache exclude options ( home, feeds, archieves, pages, singles; regex based url exclusion ) * (optional) cache for logged-in users * 404 caching * canonical redirects caching @@ -43,6 +43,8 @@ Many thanks for donations, contributors, supporters, testers & bug reporters: * [Mark Costlow](mailto:cheeks@swcp.com "Mark Costlow") * [Jason Miller](mailto:jason@redconfetti.com "Jason Miller") * [Dave Clark](https://github.com/dkcwd "Dave Clark") +* Miguel Clara +* [plescheff](https://github.com/plescheff) == Installation == @@ -98,6 +100,29 @@ Please post feature requests to [WP-FFPC feature request topic](http://wordpress == Changelog == +Version numbering logic: + +* every A. indicates BIG changes. +* every .B version indicates new features. +* every ..C indicates bugfixes for A.B version. + += 1.6.0 = +*2014-05-30* + +What's new: + +* added functionality to exclude regex urls, contribution from [plescheff](https://github.com/plescheff/wp-ffpc/commit/3c875ad4fe1e083d3968421dd83b9c179c686649) +* added functionality to include "?" containing URL + +What's fixed: + +* some warning messages removed in case there's not a single backend installed when the plugin is activated + +Under the hood: + +* major changes to the abstract wp-common class for better interoperability between my plugins + + = 1.5.0 = *2014-05-30* diff --git a/wp-common b/wp-common index 2dd92a6..d84ff21 160000 --- a/wp-common +++ b/wp-common @@ -1 +1 @@ -Subproject commit 2dd92a681f986a6637550a2640c697be39399de9 +Subproject commit d84ff213cd944c22a6a440d6faba502abd1da774 diff --git a/wp-ffpc-acache.php b/wp-ffpc-acache.php index 024d253..904f346 100644 --- a/wp-ffpc-acache.php +++ b/wp-ffpc-acache.php @@ -26,7 +26,7 @@ if (defined('SID') && SID != '') $wp_ffpc_uri = $_SERVER['REQUEST_URI']; /* no cache for uri with query strings, things usually go bad that way */ -if ( stripos($wp_ffpc_uri, '?') !== false) +if ( isset($wp_ffpc_config['nocache_dyn']) && !empty($wp_ffpc_config['nocache_dyn']) && stripos($wp_ffpc_uri, '?') !== false ) { return false; /* no cache for pages starting with /wp- like WP admin */ @@ -67,6 +67,14 @@ if ( isset($wp_ffpc_config['nocache_cookies']) && !empty($wp_ffpc_config['nocach } } +/* no cache for excluded URL patterns */ +if ( isset($wp_ffpc_config['nocache_url']) && trim($wp_ffpc_config['nocache_url']) ) { + $pattern = sprintf('#%s#', trim($wp_ffpc_config['nocache_url'])); + if ( preg_match($pattern, $wp_ffpc_uri) ) { + return false; + } +} + /* canonical redirect storage */ $wp_ffpc_redirect = null; /* fires up the backend storage array with current config */ @@ -254,7 +262,7 @@ function wp_ffpc_callback( $buffer ) { } } - if ( is_404() ) + if ( is_404() ) $meta['status'] = 404; /* redirect page */ diff --git a/wp-ffpc-backend.php b/wp-ffpc-backend.php index dbc4be6..2d03186 100644 --- a/wp-ffpc-backend.php +++ b/wp-ffpc-backend.php @@ -520,7 +520,7 @@ class WP_FFPC_Backend { } /* verify apcu is working */ - if ( apcu_cache_info("user",true) ) { + if ( apcu_cache_info("user") ) { $this->log ( __translate__('backend OK', $this->plugin_constant ) ); $this->alive = true; } @@ -606,6 +606,14 @@ class WP_FFPC_Backend { return false; } + $xcache_admin = ini_get ( 'xcache.admin.user' ); + $xcache_pass = ini_get ( 'xcache.admin.pass' ); + + if ( empty( $xcache_admin ) || empty( $xcache_pass ) ) { + $this->log ( __translate__('XCACHE xcache.admin.user or xcache.admin.pass is not set in php.ini. Please set them, otherwise the use cache part of xcache is not accessible.', $this->plugin_constant ) ); + return false; + } + /* verify apc is working */ $info = xcache_info(); if ( !empty( $info )) { @@ -716,7 +724,7 @@ class WP_FFPC_Backend { $this->connection->setOption( Memcached::OPT_COMPRESSION , false ); $this->connection->setOption( Memcached::OPT_BINARY_PROTOCOL , true ); - if ( version_compare( phpversion( 'memcached' ) , '2.0.0', '>=' ) && ini_get( 'memcached.use_sasl' ) == 1 ) { + if ( version_compare( phpversion( 'memcached' ) , '2.0.0', '>=' ) && ini_get( 'memcached.use_sasl' ) == 1 && isset($this->options['authpass']) && !empty($this->options['authpass']) && isset($this->options['authuser']) && !empty($this->options['authuser']) ) { $this->connection->setSaslAuthData ( $this->options['authuser'], $this->options['authpass']); } } diff --git a/wp-ffpc-class.php b/wp-ffpc-class.php index 3961d77..2e0b6e6 100644 --- a/wp-ffpc-class.php +++ b/wp-ffpc-class.php @@ -3,9 +3,9 @@ if ( ! class_exists( 'WP_FFPC' ) ) : /* get the plugin abstract class*/ -include_once ( 'wp-common/plugin_abstract.php' ); +include_once ( dirname(__FILE__) . '/wp-common/plugin_abstract.php' ); /* get the common functions class*/ -include_once ( 'wp-ffpc-backend.php' ); +include_once ( dirname(__FILE__) .'/wp-ffpc-backend.php' ); /** * main wp-ffpc class @@ -63,6 +63,20 @@ class WP_FFPC extends PluginAbstract { private $scheduled = false; private $errors = array(); + /** + * + */ + public function plugin_post_construct () { + $this->plugin_url = plugin_dir_url( __FILE__ ); + $this->plugin_dir = plugin_dir_path( __FILE__ ); + + $this->common_url = $this->plugin_url . self::common_slug; + $this->common_dir = $this->plugin_dir . self::common_slug; + + $this->admin_css_handle = $this->plugin_constant . '-admin-css'; + $this->admin_css_url = $this->common_url . 'wp-admin.css'; + } + /** * init hook function runs before admin panel hook, themeing and options read */ @@ -272,12 +286,11 @@ class WP_FFPC extends PluginAbstract { */ public function plugin_extend_admin_init () { /* save parameter updates, if there are any */ - if ( isset( $_POST[ $this->button_flush ] ) ) { - + if ( isset( $_POST[ $this->button_flush ] ) && check_admin_referer ( $this->plugin_constant ) ) { /* remove precache log entry */ - $this->_delete_option( self::precache_log ); + $this->utils->_delete_option( self::precache_log ); /* remove precache timestamp entry */ - $this->_delete_option( self::precache_timestamp ); + $this->utils->_delete_option( self::precache_timestamp ); /* remove precache logfile */ if ( @file_exists ( $this->precache_logfile ) ) { @@ -296,8 +309,7 @@ class WP_FFPC extends PluginAbstract { } /* save parameter updates, if there are any */ - if ( isset( $_POST[ $this->button_precache ] ) ) { - + if ( isset( $_POST[ $this->button_precache ] ) && check_admin_referer ( $this->plugin_constant ) ) { /* is no shell function is possible, fail */ if ( $this->shell_function == false ) { $this->status = 5; @@ -407,15 +419,17 @@ class WP_FFPC extends PluginAbstract { /* we need to go through all servers */ $servers = $this->backend->status(); - foreach ( $servers as $server_string => $status ) { - echo $server_string ." => "; + if ( is_array( $servers ) && !empty ( $servers ) ) { + foreach ( $servers as $server_string => $status ) { + echo $server_string ." => "; - if ( $status == 0 ) - _e ( 'down
', $this->plugin_constant ); - elseif ( ( $this->options['cache_type'] == 'memcache' && $status > 0 ) || $status == 1 ) - _e ( 'up & running
', $this->plugin_constant ); - else - _e ( 'unknown, please try re-saving settings!
', $this->plugin_constant ); + if ( $status == 0 ) + _e ( 'down
', $this->plugin_constant ); + elseif ( ( $this->options['cache_type'] == 'memcache' && $status > 0 ) || $status == 1 ) + _e ( 'up & running
', $this->plugin_constant ); + else + _e ( 'unknown, please try re-saving settings!
', $this->plugin_constant ); + } } ?>

+ plugin_constant ); ?>