short open removed, syslog finished git-svn-id: http://plugins.svn.wordpress.org/wp-ffpc/trunk@508226 b8457f37-d9ea-0310-8a92-e5e31aec5664
cadeyrn cadeyrn@b8457f37-d9ea-0310-8a92-e5e31aec5664
Tue, 21 Feb 2012 13:35:48 +0000
3 files changed,
60 insertions(+),
15 deletions(-)
M
readme.txt
→
readme.txt
@@ -3,7 +3,7 @@ Contributors: cadeyrn
Tags: cache, APC, memcached, full page cache Requires at least: 3.0 Tested up to: 3.3.1 -Stable tag: 0.2.3 +Stable tag: 0.2.4 Fast Full Page Cache, backend can be memcached or APC@@ -45,6 +45,12 @@
== Upgrade Notice == == Changelog == + += 0.3 = +2012.02.21 + +* added syslog debug messages possibility +* bugfix: removed short_open_tags from config file = 0.2.3 = 2012.02.21
M
wp-ffpc-common.php
→
wp-ffpc-common.php
@@ -9,6 +9,15 @@ */
global $wp_ffpc_backend; global $wp_nmc_redirect; +/* wp ffpc prefic */ +if (!defined('WP_FFPC_PARAM')) + define ( 'WP_FFPC_PARAM' , 'wp-ffpc' ); +/* log level */ +define ('WP_FFPC_LOG_LEVEL' , LOG_INFO); +/* define log ending message */ +define ('WP_FFPC_LOG_TYPE_MSG' , '; cache type: '. $wp_ffpc_config['cache_type'] ); + + /* safety rules if file has been already included */ if ( function_exists('wp_ffpc_init') || function_exists('wp_ffpc_clear') || function_exists('wp_ffpc_set') || function_exists('wp_ffpc_get') ) return false;@@ -102,12 +111,20 @@ case 'apc':
if ( $post_only ) { apc_delete ( $meta ); + if ($wp_ffpc_config['syslog']) + syslog( WP_FFPC_LOG_LEVEL , WP_FFPC_PARAM . ' clearing key: "'. $meta . '"' . WP_FFPC_LOG_TYPE_MSG ); apc_delete ( $data ); + if ($wp_ffpc_config['syslog']) + syslog( WP_FFPC_LOG_LEVEL , WP_FFPC_PARAM . ' clearing key: "'. $data . '"' . WP_FFPC_LOG_TYPE_MSG ); } else { apc_clear_cache('user'); + if ($wp_ffpc_config['syslog']) + syslog( WP_FFPC_LOG_LEVEL , WP_FFPC_PARAM . ' flushing user cache' . WP_FFPC_LOG_TYPE_MSG ); apc_clear_cache('system'); + if ($wp_ffpc_config['syslog']) + syslog( WP_FFPC_LOG_LEVEL , WP_FFPC_PARAM . ' flushing system cache' . WP_FFPC_LOG_TYPE_MSG ); } break;@@ -118,11 +135,17 @@ global $wp_ffpc_backend;
if ( $post_only ) { $wp_ffpc_backend->delete( $meta ); + if ($wp_ffpc_config['syslog']) + syslog( WP_FFPC_LOG_LEVEL , WP_FFPC_PARAM . ' clearing key: "'. $meta . '"' . WP_FFPC_LOG_TYPE_MSG ); $wp_ffpc_backend->delete( $data ); + if ($wp_ffpc_config['syslog']) + syslog( WP_FFPC_LOG_LEVEL , WP_FFPC_PARAM . ' clearing key: "'. $data . '"' . WP_FFPC_LOG_TYPE_MSG ); } else { $wp_ffpc_backend->flush(); + if ($wp_ffpc_config['syslog']) + syslog( WP_FFPC_LOG_LEVEL , WP_FFPC_PARAM . ' flushing cache' . WP_FFPC_LOG_TYPE_MSG ); } break;@@ -144,6 +167,18 @@ function wp_ffpc_set ( &$key, &$data, $compress = false ) {
global $wp_ffpc_config; global $wp_ffpc_backend; + /* syslog */ + if ($wp_ffpc_config['syslog']) + { + if ( @is_array( $data ) ) + $string = serialize($data); + elseif ( @is_string( $data )) + $string = $data; + + $size = strlen($string); + syslog( WP_FFPC_LOG_LEVEL , WP_FFPC_PARAM . ' set key: "'. $key . '", size: '. $size . ' byte(s)' . WP_FFPC_LOG_TYPE_MSG ); + } + switch ($wp_ffpc_config['cache_type']) { case 'apc':@@ -177,6 +212,10 @@ */
function wp_ffpc_get( &$key , $uncompress = false ) { global $wp_ffpc_config; global $wp_ffpc_backend; + + /* syslog */ + if ($wp_ffpc_config['syslog']) + syslog( WP_FFPC_LOG_LEVEL , WP_FFPC_PARAM . ' get key: "'.$key . '"' . WP_FFPC_LOG_TYPE_MSG ); switch ($wp_ffpc_config['cache_type']) {
M
wp-ffpc.php
→
wp-ffpc.php
@@ -1,7 +1,7 @@
<?php /* Plugin Name: WP-FFPC -Version: 0.2.3 +Version: 0.3 Plugin URI: http://petermolnar.eu/wordpress/wp-ffpc Description: Fast Full Page Cache, backend can be memcached or APC Author: Peter Molnar@@ -160,18 +160,17 @@
/** * if options were saved */ - if ($_GET['saved']=='true' || $this->status == 1) : ?> + if ($_GET['saved']=='true' || $this->status == 1) { ?> <div id='setting-error-settings_updated' class='updated settings-error'><p><strong>Settings saved.</strong></p></div> - <?php endif; - + <?php } /** * the admin panel itself */ ?> - <?php if ( !WP_CACHE ) : ?> + <?php if ( !WP_CACHE ) { ?> <div class="updated settings-error"><p><strong>WARNING: WP_CACHE is disabled, plugin will not work that way. Please add define( 'WP_CACHE', true ); into the beginning of wp-config.php</strong></p></div> - <?php endif; ?> + <?php } ?> <div class="wrap"> <h2><?php _e( 'NMC settings', WP_FFPC_PARAM ) ; ?></h2>@@ -254,7 +253,7 @@ <label for="syslog"><?php _e("Enable syslog messages", WP_FFPC_PARAM); ?></label>
</dt> <dd> <input type="checkbox" name="syslog" id="syslog" value="1" <?php checked($this->options['syslog'],true); ?> /> - <span class="description"><?php _e('Writes sets and reads and some additional info into syslog, using "syslog" function of PHP.', WP_FFPC_PARAM); ?></span> + <span class="description"><?php _e('Writes sets, gets and flushed into syslog at INFO level, using "syslog" function of PHP.', WP_FFPC_PARAM); ?></span> <span class="default"><?php _e('Default ', WP_FFPC_PARAM); ?>: <?php $this->print_bool( $this->defaults['syslog']); ?></span> </dd>@@ -330,14 +329,15 @@
<fieldset class="grid50"> <legend><?php _e('Settings for memcached backend', WP_FFPC_PARAM); ?></legend> - <?php if ( !class_exists('Memcache') && !class_exists('Memcached') ): ?> + <?php if ( !class_exists('Memcache') && !class_exists('Memcached') ) { ?> <h1 class="error">No PHP memcached extension was found. To use memcached, you need PHP Memcache or PHP Memcached extension.</h1> - <?php endif; ?> + <?php } ?> - <?php if ( $this->options['cache_type'] == 'memcached' || $this->options['cache_type'] == 'memcache' ) : ?> + <?php if ( $this->options['cache_type'] == 'memcached' || $this->options['cache_type'] == 'memcache' ) { ?> <div> - <strong><?php _e( 'Backend status: ', WP_FFPC_PARAM ) ; ?> + <strong> <?php + _e( 'Backend status: ', WP_FFPC_PARAM ); $server_status = wp_ffpc_init( $this->options); $server_status = ( empty($server_status) || $server_status == 0 ) ? '<span class="error-msg">down</span>' : '<span class="ok-msg">up & running</span>' ;@@ -345,7 +345,7 @@ echo $server_status;
?> </strong> </div> - <?php endif; ?> + <?php } ?> <dl>@@ -370,7 +370,7 @@
</dl> </fieldset> - <?php if ( $this->options['cache_type'] == 'memcache' ) : ?> + <?php if ( $this->options['cache_type'] == 'memcache' ) { ?> <fieldset class="grid50"> <legend><?php _e('Sample config for nginx to utilize the data entries', WP_FFPC_PARAM); ?></legend>@@ -384,7 +384,7 @@ ?>
<pre><?php echo $nginx; ?></pre> </fieldset> - <? endif; ?> + <? } ?> <fieldset class="grid50"> <legend><?php _e('Settings for APC', WP_FFPC_PARAM); ?></legend>