1.9.1, see changelog

This commit is contained in:
Peter Molnar 2015-10-18 18:32:10 +01:00
parent fedcdfc278
commit c84498d069
9 changed files with 55 additions and 37 deletions

View file

@ -10,13 +10,13 @@ class WP_FFPC_Backend_apc extends WP_FFPC_Backend {
protected function _init () {
/* verify apc functions exist, apc extension is loaded */
if ( ! function_exists( 'apc_cache_info' ) ) {
$this->log ( __translate__('APC extension missing', $this->plugin_constant ) );
$this->log ( __translate__('APC extension missing', 'wp-ffpc' ) );
return false;
}
/* verify apc is working */
if ( apc_cache_info("user",true) ) {
$this->log ( __translate__('backend OK', $this->plugin_constant ) );
$this->log ( __translate__('backend OK', 'wp-ffpc' ) );
$this->alive = true;
}
}
@ -79,11 +79,11 @@ class WP_FFPC_Backend_apc extends WP_FFPC_Backend {
foreach ( $keys as $key => $dummy ) {
if ( ! apc_delete ( $key ) ) {
$this->log ( sprintf( __translate__( 'Failed to delete APC entry: %s', $this->plugin_constant ), $key ), LOG_WARNING );
$this->log ( sprintf( __translate__( 'Failed to delete APC entry: %s', 'wp-ffpc' ), $key ), LOG_WARNING );
//throw new Exception ( __translate__('Deleting APC entry failed with key ', $this->plugin_constant ) . $key );
}
else {
$this->log ( sprintf( __translate__( 'APC entry delete: %s', $this->plugin_constant ), $key ) );
$this->log ( sprintf( __translate__( 'APC entry delete: %s', 'wp-ffpc' ), $key ) );
}
}
}

View file

@ -10,13 +10,13 @@ class WP_FFPC_Backend_apcu extends WP_FFPC_Backend {
protected function _init () {
/* verify apcu functions exist, apcu extension is loaded */
if ( ! function_exists( 'apcu_cache_info' ) ) {
$this->log ( __translate__('APCu extension missing', $this->plugin_constant ) );
$this->log ( __translate__('APCu extension missing', 'wp-ffpc' ) );
return false;
}
/* verify apcu is working */
if ( @apcu_cache_info("user") != false ) {
$this->log ( __translate__('backend OK', $this->plugin_constant ) );
$this->log ( __translate__('backend OK', 'wp-ffpc' ) );
$this->alive = true;
}
}
@ -79,11 +79,11 @@ class WP_FFPC_Backend_apcu extends WP_FFPC_Backend {
foreach ( $keys as $key => $dummy ) {
if ( ! apcu_delete ( $key ) ) {
$this->log ( sprintf( __translate__( 'Failed to delete APC entry: %s', $this->plugin_constant ), $key ), LOG_WARNING );
//throw new Exception ( __translate__('Deleting APC entry failed with key ', $this->plugin_constant ) . $key );
$this->log ( sprintf( __translate__( 'Failed to delete APC entry: %s', 'wp-ffpc' ), $key ), LOG_WARNING );
//throw new Exception ( __translate__('Deleting APC entry failed with key ', 'wp-ffpc' ) . $key );
}
else {
$this->log ( sprintf( __translate__( 'APC entry delete: %s', $this->plugin_constant ), $key ) );
$this->log ( sprintf( __translate__( 'APC entry delete: %s', 'wp-ffpc' ), $key ) );
}
}
}

View file

@ -9,13 +9,13 @@ class WP_FFPC_Backend_memcache extends WP_FFPC_Backend {
protected function _init () {
/* Memcached class does not exist, Memcache extension is not available */
if (!class_exists('Memcache')) {
$this->log ( __translate__('PHP Memcache extension missing', $this->plugin_constant ), LOG_WARNING );
$this->log ( __translate__('PHP Memcache extension missing', 'wp-ffpc' ), LOG_WARNING );
return false;
}
/* check for existing server list, otherwise we cannot add backends */
if ( empty ( $this->options['servers'] ) && ! $this->alive ) {
$this->log ( __translate__("servers list is empty, init failed", $this->plugin_constant ), LOG_WARNING );
$this->log ( __translate__("servers list is empty, init failed", 'wp-ffpc' ), LOG_WARNING );
return false;
}
@ -25,7 +25,7 @@ class WP_FFPC_Backend_memcache extends WP_FFPC_Backend {
/* check if initialization was success or not */
if ( $this->connection === NULL ) {
$this->log ( __translate__( 'error initializing Memcache PHP extension, exiting', $this->plugin_constant ) );
$this->log ( __translate__( 'error initializing Memcache PHP extension, exiting', 'wp-ffpc' ) );
return false;
}
@ -37,7 +37,7 @@ class WP_FFPC_Backend_memcache extends WP_FFPC_Backend {
else
$this->status[$server_id] = $this->connection->connect ( $server['host'] , $server['port'] );
$this->log ( sprintf( __translate__( '%s added', $this->plugin_constant ), $server_id ) );
$this->log ( sprintf( __translate__( '%s added', 'wp-ffpc' ), $server_id ) );
}
/* backend is now alive */
@ -51,7 +51,7 @@ class WP_FFPC_Backend_memcache extends WP_FFPC_Backend {
*/
protected function _status () {
/* server status will be calculated by getting server stats */
$this->log ( __translate__("checking server statuses", $this->plugin_constant ));
$this->log ( __translate__("checking server statuses", 'wp-ffpc' ));
/* get servers statistic from connection */
foreach ( $this->options['servers'] as $server_id => $server ) {
if ( $server['port'] === 0 )
@ -59,9 +59,9 @@ class WP_FFPC_Backend_memcache extends WP_FFPC_Backend {
else
$this->status[$server_id] = $this->connection->getServerStatus( $server['host'], $server['port'] );
if ( $this->status[$server_id] == 0 )
$this->log ( sprintf( __translate__( '%s server is down', $this->plugin_constant ), $server_id ) );
$this->log ( sprintf( __translate__( '%s server is down', 'wp-ffpc' ), $server_id ) );
else
$this->log ( sprintf( __translate__( '%s server is up & running', $this->plugin_constant ), $server_id ) );
$this->log ( sprintf( __translate__( '%s server is up & running', 'wp-ffpc' ), $server_id ) );
}
}
@ -110,10 +110,10 @@ class WP_FFPC_Backend_memcache extends WP_FFPC_Backend {
$kresult = $this->connection->delete( $key );
if ( $kresult === false ) {
$this->log ( sprintf( __translate__( 'unable to delete entry: %s', $this->plugin_constant ), $key ) );
$this->log ( sprintf( __translate__( 'unable to delete entry: %s', 'wp-ffpc' ), $key ) );
}
else {
$this->log ( sprintf( __translate__( 'entry deleted: %s', $this->plugin_constant ), $key ) );
$this->log ( sprintf( __translate__( 'entry deleted: %s', 'wp-ffpc' ), $key ) );
}
}
}

View file

@ -7,13 +7,13 @@ class WP_FFPC_Backend_memcached extends WP_FFPC_Backend {
protected function _init () {
/* Memcached class does not exist, Memcached extension is not available */
if (!class_exists('Memcached')) {
$this->log ( __translate__(' Memcached extension missing, wp-ffpc will not be able to function correctly!', $this->plugin_constant ), LOG_WARNING );
$this->log ( __translate__(' Memcached extension missing, wp-ffpc will not be able to function correctly!', 'wp-ffpc' ), LOG_WARNING );
return false;
}
/* check for existing server list, otherwise we cannot add backends */
if ( empty ( $this->options['servers'] ) && ! $this->alive ) {
$this->log ( __translate__("Memcached servers list is empty, init failed", $this->plugin_constant ), LOG_WARNING );
$this->log ( __translate__("Memcached servers list is empty, init failed", 'wp-ffpc' ), LOG_WARNING );
return false;
}
@ -34,7 +34,7 @@ class WP_FFPC_Backend_memcached extends WP_FFPC_Backend {
/* check if initialization was success or not */
if ( $this->connection === NULL ) {
$this->log ( __translate__( 'error initializing Memcached PHP extension, exiting', $this->plugin_constant ) );
$this->log ( __translate__( 'error initializing Memcached PHP extension, exiting', 'wp-ffpc' ) );
return false;
}
@ -59,7 +59,7 @@ class WP_FFPC_Backend_memcached extends WP_FFPC_Backend {
/* only add servers that does not exists already in connection pool */
if ( !@array_key_exists($server_id , $servers_alive ) ) {
$this->connection->addServer( $server['host'], $server['port'] );
$this->log ( sprintf( __translate__( '%s added', $this->plugin_constant ), $server_id ) );
$this->log ( sprintf( __translate__( '%s added', 'wp-ffpc' ), $server_id ) );
}
}
@ -74,7 +74,7 @@ class WP_FFPC_Backend_memcached extends WP_FFPC_Backend {
*/
protected function _status () {
/* server status will be calculated by getting server stats */
$this->log ( __translate__("checking server statuses", $this->plugin_constant ));
$this->log ( __translate__("checking server statuses", 'wp-ffpc' ));
/* get server list from connection */
$servers = $this->connection->getServerList();
@ -82,8 +82,8 @@ class WP_FFPC_Backend_memcached extends WP_FFPC_Backend {
$server_id = $server['host'] . self::port_separator . $server['port'];
/* reset server status to offline */
$this->status[$server_id] = 0;
if ($this->connection->set($this->plugin_constant, time())) {
$this->log ( sprintf( __translate__( '%s server is up & running', $this->plugin_constant ), $server_id ) );
if ($this->connection->set('wp-ffpc', time())) {
$this->log ( sprintf( __translate__( '%s server is up & running', 'wp-ffpc' ), $server_id ) );
$this->status[$server_id] = 1;
}
}
@ -113,9 +113,9 @@ class WP_FFPC_Backend_memcached extends WP_FFPC_Backend {
/* if storing failed, log the error code */
if ( $result === false ) {
$code = $this->connection->getResultCode();
$this->log ( sprintf( __translate__( 'unable to set entry: %s', $this->plugin_constant ), $key ) );
$this->log ( sprintf( __translate__( 'Memcached error code: %s', $this->plugin_constant ), $code ) );
//throw new Exception ( __translate__('Unable to store Memcached entry ', $this->plugin_constant ) . $key . __translate__( ', error code: ', $this->plugin_constant ) . $code );
$this->log ( sprintf( __translate__( 'unable to set entry: %s', 'wp-ffpc' ), $key ) );
$this->log ( sprintf( __translate__( 'Memcached error code: %s', 'wp-ffpc' ), $code ) );
//throw new Exception ( __translate__('Unable to store Memcached entry ', 'wp-ffpc' ) . $key . __translate__( ', error code: ', 'wp-ffpc' ) . $code );
}
return $result;
@ -146,11 +146,11 @@ class WP_FFPC_Backend_memcached extends WP_FFPC_Backend {
if ( $kresult === false ) {
$code = $this->connection->getResultCode();
$this->log ( sprintf( __translate__( 'unable to delete entry: %s', $this->plugin_constant ), $key ) );
$this->log ( sprintf( __translate__( 'Memcached error code: %s', $this->plugin_constant ), $code ) );
$this->log ( sprintf( __translate__( 'unable to delete entry: %s', 'wp-ffpc' ), $key ) );
$this->log ( sprintf( __translate__( 'Memcached error code: %s', 'wp-ffpc' ), $code ) );
}
else {
$this->log ( sprintf( __translate__( 'entry deleted: %s', $this->plugin_constant ), $key ) );
$this->log ( sprintf( __translate__( 'entry deleted: %s', 'wp-ffpc' ), $key ) );
}
}
}

View file

@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Tags: cache, page cache, full page cache, nginx, memcached, apc, speed
Requires at least: 3.0
Tested up to: 4.3.1
Stable tag: 1.9.0
Stable tag: 1.9.1
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
@ -128,6 +128,14 @@ Version numbering logic:
* every .B version indicates new features.
* every ..C indicates bugfixes for A.B version.
= 1.9.1 =
*2015-10-18*
* bugfix for is_writable check failures ( see: https://wordpress.org/support/topic/settings-saved-but-getting-not-saved-error-message)
* bugfix for memcached.protocol notice
* typo fixes
* replace variable with string constant in translatable messages
= 1.9.0 =
*2015-10-14*

View file

@ -10,6 +10,14 @@ if ( !function_exists ('__translate__') ) {
}
}
if ( !function_exists ('__debug__') ) {
/* __ only availabe if we're running from the inside of wordpress, not in advanced-cache.php phase */
function __debug__ ( $text ) {
if ( defined('WP_FFPC__DEBUG_MODE') && WP_FFPC__DEBUG_MODE == true)
error_log ( __FILE__ . ': ' . $text );
}
}
if (!class_exists('WP_FFPC_ABSTRACT')):
/**

View file

@ -22,7 +22,6 @@ abstract class WP_FFPC_Backend {
const host_separator = ',';
const port_separator = ':';
protected $plugin_constant = 'wp-ffpc';
protected $connection = NULL;
protected $alive = false;
protected $options = array();
@ -242,7 +241,7 @@ abstract class WP_FFPC_Backend {
$this->log ( __translate__('flushing cache', 'wp-ffpc') );
/* proxy to internal function */
$internal = $this->_flush();
$result = $this->_flush();
if ( $result === false )
$this->log ( __translate__('failed to flush cache', 'wp-ffpc'), LOG_WARNING );

View file

@ -67,6 +67,7 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
*
*/
public function plugin_post_construct () {
static::debug ( __CLASS__, 'post_construct' );
$this->plugin_url = plugin_dir_url( __FILE__ );
$this->plugin_dir = plugin_dir_path( __FILE__ );
@ -78,6 +79,7 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
* init hook function runs before admin panel hook, themeing and options read
*/
public function plugin_pre_init() {
static::debug ( __CLASS__, 'pre_init' );
/* advanced cache "worker" file */
$this->acache_worker = $this->plugin_dir . $this->plugin_constant . '-acache.php';
/* WordPress advanced-cache.php file location */
@ -242,7 +244,7 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
/* get the current runtime configuration for memcache in PHP because Memcache in binary mode is really problematic */
if ( extension_loaded ( 'memcache' ) ) {
$memcache_settings = ini_get_all( 'memcache' );
if ( !empty ( $memcache_settings ) && $this->options['cache_type'] == 'memcache' )
if ( !empty ( $memcache_settings ) && $this->options['cache_type'] == 'memcache' && isset($memcache_settings['memcache.protocol']) )
{
$memcache_protocol = strtolower($memcache_settings['memcache.protocol']['local_value']);
if ( $memcache_protocol == 'binary' ) {
@ -1000,7 +1002,7 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
*/
private function deploy_advanced_cache( ) {
if ( !is_writable( $this->acache )) {
if (!touch($this->acache)) {
error_log('Generating advanced-cache.php failed: '.$this->acache.' is not writable');
return false;
}
@ -1011,6 +1013,7 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
return false;
}
/* add the required includes and generate the needed code */
$string[] = "<?php";
$string[] = self::global_config_var . ' = ' . var_export ( $this->global_config, true ) . ';' ;

View file

@ -3,7 +3,7 @@
Plugin Name: WP-FFPC
Plugin URI: https://github.com/petermolnar/wp-ffpc
Description: WordPress in-memory full page cache plugin
Version: 1.9.0
Version: 1.9.1
Author: Peter Molnar <hello@petermolnar.eu>
Author URI: http://petermolnar.eu/
License: GPLv3