Version Description
- Fixed WP-CLI redirect issue in multisite
- Fix: Avoid PREG_JIT_STACKLIMIT_ERROR in minify
- Fix: Prevent empty needle PHP warning
- Update: Allow to specify URIs with a query string in Additional Pages
Download this release
Release Info
Developer | joemoto |
Plugin | W3 Total Cache |
Version | 0.14.2 |
Comparing to | |
See all releases |
Code changes from version 0.14.1 to 0.14.2
- Dispatcher.php +11 -5
- Generic_Plugin.php +20 -37
- Util_Environment.php +15 -7
- Util_PageUrls.php +5 -3
- Util_WpmuBlogmap.php +33 -6
- lib/Minify/Minify/HTML.php +7 -1
- lib/Minify/Minify/IgnoredCommentPreserver.php +5 -5
- readme.txt +7 -1
- w3-total-cache-api.php +1 -1
- w3-total-cache.php +1 -1
Dispatcher.php
CHANGED
@@ -5,18 +5,18 @@ namespace W3TC;
|
|
5 |
* Interplugin communication
|
6 |
*/
|
7 |
class Dispatcher {
|
|
|
|
|
8 |
/**
|
9 |
* return component instance
|
10 |
*/
|
11 |
static public function component( $class ) {
|
12 |
-
|
13 |
-
|
14 |
-
if ( !isset( $instances[$class] ) ) {
|
15 |
$full_class = '\\W3TC\\' . $class;
|
16 |
-
|
17 |
}
|
18 |
|
19 |
-
$v =
|
20 |
return $v;
|
21 |
}
|
22 |
|
@@ -28,6 +28,12 @@ class Dispatcher {
|
|
28 |
|
29 |
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
static public function config_master() {
|
32 |
static $config_master = null;
|
33 |
|
5 |
* Interplugin communication
|
6 |
*/
|
7 |
class Dispatcher {
|
8 |
+
static private $instances = array();
|
9 |
+
|
10 |
/**
|
11 |
* return component instance
|
12 |
*/
|
13 |
static public function component( $class ) {
|
14 |
+
if ( !isset( self::$instances[$class] ) ) {
|
|
|
|
|
15 |
$full_class = '\\W3TC\\' . $class;
|
16 |
+
self::$instances[$class] = new $full_class();
|
17 |
}
|
18 |
|
19 |
+
$v = self::$instances[$class]; // Don't return reference
|
20 |
return $v;
|
21 |
}
|
22 |
|
28 |
|
29 |
|
30 |
|
31 |
+
static public function reset_config() {
|
32 |
+
unset(self::$instances['Config']);
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
static public function config_master() {
|
38 |
static $config_master = null;
|
39 |
|
Generic_Plugin.php
CHANGED
@@ -163,52 +163,35 @@ class Generic_Plugin {
|
|
163 |
}
|
164 |
|
165 |
if ( isset( $GLOBALS['w3tc_blogmap_register_new_item'] ) ) {
|
166 |
-
$do_redirect =
|
167 |
-
// true value is a sign to just generate config cache
|
168 |
-
if ( $GLOBALS['w3tc_blogmap_register_new_item'] != 'cache_options' ) {
|
169 |
-
if ( Util_Environment::is_wpmu_subdomain() )
|
170 |
-
$blog_home_url = $GLOBALS['w3tc_blogmap_register_new_item'];
|
171 |
-
else {
|
172 |
-
$home_url = rtrim( get_home_url(), '/' );
|
173 |
-
if ( substr( $home_url, 0, 7 ) == 'http://' )
|
174 |
-
$home_url = substr( $home_url, 7 );
|
175 |
-
else if ( substr( $home_url, 0, 8 ) == 'https://' )
|
176 |
-
$home_url = substr( $home_url, 8 );
|
177 |
-
|
178 |
-
if ( substr( $GLOBALS['w3tc_blogmap_register_new_item'], 0,
|
179 |
-
strlen( $home_url ) ) == $home_url )
|
180 |
-
$blog_home_url = $home_url;
|
181 |
-
else
|
182 |
-
$blog_home_url = $GLOBALS['w3tc_blogmap_register_new_item'];
|
183 |
-
}
|
184 |
-
|
185 |
|
186 |
-
|
187 |
-
|
|
|
188 |
|
189 |
-
|
190 |
-
|
191 |
-
$w3_current_blog_id = null;
|
192 |
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
$environment = Dispatcher::component( 'Root_Environment' );
|
198 |
-
$environment->fix_on_event( $this->_config, 'first_frontend',
|
199 |
-
$this->_config );
|
200 |
-
}
|
201 |
|
202 |
// need to repeat request processing, since we was not able to realize
|
203 |
// blog_id before so we are running with master config now.
|
204 |
// redirect to the same url causes "redirect loop" error in browser,
|
205 |
// so need to redirect to something a bit different
|
206 |
if ( $do_redirect ) {
|
207 |
-
if (
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
|
|
|
|
|
|
|
|
|
|
212 |
}
|
213 |
}
|
214 |
}
|
163 |
}
|
164 |
|
165 |
if ( isset( $GLOBALS['w3tc_blogmap_register_new_item'] ) ) {
|
166 |
+
$do_redirect = Util_WpmuBlogmap::register_new_item( $this->_config );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
+
// reset cache of blog_id
|
169 |
+
Util_Environment::reset_microcache();
|
170 |
+
Dispatcher::reset_config();
|
171 |
|
172 |
+
// change config to actual blog, it was master before
|
173 |
+
$this->_config = new Config();
|
|
|
174 |
|
175 |
+
// fix environment, potentially it's first request to a specific blog
|
176 |
+
$environment = Dispatcher::component( 'Root_Environment' );
|
177 |
+
$environment->fix_on_event( $this->_config, 'first_frontend',
|
178 |
+
$this->_config );
|
|
|
|
|
|
|
|
|
179 |
|
180 |
// need to repeat request processing, since we was not able to realize
|
181 |
// blog_id before so we are running with master config now.
|
182 |
// redirect to the same url causes "redirect loop" error in browser,
|
183 |
// so need to redirect to something a bit different
|
184 |
if ( $do_redirect ) {
|
185 |
+
if ( ( defined( 'WP_CLI' ) && WP_CLI ) || php_sapi_name() == 'cli' ) {
|
186 |
+
// command-line mode, no real requests made,
|
187 |
+
// try to switch context in-request
|
188 |
+
} else {
|
189 |
+
if ( strpos( $_SERVER['REQUEST_URI'], '?' ) === false )
|
190 |
+
Util_Environment::safe_redirect_temp( $_SERVER['REQUEST_URI'] . '?repeat=w3tc' );
|
191 |
+
else {
|
192 |
+
if ( strpos( $_SERVER['REQUEST_URI'], 'repeat=w3tc' ) === false )
|
193 |
+
Util_Environment::safe_redirect_temp( $_SERVER['REQUEST_URI'] . '&repeat=w3tc' );
|
194 |
+
}
|
195 |
}
|
196 |
}
|
197 |
}
|
Util_Environment.php
CHANGED
@@ -173,24 +173,25 @@ class Util_Environment {
|
|
173 |
return $wpmu;
|
174 |
}
|
175 |
|
|
|
|
|
176 |
static public function is_using_master_config() {
|
177 |
-
|
178 |
-
if ( is_null( $result ) ) {
|
179 |
if ( !Util_Environment::is_wpmu() ) {
|
180 |
-
|
181 |
} elseif ( is_network_admin() ) {
|
182 |
-
|
183 |
} else {
|
184 |
$blog_data = Util_WpmuBlogmap::get_current_blog_data();
|
185 |
if ( is_null( $blog_data ) ) {
|
186 |
-
|
187 |
} else {
|
188 |
-
|
189 |
}
|
190 |
}
|
191 |
}
|
192 |
|
193 |
-
return
|
194 |
}
|
195 |
|
196 |
/**
|
@@ -1244,4 +1245,11 @@ class Util_Environment {
|
|
1244 |
// wp filters are not available in that case
|
1245 |
return preg_match( '~' . W3TC_WP_JSON_URI . '~', $url );
|
1246 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1247 |
}
|
173 |
return $wpmu;
|
174 |
}
|
175 |
|
176 |
+
static private $is_using_master_config = null;
|
177 |
+
|
178 |
static public function is_using_master_config() {
|
179 |
+
if ( is_null( self::$is_using_master_config ) ) {
|
|
|
180 |
if ( !Util_Environment::is_wpmu() ) {
|
181 |
+
self::$is_using_master_config = true;
|
182 |
} elseif ( is_network_admin() ) {
|
183 |
+
self::$is_using_master_config = true;
|
184 |
} else {
|
185 |
$blog_data = Util_WpmuBlogmap::get_current_blog_data();
|
186 |
if ( is_null( $blog_data ) ) {
|
187 |
+
self::$is_using_master_config = true;
|
188 |
} else {
|
189 |
+
self::$is_using_master_config = ( $blog_data[0] == 'm' );
|
190 |
}
|
191 |
}
|
192 |
}
|
193 |
|
194 |
+
return self::$is_using_master_config;
|
195 |
}
|
196 |
|
197 |
/**
|
1245 |
// wp filters are not available in that case
|
1246 |
return preg_match( '~' . W3TC_WP_JSON_URI . '~', $url );
|
1247 |
}
|
1248 |
+
|
1249 |
+
static public function reset_microcache() {
|
1250 |
+
global $w3_current_blog_id;
|
1251 |
+
$w3_current_blog_id = null;
|
1252 |
+
|
1253 |
+
self::$is_using_master_config = null;
|
1254 |
+
}
|
1255 |
}
|
Util_PageUrls.php
CHANGED
@@ -431,14 +431,16 @@ class Util_PageUrls {
|
|
431 |
$key = md5( implode( ',', $pages ) );
|
432 |
if ( !isset( $pages_urls[$key] ) ) {
|
433 |
$full_urls = array();
|
434 |
-
foreach ( $pages as $
|
435 |
-
if ( $
|
436 |
-
$page_link = get_home_url() . '/' . trim( $
|
|
|
437 |
$full_urls[] = $page_link;
|
438 |
}
|
439 |
}
|
440 |
$pages_urls[$key] = $full_urls;
|
441 |
}
|
|
|
442 |
return $pages_urls[$key];
|
443 |
}
|
444 |
|
431 |
$key = md5( implode( ',', $pages ) );
|
432 |
if ( !isset( $pages_urls[$key] ) ) {
|
433 |
$full_urls = array();
|
434 |
+
foreach ( $pages as $uri ) {
|
435 |
+
if ( $uri ) {
|
436 |
+
$page_link = get_home_url() . '/' . trim( $uri, '/' ) .
|
437 |
+
( strpos( $uri, '?' ) !== FALSE ? '': '/' );
|
438 |
$full_urls[] = $page_link;
|
439 |
}
|
440 |
}
|
441 |
$pages_urls[$key] = $full_urls;
|
442 |
}
|
443 |
+
|
444 |
return $pages_urls[$key];
|
445 |
}
|
446 |
|
Util_WpmuBlogmap.php
CHANGED
@@ -94,23 +94,49 @@ class Util_WpmuBlogmap {
|
|
94 |
/**
|
95 |
* Registers new blog url in url=>blog mapfile
|
96 |
*/
|
97 |
-
static public function register_new_item( $
|
98 |
-
if ( !isset( $GLOBALS['current_blog'] ) )
|
99 |
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
$filename = Util_WpmuBlogmap::blogmap_filename_by_home_url( $blog_home_url );
|
102 |
|
103 |
-
if ( !@file_exists( $filename ) )
|
104 |
$blog_ids = array();
|
105 |
-
else {
|
106 |
$data = @file_get_contents( $filename );
|
107 |
$blog_ids = @json_decode( $data, true );
|
108 |
-
if ( !is_array( $blog_ids ) )
|
109 |
$blog_ids = array();
|
|
|
110 |
}
|
111 |
|
112 |
-
if ( isset( $blog_ids[$blog_home_url] ) )
|
113 |
return false;
|
|
|
|
|
114 |
$data = $config->get_boolean( 'common.force_master' ) ? 'm' : 'c';
|
115 |
$blog_home_url = preg_replace( '/[^a-zA-Z0-9\+\.%~!:()\/\-\_]/', '', $blog_home_url );
|
116 |
$blog_ids[$blog_home_url] = $data . $GLOBALS['current_blog']->blog_id;
|
@@ -124,6 +150,7 @@ class Util_WpmuBlogmap {
|
|
124 |
}
|
125 |
|
126 |
unset( self::$content_by_filename[$filename] );
|
|
|
127 |
|
128 |
return true;
|
129 |
}
|
94 |
/**
|
95 |
* Registers new blog url in url=>blog mapfile
|
96 |
*/
|
97 |
+
static public function register_new_item( $config ) {
|
98 |
+
if ( !isset( $GLOBALS['current_blog'] ) ) {
|
99 |
return false;
|
100 |
+
}
|
101 |
+
|
102 |
+
|
103 |
+
// find blog_home_url
|
104 |
+
if ( Util_Environment::is_wpmu_subdomain() ) {
|
105 |
+
$blog_home_url = $GLOBALS['w3tc_blogmap_register_new_item'];
|
106 |
+
} else {
|
107 |
+
$home_url = rtrim( get_home_url(), '/' );
|
108 |
+
if ( substr( $home_url, 0, 7 ) == 'http://' ) {
|
109 |
+
$home_url = substr( $home_url, 7 );
|
110 |
+
} else if ( substr( $home_url, 0, 8 ) == 'https://' ) {
|
111 |
+
$home_url = substr( $home_url, 8 );
|
112 |
+
}
|
113 |
|
114 |
+
if ( substr( $GLOBALS['w3tc_blogmap_register_new_item'], 0,
|
115 |
+
strlen( $home_url ) ) == $home_url ) {
|
116 |
+
$blog_home_url = $home_url;
|
117 |
+
} else {
|
118 |
+
$blog_home_url = $GLOBALS['w3tc_blogmap_register_new_item'];
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
|
123 |
+
// write contents
|
124 |
$filename = Util_WpmuBlogmap::blogmap_filename_by_home_url( $blog_home_url );
|
125 |
|
126 |
+
if ( !@file_exists( $filename ) ) {
|
127 |
$blog_ids = array();
|
128 |
+
} else {
|
129 |
$data = @file_get_contents( $filename );
|
130 |
$blog_ids = @json_decode( $data, true );
|
131 |
+
if ( !is_array( $blog_ids ) ) {
|
132 |
$blog_ids = array();
|
133 |
+
}
|
134 |
}
|
135 |
|
136 |
+
if ( isset( $blog_ids[$blog_home_url] ) ) {
|
137 |
return false;
|
138 |
+
}
|
139 |
+
|
140 |
$data = $config->get_boolean( 'common.force_master' ) ? 'm' : 'c';
|
141 |
$blog_home_url = preg_replace( '/[^a-zA-Z0-9\+\.%~!:()\/\-\_]/', '', $blog_home_url );
|
142 |
$blog_ids[$blog_home_url] = $data . $GLOBALS['current_blog']->blog_id;
|
150 |
}
|
151 |
|
152 |
unset( self::$content_by_filename[$filename] );
|
153 |
+
unset( $GLOBALS['w3tc_blogmap_register_new_item'] );
|
154 |
|
155 |
return true;
|
156 |
}
|
lib/Minify/Minify/HTML.php
CHANGED
@@ -157,11 +157,17 @@ class Minify_HTML {
|
|
157 |
,$this->_html);
|
158 |
|
159 |
// remove trailing slash from void elements
|
160 |
-
$
|
161 |
'~<(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)(([^\'">]|\"[^\"]*\"|\'[^\']*\'|)*?)\\s*[/]?>~i'
|
162 |
,'<$1$2>'
|
163 |
,$this->_html);
|
164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
// use newlines before 1st attribute in open tags (to limit line lengths)
|
166 |
$this->_html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n$2", $this->_html);
|
167 |
|
157 |
,$this->_html);
|
158 |
|
159 |
// remove trailing slash from void elements
|
160 |
+
$_html = preg_replace(
|
161 |
'~<(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)(([^\'">]|\"[^\"]*\"|\'[^\']*\'|)*?)\\s*[/]?>~i'
|
162 |
,'<$1$2>'
|
163 |
,$this->_html);
|
164 |
|
165 |
+
// Avoid PREG_JIT_STACKLIMIT_ERROR. Thanks @ericek111 for https://github.com/W3EDGE/w3-total-cache/issues/190.
|
166 |
+
if ( preg_last_error() === PREG_NO_ERROR ) {
|
167 |
+
$this->_html = $_html;
|
168 |
+
}
|
169 |
+
unset( $_html );
|
170 |
+
|
171 |
// use newlines before 1st attribute in open tags (to limit line lengths)
|
172 |
$this->_html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n$2", $this->_html);
|
173 |
|
lib/Minify/Minify/IgnoredCommentPreserver.php
CHANGED
@@ -14,15 +14,15 @@ class Minify_IgnoredCommentPreserver {
|
|
14 |
}
|
15 |
|
16 |
public function search($html) {
|
17 |
-
$html = preg_replace_callback('/<!--[\\s\\S]*?-->/',
|
18 |
-
array($this, '_callback'),
|
19 |
$html);
|
20 |
return $html;
|
21 |
}
|
22 |
|
23 |
public function replace($html) {
|
24 |
-
$html = str_replace(array_keys($this->_placeholders),
|
25 |
-
array_values($this->_placeholders),
|
26 |
$html);
|
27 |
return $html;
|
28 |
}
|
@@ -39,7 +39,7 @@ class Minify_IgnoredCommentPreserver {
|
|
39 |
|
40 |
protected function _isIgnoredComment(&$comment) {
|
41 |
foreach ($this->_ignoredComments as $ignoredComment) {
|
42 |
-
if (stristr($comment, $ignoredComment) !== false) {
|
43 |
return true;
|
44 |
}
|
45 |
}
|
14 |
}
|
15 |
|
16 |
public function search($html) {
|
17 |
+
$html = preg_replace_callback('/<!--[\\s\\S]*?-->/',
|
18 |
+
array($this, '_callback'),
|
19 |
$html);
|
20 |
return $html;
|
21 |
}
|
22 |
|
23 |
public function replace($html) {
|
24 |
+
$html = str_replace(array_keys($this->_placeholders),
|
25 |
+
array_values($this->_placeholders),
|
26 |
$html);
|
27 |
return $html;
|
28 |
}
|
39 |
|
40 |
protected function _isIgnoredComment(&$comment) {
|
41 |
foreach ($this->_ignoredComments as $ignoredComment) {
|
42 |
+
if ( ! empty( $ignoredComment ) && stristr($comment, $ignoredComment ) !== false) {
|
43 |
return true;
|
44 |
}
|
45 |
}
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: boldgrid, fredericktownes, maxicusc, gidomanders, bwmarkle, harryj
|
|
3 |
Tags: seo, cache, optimize, pagespeed, performance, caching, compression, maxcdn, nginx, varnish, redis, new relic, aws, amazon web services, s3, cloudfront, rackspace, cloudflare, azure, apache
|
4 |
Requires at least: 3.2
|
5 |
Tested up to: 5.4
|
6 |
-
Stable tag: 0.14.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -275,6 +275,12 @@ Please reach out to all of these people and support their projects if you're so
|
|
275 |
|
276 |
== Changelog ==
|
277 |
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
= 0.14.1 =
|
279 |
* Fixed CSS minify URL rewrite logic that affected some lazy loading and CSS URL addresses using protocols
|
280 |
|
3 |
Tags: seo, cache, optimize, pagespeed, performance, caching, compression, maxcdn, nginx, varnish, redis, new relic, aws, amazon web services, s3, cloudfront, rackspace, cloudflare, azure, apache
|
4 |
Requires at least: 3.2
|
5 |
Tested up to: 5.4
|
6 |
+
Stable tag: 0.14.2
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
275 |
|
276 |
== Changelog ==
|
277 |
|
278 |
+
= 0.14.2 =
|
279 |
+
* Fixed WP-CLI redirect issue in multisite
|
280 |
+
* Fix: Avoid PREG_JIT_STACKLIMIT_ERROR in minify
|
281 |
+
* Fix: Prevent empty needle PHP warning
|
282 |
+
* Update: Allow to specify URIs with a query string in Additional Pages
|
283 |
+
|
284 |
= 0.14.1 =
|
285 |
* Fixed CSS minify URL rewrite logic that affected some lazy loading and CSS URL addresses using protocols
|
286 |
|
w3-total-cache-api.php
CHANGED
@@ -5,7 +5,7 @@ if ( !defined( 'ABSPATH' ) ) {
|
|
5 |
}
|
6 |
|
7 |
define( 'W3TC', true );
|
8 |
-
define( 'W3TC_VERSION', '0.14.
|
9 |
define( 'W3TC_POWERED_BY', 'W3 Total Cache' );
|
10 |
define( 'W3TC_EMAIL', 'w3tc@w3-edge.com' );
|
11 |
define( 'W3TC_TEXT_DOMAIN', 'w3-total-cache' );
|
5 |
}
|
6 |
|
7 |
define( 'W3TC', true );
|
8 |
+
define( 'W3TC_VERSION', '0.14.2' );
|
9 |
define( 'W3TC_POWERED_BY', 'W3 Total Cache' );
|
10 |
define( 'W3TC_EMAIL', 'w3tc@w3-edge.com' );
|
11 |
define( 'W3TC_TEXT_DOMAIN', 'w3-total-cache' );
|
w3-total-cache.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/*
|
3 |
Plugin Name: W3 Total Cache
|
4 |
Description: The highest rated and most complete WordPress performance plugin. Dramatically improve the speed and user experience of your site. Add browser, page, object and database caching as well as minify and content delivery network (CDN) to WordPress.
|
5 |
-
Version: 0.14.
|
6 |
Plugin URI: https://www.boldgrid.com/totalcache/
|
7 |
Author: BoldGrid
|
8 |
Author URI: https://www.boldgrid.com/
|
2 |
/*
|
3 |
Plugin Name: W3 Total Cache
|
4 |
Description: The highest rated and most complete WordPress performance plugin. Dramatically improve the speed and user experience of your site. Add browser, page, object and database caching as well as minify and content delivery network (CDN) to WordPress.
|
5 |
+
Version: 0.14.2
|
6 |
Plugin URI: https://www.boldgrid.com/totalcache/
|
7 |
Author: BoldGrid
|
8 |
Author URI: https://www.boldgrid.com/
|