Skip to content

Commit

Permalink
Super cache: check that is_utf8_charset exists (#38383)
Browse files Browse the repository at this point in the history
* Check for is_utf8_charset, WP 6.6 bug

* changelog

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/9978142104

Upstream-Ref: Automattic/jetpack@b4e1648
  • Loading branch information
donnchawp authored and matticbot committed Jul 17, 2024
1 parent f5ffb63 commit ad4f723
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ This is an alpha version! The changes listed here are not final.
### Removed
- General: update WordPress version requirements to WordPress 6.5.

### Fixed
- WP Super Cache: fixed problem with is_utf8_charset missing in WP 6.6

## [1.12.3] - 2024-07-10
### Fixed
- Don't delete the log viewer when doing garbage collection [#38276]
Expand Down
8 changes: 4 additions & 4 deletions wp-cache-phase2.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ function wp_cache_serve_cache_file() {
} else {
header( 'Cache-Control: max-age=3, must-revalidate' );
}
$size = function_exists( 'mb_strlen' ) ? mb_strlen( $cachefiledata, '8bit' ) : strlen( $cachefiledata );
$size = ( function_exists( 'mb_strlen' ) && function_exists( 'is_utf8_charset' ) ) ? mb_strlen( $cachefiledata, '8bit' ) : strlen( $cachefiledata );
if ( $wp_cache_gzip_encoding ) {
if ( isset( $wpsc_served_header ) && $wpsc_served_header ) {
header( 'X-WP-Super-Cache: Served supercache gzip file from PHP' );
Expand Down Expand Up @@ -356,7 +356,7 @@ function wp_cache_serve_cache_file() {
6,
FORCE_GZIP
);
$size = function_exists( 'mb_strlen' ) ? mb_strlen( $cache, '8bit' ) : strlen( $cache );
$size = ( function_exists( 'mb_strlen' ) && function_exists( 'is_utf8_charset' ) ) ? mb_strlen( $cache, '8bit' ) : strlen( $cache );
wp_cache_debug( 'Sending Header: Content-Length: ' . $size );
header( 'Content-Length: ' . $size );
}
Expand Down Expand Up @@ -2441,7 +2441,7 @@ function wp_cache_get_ob( &$buffer ) {
wp_cache_debug( 'Gzipping dynamic buffer for display.', 5 );
wp_cache_add_to_buffer( $buffer, 'Compression = gzip' );
$gzdata = gzencode( $buffer, 6, FORCE_GZIP );
$gzsize = function_exists( 'mb_strlen' ) ? mb_strlen( $gzdata, '8bit' ) : strlen( $gzdata );
$gzsize = ( function_exists( 'mb_strlen' ) && function_exists( 'is_utf8_charset' ) ) ? mb_strlen( $gzdata, '8bit' ) : strlen( $gzdata );
}
} else {
if ( defined( 'WPSC_VARY_HEADER' ) ) {
Expand All @@ -2460,7 +2460,7 @@ function wp_cache_get_ob( &$buffer ) {
wp_cache_debug( 'Gzipping buffer.', 5 );
wp_cache_add_to_buffer( $buffer, 'Compression = gzip' );
$gzdata = gzencode( $buffer, 6, FORCE_GZIP );
$gzsize = function_exists( 'mb_strlen' ) ? mb_strlen( $gzdata, '8bit' ) : strlen( $gzdata );
$gzsize = ( function_exists( 'mb_strlen' ) && function_exists( 'is_utf8_charset' ) ) ? mb_strlen( $gzdata, '8bit' ) : strlen( $gzdata );

$wp_cache_meta['headers']['Content-Encoding'] = 'Content-Encoding: ' . $wp_cache_gzip_encoding;
// Return uncompressed data & store compressed for later use
Expand Down

0 comments on commit ad4f723

Please sign in to comment.