diff --git a/backends/apc.php b/backends/apc.php
index 6357e4e..60b7fa3 100644
--- a/backends/apc.php
+++ b/backends/apc.php
@@ -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 ) );
}
}
}
diff --git a/backends/apcu.php b/backends/apcu.php
index 98fb734..c3953b3 100644
--- a/backends/apcu.php
+++ b/backends/apcu.php
@@ -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 ) );
}
}
}
diff --git a/backends/memcache.php b/backends/memcache.php
index a748f13..84246b6 100644
--- a/backends/memcache.php
+++ b/backends/memcache.php
@@ -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 ) );
}
}
}
diff --git a/backends/memcached.php b/backends/memcached.php
index 47828c8..e84f5fd 100644
--- a/backends/memcached.php
+++ b/backends/memcached.php
@@ -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 ) );
}
}
}
diff --git a/wp-ffpc-abstract.php b/wp-ffpc-abstract.php
index f6f5005..87d21b2 100644
--- a/wp-ffpc-abstract.php
+++ b/wp-ffpc-abstract.php
@@ -1,4 +1,7 @@
$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 );
diff --git a/wp-ffpc-backend.php b/wp-ffpc-backend.php
index 7a05358..261c11a 100644
--- a/wp-ffpc-backend.php
+++ b/wp-ffpc-backend.php
@@ -1,15 +1,6 @@
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;
}
diff --git a/wp-ffpc-class.php b/wp-ffpc-class.php
index 6f53de0..9dbe507 100644
--- a/wp-ffpc-class.php
+++ b/wp-ffpc-class.php
@@ -1,5 +1,7 @@
__( '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, including values set by other applications',
'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
Caution! Slows down page/post saving when there are many tags.',
- '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('