Varnish HTTP Purge - Version 5.1.1

Version Description

  • April 2022
  • Prevent two versions of the plugin from running at once.
Download this release

Release Info

Developer Ipstenu
Plugin Icon 128x128 Varnish HTTP Purge
Version 5.1.1
Comparing to
See all releases

Code changes from version 5.1.0 to 5.1.1

changelog.txt CHANGED
@@ -1,5 +1,30 @@
1
  ## CHANGELOG
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  = 4.8.1 =
4
  * May 2019
5
  * Compat with WP 5.2
1
  ## CHANGELOG
2
 
3
+ = 5.0.3 =
4
+ * August 2021
5
+ * PHP 8 Compat
6
+
7
+ = 5.0.2 =
8
+ * April 2021
9
+ * Wrapping a function_exists check which shouldn't be needed, but it fataled for someone and an ounce of prevention yadda yadda.
10
+
11
+ = 5.0.1 =
12
+ * April 2021
13
+ * Updating incompatibility lists
14
+ * HHVM deprecation
15
+ * Allow saving Proxy IP with ports
16
+ * Add check for CloudFlare APO
17
+ * Improve purge execution fails
18
+ * Double check multiple varnish IPs
19
+
20
+ = 5.0 =
21
+ * March 2021
22
+ * Now purges draft and pending posts (to account for people who un-publish) - props @jerlarke
23
+ * Localhost the debugger json. They aren't updated that often, and the remote load is unnecessary.
24
+ * More support for Health Check
25
+ * Remove strtotime check on Age header - props Matt Fields
26
+ * Support for multiple IPs (based on P.Brisson's work)
27
+
28
  = 4.8.1 =
29
  * May 2019
30
  * Compat with WP 5.2
debug.php CHANGED
@@ -31,7 +31,7 @@ class VarnishDebug {
31
  $return = true;
32
  } elseif ( $newmode['active'] ) {
33
  $return = true;
34
- if ( $newmode['expire'] <= current_time( 'timestamp' ) ) {
35
  // if expire is less that NOW, it's over.
36
  self::devmode_toggle( 'deactivate' );
37
  $return = false;
@@ -51,7 +51,7 @@ class VarnishDebug {
51
  */
52
  public static function devmode_toggle( $state = 'deactivate' ) {
53
  $newmode = get_site_option( 'vhp_varnish_devmode', VarnishPurger::$devmode );
54
- $newmode['expire'] = current_time( 'timestamp' ) + DAY_IN_SECONDS;
55
 
56
  switch ( sanitize_text_field( $state ) ) {
57
  case 'activate':
@@ -680,7 +680,8 @@ class VarnishDebug {
680
  */
681
  public static function bad_themes_results() {
682
 
683
- $return = array();
 
684
  // Let's check our known bad themes.
685
  $json_data = file_get_contents( plugin_dir_path( __FILE__ ) . 'debugger/themes.json' );
686
  $themes = json_decode( $json_data );
@@ -745,14 +746,15 @@ class VarnishDebug {
745
  $return = array();
746
  $messages = array(
747
  'addon' => __( 'This plugin may require add-ons to ensure full compatibility. Please check their documentation.', 'varnish-http-purge' ),
748
- 'incompatible' => __( 'This plugin has unexpected results with caching, making not function properly.', 'varnish-http-purge' ),
749
  'translation' => __( 'Translation plugins that use cookies and/or sessions prevent most server side caching from running properly.', 'varnish-http-purge' ),
750
  'sessions' => __( 'This plugin uses sessions, which conflicts with server side caching.', 'varnish-http-purge' ),
751
  'cookies' => __( 'This plugin uses cookies, which may prevent server side caching.', 'varnish-http-purge' ),
752
  'cache' => __( 'This type of caching plugin does not work well with server side caching.', 'varnish-http-purge' ),
753
  'ancient' => __( 'This plugin is not up to date with WordPress best practices and breaks caching.', 'varnish-http-purge' ),
754
  'removed' => __( 'This plugin was removed from WordPress.org and we do not recommend it\'s use.', 'varnish-http-purge' ),
755
- 'maybe' => __( 'This plugin is usually fine, but may be configured in a way that breaks caching. Please resolve all other errors. If this is the only one left, and caching is running, you may safely ignore this message.', 'varnish-http-purge' ),
 
756
  );
757
 
758
  $json_data = file_get_contents( plugin_dir_path( __FILE__ ) . 'debugger/plugins.json' );
@@ -830,26 +832,24 @@ class VarnishDebug {
830
 
831
  // Server Results.
832
  $server_results = self::server_results( $headers, $remote_ip, $varniship );
833
- $output = array_merge( $output, $server_results );
834
 
835
  // Cache Results.
836
  $cache_results = self::cache_results( $headers );
837
- $output = array_merge( $output, $cache_results );
838
 
839
  // Cookies.
840
  $cookie_results = self::cookie_results( $headers );
841
- $output = array_merge( $output, $cookie_results );
842
 
843
  // Plugins that don't play nicely with Varnish.
844
  $bad_plugins_results = self::bad_plugins_results();
845
- $output = array_merge( $output, $bad_plugins_results );
846
 
847
  // Themes that don't play nicely with Varnish.
848
  $bad_themes_results = self::bad_themes_results();
849
- $output = array_merge( $output, $bad_themes_results );
 
 
850
 
851
  // Update site option data
852
- $debug_log = get_site_option( 'vhp_varnish_debug' );
853
  $debug_log[ VarnishPurger::the_home_url() ] = $output;
854
  update_site_option( 'vhp_varnish_debug', $debug_log );
855
 
31
  $return = true;
32
  } elseif ( $newmode['active'] ) {
33
  $return = true;
34
+ if ( $newmode['expire'] <= time() ) {
35
  // if expire is less that NOW, it's over.
36
  self::devmode_toggle( 'deactivate' );
37
  $return = false;
51
  */
52
  public static function devmode_toggle( $state = 'deactivate' ) {
53
  $newmode = get_site_option( 'vhp_varnish_devmode', VarnishPurger::$devmode );
54
+ $newmode['expire'] = time() + DAY_IN_SECONDS;
55
 
56
  switch ( sanitize_text_field( $state ) ) {
57
  case 'activate':
680
  */
681
  public static function bad_themes_results() {
682
 
683
+ $return = array();
684
+
685
  // Let's check our known bad themes.
686
  $json_data = file_get_contents( plugin_dir_path( __FILE__ ) . 'debugger/themes.json' );
687
  $themes = json_decode( $json_data );
746
  $return = array();
747
  $messages = array(
748
  'addon' => __( 'This plugin may require add-ons to ensure full compatibility. Please check their documentation.', 'varnish-http-purge' ),
749
+ 'incompatible' => __( 'This plugin has unexpected results with caching, making things not function properly.', 'varnish-http-purge' ),
750
  'translation' => __( 'Translation plugins that use cookies and/or sessions prevent most server side caching from running properly.', 'varnish-http-purge' ),
751
  'sessions' => __( 'This plugin uses sessions, which conflicts with server side caching.', 'varnish-http-purge' ),
752
  'cookies' => __( 'This plugin uses cookies, which may prevent server side caching.', 'varnish-http-purge' ),
753
  'cache' => __( 'This type of caching plugin does not work well with server side caching.', 'varnish-http-purge' ),
754
  'ancient' => __( 'This plugin is not up to date with WordPress best practices and breaks caching.', 'varnish-http-purge' ),
755
  'removed' => __( 'This plugin was removed from WordPress.org and we do not recommend it\'s use.', 'varnish-http-purge' ),
756
+ 'maybe' => __( 'This plugin is usually fine, but can be configured in a way that breaks caching. Please resolve all other errors. If this is the only one left, and caching is running, you may safely ignore this message.', 'varnish-http-purge' ),
757
+ 'maybe-cache' => __( 'This plugin is usually fine, however it has been known to have issues with caching. Sometimes its pages will not be properly updated. This is being worked on, but has no ETA for resolution.', 'varnish-http-purge' ),
758
  );
759
 
760
  $json_data = file_get_contents( plugin_dir_path( __FILE__ ) . 'debugger/plugins.json' );
832
 
833
  // Server Results.
834
  $server_results = self::server_results( $headers, $remote_ip, $varniship );
 
835
 
836
  // Cache Results.
837
  $cache_results = self::cache_results( $headers );
 
838
 
839
  // Cookies.
840
  $cookie_results = self::cookie_results( $headers );
 
841
 
842
  // Plugins that don't play nicely with Varnish.
843
  $bad_plugins_results = self::bad_plugins_results();
 
844
 
845
  // Themes that don't play nicely with Varnish.
846
  $bad_themes_results = self::bad_themes_results();
847
+
848
+ // Update Output
849
+ $output = array_merge( $output, $server_results, $cache_results, $cookie_results, $bad_plugins_results, $bad_themes_results );
850
 
851
  // Update site option data
852
+ $debug_log = get_site_option( 'vhp_varnish_debug' );
853
  $debug_log[ VarnishPurger::the_home_url() ] = $output;
854
  update_site_option( 'vhp_varnish_debug', $debug_log );
855
 
debugger/plugins.json CHANGED
@@ -17,6 +17,12 @@
17
  "reason": "translation",
18
  "always": true
19
  },
 
 
 
 
 
 
20
  "divi-protect":{
21
  "type": "bad",
22
  "path": "divi-protect/divi-protect.php",
@@ -83,7 +89,6 @@
83
  "reason": "cookies",
84
  "always": true
85
  },
86
- },
87
  "quick-cache":{
88
  "type": "bad",
89
  "path": "quick-cache/quick-cache.php",
17
  "reason": "translation",
18
  "always": true
19
  },
20
+ "custom-simple-rss":{
21
+ "type": "warning",
22
+ "path": "custom-simple-rss/custom-simple-rss.php",
23
+ "reason": "maybe-cache",
24
+ "always": false
25
+ },
26
  "divi-protect":{
27
  "type": "bad",
28
  "path": "divi-protect/divi-protect.php",
89
  "reason": "cookies",
90
  "always": true
91
  },
 
92
  "quick-cache":{
93
  "type": "bad",
94
  "path": "quick-cache/quick-cache.php",
health-check.php CHANGED
@@ -21,17 +21,17 @@ function vhp_add_site_status_tests( $tests ) {
21
 
22
  function vhp_site_status_caching_test() {
23
 
24
- // Check the debug log
25
  $debug_log = get_site_option( 'vhp_varnish_debug' );
26
  $debug_results = array();
27
  foreach ( $debug_log as $site => $results ) {
28
  foreach ( $results as $item => $content ) {
29
  $sitename = ( VarnishPurger::the_home_url() !== $site ) ? 'Site: ' . $site . '<br />' : '';
30
- // Log cache not working
31
  if ( 'Cache Service' === $item && 'notice' === $content['icon'] ) {
32
  $debug_results[ $item ] = $sitename . $content['message'];
33
  }
34
- // Log all Criticals
35
  if ( isset( $content['icon'] ) && 'bad' === $content['icon'] ) {
36
  $debug_results[ $item ] = $sitename . $content['message'];
37
  }
@@ -74,12 +74,12 @@ function vhp_site_status_caching_test() {
74
  } elseif ( ! empty( $debug_results ) && '' !== $debug_results ) {
75
  $count = count( $debug_results );
76
  // Translators: %d is the number of issues reported
77
- $desc = sprintf( _n( 'The most recent cache status check reported %d issue.', 'The most recent cache status check reported %d issues.', $count, 'varnish-http-purge' ), $count );
78
 
79
- $result['status'] = 'critical';
80
  // Translators: %d is the number of issues reported
81
- $result['label'] = sprintf( __( 'Proxy Cache Purge has reported caching errors (%s)', 'varnish-http-purge' ), $count );
82
- $result['description'] = sprintf(
83
  '<p>%s</p>',
84
  $desc
85
  );
21
 
22
  function vhp_site_status_caching_test() {
23
 
24
+ // Check the debug log.
25
  $debug_log = get_site_option( 'vhp_varnish_debug' );
26
  $debug_results = array();
27
  foreach ( $debug_log as $site => $results ) {
28
  foreach ( $results as $item => $content ) {
29
  $sitename = ( VarnishPurger::the_home_url() !== $site ) ? 'Site: ' . $site . '<br />' : '';
30
+ // Log cache not working.
31
  if ( 'Cache Service' === $item && 'notice' === $content['icon'] ) {
32
  $debug_results[ $item ] = $sitename . $content['message'];
33
  }
34
+ // Log all critical warnings.
35
  if ( isset( $content['icon'] ) && 'bad' === $content['icon'] ) {
36
  $debug_results[ $item ] = $sitename . $content['message'];
37
  }
74
  } elseif ( ! empty( $debug_results ) && '' !== $debug_results ) {
75
  $count = count( $debug_results );
76
  // Translators: %d is the number of issues reported
77
+ $desc = sprintf( _n( 'The most recent cache status check reported %d issue.', 'The most recent cache status check reported %d issues.', $count, 'varnish-http-purge' ), $count );
78
 
79
+ $result['status'] = 'critical';
80
  // Translators: %d is the number of issues reported
81
+ $result['label'] = sprintf( __( 'Proxy Cache Purge has reported caching errors (%s)', 'varnish-http-purge' ), $count );
82
+ $result['description'] = sprintf(
83
  '<p>%s</p>',
84
  $desc
85
  );
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: Ipstenu, mikeschroder, techpriester, danielbachhuber
3
  Tags: proxy, purge, cache, varnish, nginx
4
  Requires at least: 5.0
5
- Tested up to: 5.9
6
- Stable tag: 5.1.0
7
  Requires PHP: 5.6
8
 
9
  Automatically empty proxy cached content when your site is modified.
@@ -247,6 +247,10 @@ This plugin is installed by default for _all_ DreamPress installs on DreamHost,
247
 
248
  == Changelog ==
249
 
 
 
 
 
250
  = 5.1 =
251
  * February 2022
252
  * WP 5.9 Compat
2
  Contributors: Ipstenu, mikeschroder, techpriester, danielbachhuber
3
  Tags: proxy, purge, cache, varnish, nginx
4
  Requires at least: 5.0
5
+ Tested up to: 6.0
6
+ Stable tag: 5.1.1
7
  Requires PHP: 5.6
8
 
9
  Automatically empty proxy cached content when your site is modified.
247
 
248
  == Changelog ==
249
 
250
+ = 5.1.1 =
251
+ * April 2022
252
+ * Prevent two versions of the plugin from running at once.
253
+
254
  = 5.1 =
255
  * February 2022
256
  * WP 5.9 Compat
settings.php CHANGED
@@ -149,7 +149,7 @@ class VarnishStatus {
149
  */
150
  public function options_settings_maxposts() {
151
  ?>
152
- <p><a name="#configuremaxposts"></a><?php esc_html_e( 'Since it\'s possible to purge multiple URLs in sequence, there can be cases where too many URLs are queued at a time. In order to minimize disruption, the plugin has a limit of how many URLs can be queued before it runs a "purge all" instead. You can customize that here.', 'varnish-http-purge' ); ?></strong></p>
153
  <?php
154
  }
155
 
149
  */
150
  public function options_settings_maxposts() {
151
  ?>
152
+ <p><a name="#configuremaxposts"></a><?php esc_html_e( 'Since it\'s possible to purge multiple URLs in sequence, there can be cases where too many URLs are queued at a time. In order to minimize disruption, the plugin has a limit of how many URLs can be queued before it runs a "purge all" instead. You can customize that value here.', 'varnish-http-purge' ); ?></strong></p>
153
  <?php
154
  }
155
 
uninstall.php CHANGED
@@ -8,6 +8,7 @@ if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
8
  exit();
9
  }
10
 
 
11
  delete_site_option( 'vhp_varnish_url' );
12
  delete_site_option( 'vhp_varnish_ip' );
13
  delete_site_option( 'vhp_varnish_devmode' );
8
  exit();
9
  }
10
 
11
+ // Delete site options.
12
  delete_site_option( 'vhp_varnish_url' );
13
  delete_site_option( 'vhp_varnish_ip' );
14
  delete_site_option( 'vhp_varnish_devmode' );
varnish-http-purge.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Proxy Cache Purge
4
  * Plugin URI: https://github.com/ipstenu/varnish-http-purge/
5
  * Description: Automatically empty cached pages when content on your site is modified.
6
- * Version: 5.1.0
7
  * Author: Mika Epstein
8
  * Author URI: https://halfelf.org/
9
  * License: http://www.apache.org/licenses/LICENSE-2.0
@@ -14,7 +14,8 @@
14
  *
15
  * Copyright 2016-2022 Mika Epstein (email: ipstenu@halfelf.org)
16
  *
17
- * This file is part of Proxy Cache Purge, a plugin for WordPress.
 
18
  *
19
  * Proxy Cache Purge is free software: you can redistribute it and/or modify
20
  * it under the terms of the Apache License 2.0 license.
@@ -762,6 +763,16 @@ class VarnishPurger {
762
  $purgeme .= '?' . $p['query'];
763
  }
764
 
 
 
 
 
 
 
 
 
 
 
765
  /**
766
  * Filters the HTTP headers to send with a PURGE request.
767
  *
@@ -1105,16 +1116,19 @@ if ( defined( 'WP_CLI' ) && WP_CLI ) {
1105
  include 'wp-cli.php';
1106
  }
1107
 
1108
- /*
1109
- * Settings Pages
1110
- *
1111
- * @since 4.0
1112
- */
1113
- // The settings PAGES aren't needed on the network admin page
1114
- if ( ! is_network_admin() ) {
1115
- require_once 'settings.php';
1116
- }
1117
- require_once 'debug.php';
1118
- require_once 'health-check.php';
 
 
1119
 
1120
- $purger = new VarnishPurger();
 
3
  * Plugin Name: Proxy Cache Purge
4
  * Plugin URI: https://github.com/ipstenu/varnish-http-purge/
5
  * Description: Automatically empty cached pages when content on your site is modified.
6
+ * Version: 5.1.1
7
  * Author: Mika Epstein
8
  * Author URI: https://halfelf.org/
9
  * License: http://www.apache.org/licenses/LICENSE-2.0
14
  *
15
  * Copyright 2016-2022 Mika Epstein (email: ipstenu@halfelf.org)
16
  *
17
+ * This file is part of Proxy Cache Purge (formerly Varnish HTTP Purge), a
18
+ * plugin for WordPress.
19
  *
20
  * Proxy Cache Purge is free software: you can redistribute it and/or modify
21
  * it under the terms of the Apache License 2.0 license.
763
  $purgeme .= '?' . $p['query'];
764
  }
765
 
766
+ /**
767
+ * Filter the purge path
768
+ *
769
+ * Allows dynamically changing the purge cache for custom purge location
770
+ * or systems not supporting .* regex purge for example
771
+ *
772
+ * @since 5.1
773
+ */
774
+ $purgeme = apply_filters( 'vhp_purgeme_path', $purgeme, $schema, $one_host, $path, $pregex, $p );
775
+
776
  /**
777
  * Filters the HTTP headers to send with a PURGE request.
778
  *
1116
  include 'wp-cli.php';
1117
  }
1118
 
1119
+ // Preventing people from forking this and hurting themselve by having two versions, though it may not work.
1120
+ if ( ! class_exists( 'VarnishPurger' ) ) {
1121
+ /*
1122
+ * Settings Pages
1123
+ *
1124
+ * @since 4.0
1125
+ */
1126
+ // The settings PAGES aren't needed on the network admin page
1127
+ if ( ! is_network_admin() ) {
1128
+ require_once 'settings.php';
1129
+ }
1130
+ require_once 'debug.php';
1131
+ require_once 'health-check.php';
1132
 
1133
+ $purger = new VarnishPurger();
1134
+ }
wp-cli.php CHANGED
@@ -13,6 +13,7 @@ if ( ! defined( 'WP_CLI' ) ) {
13
  return;
14
  }
15
 
 
16
  if ( ! class_exists( 'WP_CLI_Varnish_Command' ) ) {
17
 
18
  /**
13
  return;
14
  }
15
 
16
+ // Only load if the class doesn't exist.
17
  if ( ! class_exists( 'WP_CLI_Varnish_Command' ) ) {
18
 
19
  /**