1.2 beta: error messages added globally
Peter Molnar hello@petermolnar.eu
Wed, 19 Jun 2013 11:14:52 +0100
2 files changed,
78 insertions(+),
45 deletions(-)
M
readme.txt
→
readme.txt
@@ -11,11 +11,10 @@
Fastest way of cache for WordPress: memcached + nginx! == Description == -WP-FFPC ( WordPress Fast Full Page Cache ) is a cache plugin for [WordPress](http://wordpress.org/ "WordPress"). -Supports PHP Memcached, PHP Memcache and APC as storage engines, subdomain and domain based WordPress Networks and can be connected with [NGiNX](http://NGiNX.org "NGiNX") webserver. +WP-FFPC ( WordPress Fast Full Page Cache ) is a cache plugin for [WordPress](http://wordpress.org/ "WordPress"). It works with any webserver, including apache2, lighttpd, nginx, however, can be connected with [NGiNX](http://NGiNX.org "NGiNX") through memcached for unbeatable speed. +Supports PHP Memcached, PHP Memcache and APC as storage engines, subdomain and domain based WordPress Networks. = Features: = -* [NGiNX](http://NGiNX.org "NGiNX") compatibility * Wordpress Network support ( for subdomain layout ) * cache exclude possibilities ( home, feeds, archieves, pages, singles ) * (optional) cache for logged-in users@@ -24,13 +23,17 @@ * canonical redirects caching
* Last Modified HTTP header support ( for 304 responses ) * shortlink HTTP header preservation * pingback HTTP header preservation -* (optional) talkative log for troubleshooting +* talkative log for [WP_DEBUG](http://codex.wordpress.org/WP_DEBUG "WP_DEBUG") * multiple memcached upstream support -* precache ( manually only ) +* precache ( manually or by timed by wp-cron ) +* [NGiNX](http://NGiNX.org "NGiNX") compatibility -Many thanks for supporters, testers & bug reporters: [Harold Kyle](https://github.com/haroldkyle "Harold Kyle"); [Eric Gilette](http://www.ericgillette.com/ "Eric Gilette"); [doconeill](http://wordpress.org/support/profile/doconeill "doconeill"); [Mark Costlow](mailto:cheeks@swcp.com "Mark Costlow"). +Many thanks for contributors, supporters, testers & bug reporters: -Thanks for [Hyper Cache](http://wordpress.org/extend/plugins/hyper-cache "Hyper Cache") for beeing inspirational. +* [Harold Kyle](https://github.com/haroldkyle "Harold Kyle") +* [Eric Gilette](http://www.ericgillette.com/ "Eric Gilette") +* [doconeill](http://wordpress.org/support/profile/doconeill "doconeill") +* [Mark Costlow](mailto:cheeks@swcp.com "Mark Costlow"). == Installation ==@@ -86,22 +89,27 @@
== Changelog == = 1.2 = -*TBA* +2013-06-19 What's new: -* additional cookie patterns to exclude visitors from cache -* syslog dropped; using standard PHP log instead, combined with WP_DEBUG to change to info/notice level -* possibility to start pre-cache from wp-cron -* changeable key scheme ( was fixed previously ) +* additional cookie patterns to exclude visitors from cache, contribution from [Harold Kyle](https://github.com/haroldkyle "Harold Kyle") +* syslog dropped; using "regular" PHP log instead +* pre-cache from wp-cron +* changeable key scheme ( was fixed previously ); possibility to add user-specific cache if PHPESSID cookie is present What's fixed: -* WordPress has changed in cookie naming, plugin & nginx example has been updated +* logged in cookie check fixed ( was not checking all WordPress cookies ) +* global error messages to show if settings are not saved **Dropped functions** * there's no info log on/off anymore, it's triggered when WP_DEBUG is active + +**For Devs** + +* the abstract class have been moved into a separate Github repository, [wp-common](https://github.com/petermolnar/wp-common "wp-common"). Because PHP is not capable of replacing/redefining classes, there's a versioning with the abstract and the utilities class, please be aware of this. = 1.1.1 = *2013.04.25*
M
wp-ffpc-class.php
→
wp-ffpc-class.php
@@ -69,6 +69,7 @@ private $shell_function = false;
private $shell_possibilities = array (); private $backend = NULL; private $scheduled = false; + private $errors = array(); /** * init hook function runs before admin panel hook, themeing and options read@@ -194,6 +195,43 @@
/* add precache coldrun action */ add_action( self::precache_id , array( &$this, 'precache_coldrun' ) ); + $settings_link = ' » <a href="' . $this->settings_link . '">' . __( 'WP-FFPC Settings', $this->plugin_constant ) . '</a>'; + /* check for errors */ + if ( ! WP_CACHE ) + $this->errors['no_wp_cache'] = __("WP_CACHE is disabled, plugin will not work that way. Please add define `( 'WP_CACHE', true );` in wp-config.php", $this->plugin_constant ) . $settings_link; + + if ( ! $this->global_saved ) + $this->errors['no_global_saved'] = __("Plugin settings are not yet saved for the site, please save settings!", $this->plugin_constant) . $settings_link; + + if ( ! file_exists ( $this->acache ) ) + $this->errors['no_acache_saved'] = __("Advanced cache file is yet to be generated, please save settings!", $this->plugin_constant). $settings_link; + + if ( file_exists ( $this->acache ) && ! is_writable ( $this->acache ) ) + $this->errors['no_acache_write'] = __("Advanced cache file is not writeable!<br />Please change the permissions on the file: ", $this->plugin_constant) . $this->acache; + + if ( $this->options['cache_type'] == 'memcached' && !class_exists('Memcached') ) + $this->errors['no_memcached'] = __('Memcached cache backend activated but no PHP memcached extension was found.<br />Please either use different backend or activate the module!', $this->plugin_constant); + + if ( $this->options['cache_type'] == 'memcache' && !class_exists('Memcache') ) + $this->errors['no_memcached'] = __('Memcache cache backend activated but no PHP memcache extension was found.<br />Please either use different backend or activate the module!', $this->plugin_constant); + + /* 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' ) + { + $memcache_protocol = strtolower($memcache_settings['memcache.protocol']['local_value']); + if ( $memcached_protocol == 'binary' ) { + $this->errors['binary_memcache'] = __('WARNING: Memcache extension is configured to use binary mode. This is very buggy and the plugin will most probably not work correctly. <br />Please consider to change either to ASCII mode or to Memcached extension.', $this->plugin_constant ); + } + } + } + + /* display errors globally */ + if ( $this->network ) + add_action( 'network_admin_notices', array( &$this, 'display_errors') ); + else + add_action( 'admin_notices', array( &$this, 'display_errors') ); } /**@@ -363,38 +401,6 @@ ?>
<h2><?php echo $this->plugin_name ; _e( ' settings', $this->plugin_constant ) ; ?></h2> - <?php if ( ! WP_CACHE ) { ?> - <div class="error"><p><?php _e("WP_CACHE is disabled, plugin will not work that way. Please add define `( 'WP_CACHE', true );` in wp-config.php", $this->plugin_constant ); ?></p></div> - <?php } - - if ( ! $this->global_saved ) { ?> - <div class="error"><p><?php _e("WARNING: plugin settings are not yet saved for the site, please save settings!", $this->plugin_constant); ?></p><p><?php _e( "Technical information: the configuration array is not present in the global configuration." , $this->plugin_constant ) ?></p></div> - <?php } - - if ( ! file_exists ( $this->acache ) ) { ?> - <div class="error"><p><?php _e("WARNING: advanced cache file is yet to be generated, please save settings!", $this->plugin_constant); ?></p><p><?php _e( "Technical information: please check if location is writable: " . $this->acache , $this->plugin_constant ) ?></p></div> - <?php } - - if ( $this->options['cache_type'] == 'memcached' && !class_exists('Memcached') ) { ?> - <div class="error"><p><?php _e('ERROR: Memcached cache backend activated but no PHP memcached extension was found.', $this->plugin_constant); ?></p></div> - <?php } - - if ( $this->options['cache_type'] == 'memcache' && !class_exists('Memcache') ) { ?> - <div class="error"><p><?php _e('ERROR: Memcache cache backend activated but no PHP memcache extension was found.', $this->plugin_constant); ?></p></div> - <?php } - - /* 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' ) - { - $memcache_protocol = strtolower($memcache_settings['memcache.protocol']['local_value']); - if ( $memcached_protocol == 'binary' ) { ?> - <div class="error"><p><?php _e('WARNING: Memcache extension is configured to use binary mode. This is very buggy and the plugin will most probably not work correctly. <br />Please consider to change either to ASCII mode or to Memcached extension.', $this->plugin_constant ); ?></p></div> - <?php } - } - } ?> <div class="updated"> <p><strong><?php _e ( 'Driver: ' , $this->plugin_constant); echo $this->options['cache_type']; ?></strong></p> <?php@@ -1142,6 +1148,25 @@
if ( $echo ) echo $r; else return $r; }*/ + + /** + * print errors + * + */ + public function display_errors ( ) { + if ( empty ( $this->errors )) { + $r = false; + } + else { + $r = '<div class="error"><strong>'. __('WP-FFPC found errors, please correct them!', $this->plugin_constant ) .'</strong><ol>'; + foreach ( $this->errors as $eid => $message ) { + $r .= '<li>' . $message . '</li>'; + } + $r.= '</ol></div>'; + } + + echo $r; + } } }