Skip to content

Commit

Permalink
WP Super Cache: fix the output buffer check, and make logs pre-format…
Browse files Browse the repository at this point in the history
…ted to emphasize this log event (#36158)

* Make logs prettier, and fix OB level check

* changelog

* Just moving text around

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/8172297802
  • Loading branch information
donnchawp authored and matticbot committed Mar 6, 2024
1 parent 8d79470 commit 98e869e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ This is an alpha version! The changes listed here are not final.
- WP Super Cache - fix the wp_super_cache_clear_post_cache so the homepage cache isn't deleted too.
- WP Super Cache: bail if the request uri isn't set. It means the plugin isn't configured yet.
- WP Super Cache: don't create an output buffer if there's already one active
- WP Super Cache: fix the output buffer check, and make debug logs pre-formatted.

## [1.11.0] - 2023-11-08
### Added
Expand Down
20 changes: 13 additions & 7 deletions wp-cache-phase2.php
Original file line number Diff line number Diff line change
Expand Up @@ -1297,9 +1297,12 @@ function wpsc_create_debug_log( $filename = '', $username = '' ) {
}
}
}
echo "<pre>";
foreach( $debug_log as $line ) {
echo htmlspecialchars( $line ) . "<br />";
}';
echo htmlspecialchars( $line );
}
echo "</pre>";
';
fwrite( $fp, $msg );
fclose( $fp );
}
Expand Down Expand Up @@ -1512,14 +1515,17 @@ function wp_cache_phase2() {
return false;
}

if ( ob_get_level() > 0 ) {
if ( ob_get_level() > 1 ) {
global $wp_super_cache_late_init;
$ob_warning = 'Already in an output buffer. Check your plugins, themes, mu-plugins, and other custom code. Exit.';
wp_cache_debug( '***********************************************************************************' );
wp_cache_debug( '* An extra output buffer has been detected. Check your plugins, themes, *' );
wp_cache_debug( '* mu-plugins, and other custom code as this may interfere with caching. *' );

if ( isset( $wp_super_cache_late_init ) && $wp_super_cache_late_init ) {
$ob_warning = 'Late init enabled. Disable it. ' . $ob_warning;
wp_cache_debug( '* Late init is enabled. This allows third-party code to run before WP Super Cache *' );
wp_cache_debug( '* sets up an output buffer. That code may have set up the output buffer. *' );
}
wp_cache_debug( 'wp_cache_phase2: ' . $ob_warning );
return;
wp_cache_debug( '***********************************************************************************' );
}

wp_cache_debug( 'In WP Cache Phase 2', 5 );
Expand Down

0 comments on commit 98e869e

Please sign in to comment.