updated plugin W3 Total Cache version 2.7.0

This commit is contained in:
2024-03-28 09:40:06 +00:00
committed by Gitium
parent 60de585044
commit 218272bbcb
140 changed files with 3054 additions and 3013 deletions

View File

@ -9,19 +9,17 @@ class Minify_Core {
* Encode an array of files into a filename containing all files.
*/
static public function urls_for_minification_to_minify_filename( $files, $type ) {
$v = get_option( 'w3tc_minify' );
$minify_filenames = @json_decode( $v, true );
if ( !is_array( $minify_filenames ) )
$minify_filenames = array();
$files_string = json_encode( $files );
$key = substr( md5( $files_string ), 0, 5 );
// collision protection
if ( isset( $minify_filenames[$key] ) ) {
$files_stored = $minify_filenames[$key];
if ( json_encode( $files_stored ) != $files_string ) {
$key = md5( $files_string );
$key = self::urls_for_minification_to_minify_key( $files_string,
substr( md5( $files_string ), 0, 5 ) );
if ( is_null( $key ) ) {
// key collision (rare case), try full md5
$key = self::urls_for_minification_to_minify_key( $files_string,
md5( $files_string ) );
if ( is_null( $key ) ) {
// collision of full md5 - unprobable
return null;
}
}
@ -30,13 +28,26 @@ class Minify_Core {
'w3tc_minify_urls_for_minification_to_minify_filename',
$minify_filename, $files, $type );
$minify_filenames[$minify_filename] = $files;
update_option( 'w3tc_minify', json_encode( $minify_filenames ), false );
return $minify_filename;
}
/**
* Tries key for minified array of files
*/
static private function urls_for_minification_to_minify_key( $files_string, $key ) {
$v = get_option( 'w3tc_minify_' . $key );
$minify_filenames = @json_decode( $v, true );
if ( empty( $minify_filenames ) || !is_array( $minify_filenames ) ) {
update_option( 'w3tc_minify_' . $key, $files_string, false );
return $key;
}
if ( $v === $files_string ) {
return $key;
}
return null;
}
/**
* Decode a minify auto filename into an array of files.
@ -46,16 +57,12 @@ class Minify_Core {
* @return array
*/
static public function minify_filename_to_urls_for_minification( $filename, $type ) {
$v = get_option( 'w3tc_minify' );
$minify_filenames = @json_decode( $v, true );
if ( !is_array( $minify_filenames ) )
$minify_filenames = array();
$minify_filename = $filename . '.' . $type;
if ( !isset( $minify_filenames[$minify_filename] ) )
$v = get_option( 'w3tc_minify_' . $filename );
$urls_unverified = @json_decode( $v, true );
if ( !is_array( $urls_unverified ) ) {
return array();
}
$urls_unverified = $minify_filenames[$minify_filename];
$urls = array();
foreach ( $urls_unverified as $file ) {