debug logging restructure

This commit is contained in:
Peter Molnar 2016-01-15 20:18:18 +00:00
parent 62f3d0ab00
commit 32bd2f7b0e
9 changed files with 108 additions and 85 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', 'wp-ffpc' ) );
$this->log ( 'APC extension missing' );
return false;
}
/* verify apc is working */
if ( apc_cache_info("user",true) ) {
$this->log ( __translate__('backend OK', 'wp-ffpc' ) );
$this->log ( 'backend OK' );
$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', 'wp-ffpc' ), $key ), LOG_WARNING );
$this->log ( sprintf( 'Failed to delete APC entry: %s', $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', 'wp-ffpc' ), $key ) );
$this->log ( sprintf( 'APC entry delete: %s', $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', 'wp-ffpc' ) );
$this->log ( 'APCu extension missing' );
return false;
}
/* verify apcu is working */
if ( @apcu_cache_info("user") != false ) {
$this->log ( __translate__('backend OK', 'wp-ffpc' ) );
$this->log ( 'backend OK' );
$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', 'wp-ffpc' ), $key ), LOG_WARNING );
$this->log ( sprintf( 'Failed to delete APC entry: %s', $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', 'wp-ffpc' ), $key ) );
$this->log ( sprintf( 'APC entry delete: %s', $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', 'wp-ffpc' ), LOG_WARNING );
$this->log ( 'PHP Memcache extension missing', 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", 'wp-ffpc' ), LOG_WARNING );
$this->log ( "servers list is empty, init failed", 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', 'wp-ffpc' ) );
$this->log ( 'error initializing Memcache PHP extension, exiting' );
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', 'wp-ffpc' ), $server_id ) );
$this->log ( sprintf( '%s added', $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", 'wp-ffpc' ));
$this->log ( "checking server statuses" );
/* 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', 'wp-ffpc' ), $server_id ) );
$this->log ( sprintf( '%s server is down', $server_id ) );
else
$this->log ( sprintf( __translate__( '%s server is up & running', 'wp-ffpc' ), $server_id ) );
$this->log ( sprintf( '%s server is up & running', $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', 'wp-ffpc' ), $key ) );
$this->log ( sprintf( 'unable to delete entry: %s', $key ) );
}
else {
$this->log ( sprintf( __translate__( 'entry deleted: %s', 'wp-ffpc' ), $key ) );
$this->log ( sprintf( 'entry deleted: %s', $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!', 'wp-ffpc' ), LOG_WARNING );
$this->log ( ' Memcached extension missing, wp-ffpc will not be able to function correctly!', 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", 'wp-ffpc' ), LOG_WARNING );
$this->log ( "Memcached servers list is empty, init failed", 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', 'wp-ffpc' ) );
$this->log ( 'error initializing Memcached PHP extension, exiting' );
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', 'wp-ffpc' ), $server_id ) );
$this->log ( sprintf( '%s added', $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", 'wp-ffpc' ));
$this->log ( "checking server statuses");
/* get server list from connection */
$servers = $this->connection->getServerList();
@ -83,7 +83,7 @@ class WP_FFPC_Backend_memcached extends WP_FFPC_Backend {
/* reset server status to offline */
$this->status[$server_id] = 0;
if ($this->connection->set('wp-ffpc', time())) {
$this->log ( sprintf( __translate__( '%s server is up & running', 'wp-ffpc' ), $server_id ) );
$this->log ( sprintf( '%s server is up & running', $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', '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 );
$this->log ( sprintf( 'unable to set entry: %s', $key ) );
$this->log ( sprintf( 'Memcached error code: %s', $code ) );
//throw new Exception ( 'Unable to store Memcached entry ' . $key . ', error code: ' . $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', 'wp-ffpc' ), $key ) );
$this->log ( sprintf( __translate__( 'Memcached error code: %s', 'wp-ffpc' ), $code ) );
$this->log ( sprintf( 'unable to delete entry: %s', $key ) );
$this->log ( sprintf( 'Memcached error code: %s', $code ) );
}
else {
$this->log ( sprintf( __translate__( 'entry deleted: %s', 'wp-ffpc' ), $key ) );
$this->log ( sprintf( 'entry deleted: %s', $key ) );
}
}
}

View file

@ -1,4 +1,7 @@
<?php
defined('ABSPATH') or die("Walk away.");
/* __ only availabe if we're running from the inside of wordpress, not in advanced-cache.php phase */
if ( !function_exists ('__translate__') ) {
/* __ only availabe if we're running from the inside of wordpress, not in advanced-cache.php phase */

View file

@ -1,64 +1,77 @@
<?php
defined('ABSPATH') or die("Walk away.");
/**
* advanced cache worker of WordPress plugin WP-FFPC
*/
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 );
}
function __wp_ffpc_debug__ ( $text ) {
if ( defined('WP_FFPC__DEBUG_MODE') && WP_FFPC__DEBUG_MODE == true)
error_log ( __FILE__ . ': ' . $text );
}
/* check for WP cache enabled*/
if ( !WP_CACHE )
if ( !defined('WP_CACHE') || WP_CACHE != true ) {
__wp_ffpc_debug__('WP_CACHE is not true');
return false;
}
/* no cache for post request (comments, plugins and so on) */
if ($_SERVER["REQUEST_METHOD"] == 'POST')
if ($_SERVER["REQUEST_METHOD"] == 'POST') {
__wp_ffpc_debug__('POST requests are never cached');
return false;
}
/**
* Try to avoid enabling the cache if sessions are managed
* with request parameters and a session is active
*/
if (defined('SID') && SID != '')
if (defined('SID') && SID != '') {
__wp_ffpc_debug__('SID found, skipping cache');
return false;
}
/* check for config */
if (!isset($wp_ffpc_config))
if (!isset($wp_ffpc_config)) {
__wp_ffpc_debug__('wp_ffpc_config variable not found');
return false;
}
/* request uri */
$wp_ffpc_uri = $_SERVER['REQUEST_URI'];
/* no cache for robots.txt */
if ( stripos($wp_ffpc_uri, 'robots.txt') ) {
__debug__ ( 'Skippings robots.txt hit');
__wp_ffpc_debug__ ( 'Skippings robots.txt hit');
return false;
}
/* multisite files can be too large for memcached */
if ( function_exists('is_multisite') && stripos($wp_ffpc_uri, '/files/') && is_multisite() ) {
__debug__ ( 'Skippings multisite /files/ hit');
__wp_ffpc_debug__ ( 'Skippings multisite /files/ hit');
return false;
}
/* check if config is network active: use network config */
if (!empty ( $wp_ffpc_config['network'] ) )
if (!empty ( $wp_ffpc_config['network'] ) ) {
$wp_ffpc_config = $wp_ffpc_config['network'];
__wp_ffpc_debug__('using "network" level config');
}
/* check if config is active for site : use site config */
elseif ( !empty ( $wp_ffpc_config[ $_SERVER['HTTP_HOST'] ] ) )
elseif ( !empty ( $wp_ffpc_config[ $_SERVER['HTTP_HOST'] ] ) ) {
$wp_ffpc_config = $wp_ffpc_config[ $_SERVER['HTTP_HOST'] ];
__wp_ffpc_debug__("using {$_SERVER['HTTP_HOST']} level config");
}
/* plugin config not found :( */
else
else {
__wp_ffpc_debug__("no usable config found");
return false;
}
/* no cache for uri with query strings, things usually go bad that way */
if ( isset($wp_ffpc_config['nocache_dyn']) && !empty($wp_ffpc_config['nocache_dyn']) && stripos($wp_ffpc_uri, '?') !== false ) {
__debug__ ( 'Dynamic url cache is disabled ( url with "?" ), skipping');
__wp_ffpc_debug__ ( 'Dynamic url cache is disabled ( url with "?" ), skipping');
return false;
}
@ -71,7 +84,7 @@ if ( isset($wp_ffpc_config['nocache_cookies']) && !empty($wp_ffpc_config['nocach
/* check for any matches to user-added cookies to no-cache */
foreach ( $nocache_cookies as $nocache_cookie ) {
if( strpos( $n, $nocache_cookie ) === 0 ) {
__debug__ ( "Cookie exception matched: $n, skipping");
__wp_ffpc_debug__ ( "Cookie exception matched: {$n}, skipping");
return false;
}
}
@ -83,7 +96,7 @@ if ( isset($wp_ffpc_config['nocache_cookies']) && !empty($wp_ffpc_config['nocach
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) ) {
__debug__ ( "Cache exception based on URL regex pattern matched, skipping");
__wp_ffpc_debug__ ( "Cache exception based on URL regex pattern matched, skipping");
return false;
}
}
@ -105,7 +118,7 @@ if ( !isset($wp_ffpc_config['cache_loggedin']) || $wp_ffpc_config['cache_loggedi
foreach ($_COOKIE as $n=>$v) {
foreach ( $wp_ffpc_backend->cookies as $nocache_cookie ) {
if( strpos( $n, $nocache_cookie ) === 0 ) {
__debug__ ( "No cache for cookie: $n, skipping");
__wp_ffpc_debug__ ( "No cache for cookie: {$n}, skipping");
return false;
}
}
@ -117,7 +130,7 @@ $wp_ffpc_gentime = 0;
/* backend connection failed, no caching :( */
if ( $wp_ffpc_backend->status() === false ) {
__debug__ ( "Backend offline, skipping");
__wp_ffpc_debug__ ( "Backend offline");
return false;
}
@ -125,13 +138,14 @@ if ( $wp_ffpc_backend->status() === false ) {
$wp_ffpc_keys = array ( 'meta' => $wp_ffpc_config['prefix_meta'], 'data' => $wp_ffpc_config['prefix_data'] );
$wp_ffpc_values = array();
__debug__ ( "Trying to fetch entries");
__wp_ffpc_debug__ ( "Trying to fetch entries");
foreach ( $wp_ffpc_keys as $internal => $key ) {
$key = $wp_ffpc_backend->key ( $key );
$value = $wp_ffpc_backend->get ( $key );
if ( ! $value ) {
__wp_ffpc_debug__("No cached data foundd");
/* does not matter which is missing, we need both, if one fails, no caching */
wp_ffpc_start();
return;
@ -139,12 +153,13 @@ foreach ( $wp_ffpc_keys as $internal => $key ) {
else {
/* store results */
$wp_ffpc_values[ $internal ] = $value;
__debug__('Got value for ' . $internal);
__wp_ffpc_debug__('Got value for ' . $internal);
}
}
/* serve cache 404 status */
if ( isset( $wp_ffpc_values['meta']['status'] ) && $wp_ffpc_values['meta']['status'] == 404 ) {
__wp_ffpc_debug__("Serving 404");
header("HTTP/1.1 404 Not Found");
/* if I kill the page serving here, the 404 page will not be showed at all, so we do not do that
* flush();
@ -154,6 +169,7 @@ if ( isset( $wp_ffpc_values['meta']['status'] ) && $wp_ffpc_values['meta']['sta
/* server redirect cache */
if ( isset( $wp_ffpc_values['meta']['redirect'] ) && $wp_ffpc_values['meta']['redirect'] ) {
__wp_ffpc_debug__("Serving redirect to {$wp_ffpc_values['meta']['redirect']}");
header('Location: ' . $wp_ffpc_values['meta']['redirect'] );
/* cut the connection as fast as possible */
flush();
@ -165,6 +181,7 @@ if ( array_key_exists( "HTTP_IF_MODIFIED_SINCE" , $_SERVER ) && !empty( $wp_ffpc
$if_modified_since = strtotime(preg_replace('/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"]));
/* check is cache is still valid */
if ( $if_modified_since >= $wp_ffpc_values['meta']['lastmodified'] ) {
__wp_ffpc_debug__("Serving 304 Not Modified");
header("HTTP/1.0 304 Not Modified");
/* connection cut for faster serving */
flush();
@ -238,6 +255,7 @@ if ( isset($wp_ffpc_config['generate_time']) && $wp_ffpc_config['generate_time']
$wp_ffpc_values['data'] = substr_replace( $wp_ffpc_values['data'], $insertion, $index, 0);
}
__wp_ffpc_debug__("Serving data");
echo trim($wp_ffpc_values['data']);
flush();
@ -303,9 +321,9 @@ function wp_ffpc_callback( $buffer ) {
if ( isset($wp_ffpc_config[ 'nocache_comment' ]) && !empty($wp_ffpc_config[ 'nocache_comment' ]) && trim($wp_ffpc_config[ 'nocache_comment' ])) {
$pattern = sprintf('#%s#', trim($wp_ffpc_config['nocache_comment']));
__debug__ ( sprintf("Testing comment with pattern: %s", $pattern));
__wp_ffpc_debug__ ( sprintf("Testing comment with pattern: %s", $pattern));
if ( preg_match($pattern, $buffer) ) {
__debug__ ( "Cache exception based on content regex pattern matched, skipping");
__wp_ffpc_debug__ ( "Cache exception based on content regex pattern matched, skipping");
return $buffer;
}
}
@ -320,7 +338,7 @@ function wp_ffpc_callback( $buffer ) {
$meta['expire'] = time() + $wp_ffpc_config['browsercache_home'];
}
__debug__( 'Getting latest post for for home & feed');
__wp_ffpc_debug__( 'Getting latest post for for home & feed');
/* get newest post and set last modified accordingly */
$args = array(
'numberposts' => 1,
@ -347,7 +365,7 @@ function wp_ffpc_callback( $buffer ) {
global $wp_query;
if ( null != $wp_query->tax_query && !empty($wp_query->tax_query)) {
__debug__( 'Getting latest post for taxonomy: ' . json_encode($wp_query->tax_query));
__wp_ffpc_debug__( 'Getting latest post for taxonomy: ' . json_encode($wp_query->tax_query));
$args = array(
'numberposts' => 1,
@ -439,6 +457,13 @@ function wp_ffpc_callback( $buffer ) {
$to_store = substr_replace( $buffer, $insertion, $index, 0);
}
/*
if ( isset($wp_ffpc_config['relative_links']) && $wp_ffpc_config['relative_links'] == '1' ) {
$domain = parse_url(get_bloginfo('url'), PHP_URL_HOST);
$to_store = str_replace ( array("https://${domain}/", "http://${domain}/", "https://${domain}", "http://${domain}"), "/", $to_store);
}
*/
$prefix_meta = $wp_ffpc_backend->key ( $wp_ffpc_config['prefix_meta'] );
$wp_ffpc_backend->set ( $prefix_meta, $meta );

View file

@ -1,15 +1,6 @@
<?php
/* __ only availabe if we're running from the inside of wordpress, not in advanced-cache.php phase */
if ( !function_exists ('__translate__') ) {
/* __ only availabe if we're running from the inside of wordpress, not in advanced-cache.php phase */
if ( function_exists ( '__' ) ) {
function __translate__ ( $text, $domain ) { return __($text, $domain); }
}
else {
function __translate__ ( $text, $domain ) { return $text; }
}
}
defined('ABSPATH') or die("Walk away.");
/* this is the base class for all backends; the actual workers
* are included at the end of the file from backends/ directory */
@ -71,7 +62,7 @@ abstract class WP_FFPC_Backend {
$this->set_servers();
/* info level */
$this->log ( __translate__('init starting', 'wp-ffpc'));
$this->log ( 'init starting' );
/* call backend initiator based on cache type */
$init = $this->_init();
@ -137,9 +128,9 @@ abstract class WP_FFPC_Backend {
$key = $prefix . $key_base;
$this->log ( sprintf( __translate__( 'original key configuration: %s', 'wp-ffpc'), $this->options['key'] ) );
$this->log ( sprintf( __translate__( 'setting key for: %s', 'wp-ffpc'), $key_base ) );
$this->log ( sprintf( __translate__( 'setting key to: %s', 'wp-ffpc'), $key ) );
$this->log ( sprintf( 'original key configuration: %s', $this->options['key'] ) );
$this->log ( sprintf( 'setting key for: %s', $key_base ) );
$this->log ( sprintf( 'setting key to: %s', $key ) );
return $key;
}
@ -159,12 +150,12 @@ abstract class WP_FFPC_Backend {
}
/* log the current action */
$this->log ( sprintf( __translate__( 'GET %s', 'wp-ffpc'), $key ) );
$this->log ( sprintf( 'GET %s', $key ) );
$result = $this->_get( $key );
if ( $result === false || $result === null )
$this->log ( sprintf( __translate__( 'failed to get entry: %s', 'wp-ffpc'), $key ) );
$this->log ( sprintf( 'failed to get entry: %s', $key ) );
return $result;
}
@ -183,7 +174,7 @@ abstract class WP_FFPC_Backend {
return false;
/* log the current action */
$this->log ( sprintf( __translate__( 'set %s expiration time: %s', 'wp-ffpc'), $key, $this->options['expire'] ) );
$this->log ( sprintf( 'set %s expiration time: %s', $key, $this->options['expire'] ) );
/* expiration time based is based on type from now on */
/* fallback */
@ -196,13 +187,13 @@ abstract class WP_FFPC_Backend {
$expire = (int) $this->options['expire_taxonomy'];
/* log the current action */
$this->log ( sprintf( __translate__( 'SET %s', 'wp-ffpc'), $key ) );
$this->log ( sprintf( 'SET %s', $key ) );
/* proxy to internal function */
$result = $this->_set( $key, $data, $expire );
/* check result validity */
if ( $result === false || $result === null )
$this->log ( sprintf( __translate__( 'failed to set entry: %s', 'wp-ffpc'), $key ), LOG_WARNING );
$this->log ( sprintf( 'failed to set entry: %s', $key ), LOG_WARNING );
return $result;
}
@ -231,20 +222,20 @@ abstract class WP_FFPC_Backend {
/* exit if no post_id is specified */
if ( empty ( $post_id ) && $force === false ) {
$this->log ( __translate__('not clearing unidentified post ', 'wp-ffpc'), LOG_WARNING );
$this->log ( 'not clearing unidentified post', LOG_WARNING );
return false;
}
/* if invalidation method is set to full, flush cache */
if ( ( $this->options['invalidation_method'] === 0 || $force === true ) ) {
/* log action */
$this->log ( __translate__('flushing cache', 'wp-ffpc') );
$this->log ( 'flushing cache' );
/* proxy to internal function */
$result = $this->_flush();
if ( $result === false )
$this->log ( __translate__('failed to flush cache', 'wp-ffpc'), LOG_WARNING );
$this->log ( 'failed to flush cache', LOG_WARNING );
return $result;
}
@ -281,7 +272,7 @@ abstract class WP_FFPC_Backend {
/* no path, don't do anything */
if ( empty( $permalink ) && $permalink != false ) {
$this->log ( sprintf( __translate__( 'unable to determine path from Post Permalink, post ID: %s', 'wp-ffpc'), $post_id ), LOG_WARNING );
$this->log ( sprintf( 'unable to determine path from Post Permalink, post ID: %s', $post_id ), LOG_WARNING );
return false;
}
@ -437,7 +428,7 @@ abstract class WP_FFPC_Backend {
*/
protected function is_alive() {
if ( ! $this->alive ) {
$this->log ( __translate__("backend is not active, exiting function ", 'wp-ffpc') . __FUNCTION__, LOG_WARNING );
$this->log ( "backend is not active, exiting function " . __FUNCTION__, LOG_WARNING );
return false;
}

View file

@ -1,5 +1,7 @@
<?php
defined('ABSPATH') or die("Walk away.");
if ( ! class_exists( 'WP_FFPC' ) ) :
/* get the plugin abstract class*/
@ -136,8 +138,9 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
'redis' => __( 'Redis (experimental, it will break!)' , 'wp-ffpc'),
);
/* check for required functions / classes for the cache types */
$this->valid_cache_type = array (
'apc' => function_exists( 'apc_cache_info' ) ? true : false,
'apc' => (function_exists( 'apc_cache_info' ) && version_compare(PHP_VERSION, '5.3.0') <= 0 ) ? true : false,
'apcu' => function_exists( 'apcu_cache_info' ) ? true : false,
'memcache' => class_exists ( 'Memcache') ? true : false,
'memcached' => class_exists ( 'Memcached') ? true : false,
@ -148,8 +151,7 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
$this->select_invalidation_method = array (
0 => __( 'flush cache' , 'wp-ffpc'),
1 => __( 'only modified post' , 'wp-ffpc'),
2 => __( 'modified post and all taxonomies' , 'wp-ffpc'),
3 => __( 'modified post and posts index page' , 'wp-ffpc'),
2 => __( 'modified post and all related taxonomies' , 'wp-ffpc'),
);
/* map of possible key masks */
@ -159,6 +161,7 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
'$request_uri' => __('The *original* request URI as received from the client including the args', 'wp-ffpc'),
'$remote_user' => __('Name of user, authenticated by the Auth Basic Module', 'wp-ffpc'),
'$cookie_PHPSESSID' => __('PHP Session Cookie ID, if set ( empty if not )', 'wp-ffpc'),
'$accept_lang' => __('First HTTP Accept Lang set in the HTTP request', 'wp-ffpc'),
//'$cookie_COOKnginy IE' => __('Value of COOKIE', 'wp-ffpc'),
//'$http_HEADER' => __('Value of HTTP request header HEADER ( lowercase, dashes converted to underscore )', 'wp-ffpc'),
//'$query_string' => __('Full request URI after rewrites', 'wp-ffpc'),
@ -576,8 +579,7 @@ class WP_FFPC extends WP_FFPC_ABSTRACT {
$invalidation_method_description = array(
'clears everything in storage, <strong>including values set by other applications</strong>',
'clear only the modified posts entry, everything else remains in cache',
'removes all taxonomy term cache ( categories, tags, home, etc ) and the modified post as well<br><strong>Caution! Slows down page/post saving when there are many tags.</strong>',
'clear cache for modified post and posts index page'
'unvalidates post and the taxonomy related to the post',
);
foreach ($this->select_invalidation_method AS $current_key => $current_invalidation_method) {
printf('<li><em>%1$s</em> - %2$s</li>', $current_invalidation_method, $invalidation_method_description[$current_key]);

View file

@ -25,6 +25,8 @@ License: GPLv3
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
defined('ABSPATH') or die("Walk away.");
include_once ( 'wp-ffpc-class.php' );
$wp_ffpc_defaults = array (