Skip to content

Commit 2ce7cf7

Browse files
authored
mfunc fix (#1222)
* Fix issue with mfunc processing stripping the digit "1" if the constant is set to 1 or true. * Add a check to skip execution of mfunc/mclude code if the constant is set to 0, 1, or true.
1 parent eb2dab9 commit 2ce7cf7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Generic_Plugin.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ private function sanitize_dynamic_fragment_data( $data ) {
210210
* @return string
211211
*/
212212
private function strip_dynamic_fragment_tags_from_string( $value ) {
213-
if ( ! is_string( $value ) || ! defined( 'W3TC_DYNAMIC_SECURITY' ) || '' === W3TC_DYNAMIC_SECURITY ) {
213+
if ( ! is_string( $value ) || ! defined( 'W3TC_DYNAMIC_SECURITY' ) || empty( W3TC_DYNAMIC_SECURITY ) ) {
214214
return $value;
215215
}
216216

@@ -226,6 +226,11 @@ private function strip_dynamic_fragment_tags_from_string( $value ) {
226226
$value = $original;
227227
}
228228

229+
// The W3TC_DYNAMIC_SECURITY constant should be a unique string and not an int or boolean.
230+
if ( 1 === (int) W3TC_DYNAMIC_SECURITY ) {
231+
return $value;
232+
}
233+
229234
return str_replace( W3TC_DYNAMIC_SECURITY, '', $value );
230235
}
231236

PgCache_ContentGrabber.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,8 @@ public function _bad_behavior() {
20842084
* @return string The buffer with parsed dynamic content.
20852085
*/
20862086
public function _parse_dynamic( $buffer ) {
2087-
if ( ! defined( 'W3TC_DYNAMIC_SECURITY' ) ) {
2087+
// The W3TC_DYNAMIC_SECURITY constant should be a unique string and not an int or boolean.
2088+
if ( ! defined( 'W3TC_DYNAMIC_SECURITY' ) || empty( W3TC_DYNAMIC_SECURITY ) || 1 === (int) W3TC_DYNAMIC_SECURITY ) {
20882089
return $buffer;
20892090
}
20902091

0 commit comments

Comments
 (0)