From 39b3db9e278aee3a244f2f01c91650704620aac1 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Tue, 30 Jun 2020 23:50:56 +0200 Subject: [PATCH 1/7] [ticket/16543] Update query-string in stylesheet.css to 3.3.1 PHPBB3-16543 --- phpBB/styles/prosilver/theme/stylesheet.css | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/phpBB/styles/prosilver/theme/stylesheet.css b/phpBB/styles/prosilver/theme/stylesheet.css index c402d563c6..7c134b17a4 100644 --- a/phpBB/styles/prosilver/theme/stylesheet.css +++ b/phpBB/styles/prosilver/theme/stylesheet.css @@ -7,15 +7,15 @@ -------------------------------------------------------------- */ -@import url("normalize.css?v=3.3"); -@import url("base.css?v=3.3"); -@import url("utilities.css?v=3.3"); -@import url("common.css?v=3.3"); -@import url("links.css?v=3.3"); -@import url("content.css?v=3.3"); -@import url("buttons.css?v=3.3"); -@import url("cp.css?v=3.3"); -@import url("forms.css?v=3.3"); -@import url("icons.css?v=3.3"); -@import url("colours.css?v=3.3"); -@import url("responsive.css?v=3.3"); +@import url("normalize.css?v=3.3.1"); +@import url("base.css?v=3.3.1"); +@import url("utilities.css?v=3.3.1"); +@import url("common.css?v=3.3.1"); +@import url("links.css?v=3.3.1"); +@import url("content.css?v=3.3.1"); +@import url("buttons.css?v=3.3.1"); +@import url("cp.css?v=3.3.1"); +@import url("forms.css?v=3.3.1"); +@import url("icons.css?v=3.3.1"); +@import url("colours.css?v=3.3.1"); +@import url("responsive.css?v=3.3.1"); From bc869f8ec3f10dfc35b7568505ea4714f006f268 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Thu, 2 Jul 2020 23:01:11 +0200 Subject: [PATCH 2/7] [ticket/16543] Add script for automate it on builds PHPBB3-16543 --- build/patch_stylesheet_cache_busters.php | 54 ++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 build/patch_stylesheet_cache_busters.php diff --git a/build/patch_stylesheet_cache_busters.php b/build/patch_stylesheet_cache_busters.php new file mode 100644 index 0000000000..cc7db550f4 --- /dev/null +++ b/build/patch_stylesheet_cache_busters.php @@ -0,0 +1,54 @@ + +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +if (php_sapi_name() !== 'cli') +{ + die("This program must be run from the command line.\n"); +} + +if (version_compare(PHP_VERSION, '7.1.3', '<')) +{ + die('patch_stylesheet_cache_busters.php requires at least PHP 7.1.3'); +} + +// Usage: "$ php build/patch_stylesheet_cache_busters.php" +$targets = [dirname(dirname(__FILE__)) . '/phpBB/styles/prosilver/theme/stylesheet.css']; + +array_map('patch_glob', $targets); + +function patch_glob($glob): void +{ + array_map('patch_file', glob($glob)); +} + +function patch_file(string $filepath): void +{ + $file = file_get_contents($filepath); + $old = $file; + $new = preg_replace_callback( + '(^@import\\s+url\\([\'"](?\\w++\\.css)\\?\\K(?:hash|v)=[^\'"]++)m', + function ($m) use ($filepath) + { + $path = dirname($filepath) . DIRECTORY_SEPARATOR . $m['basename']; + $hash = sprintf('%08x', crc32(file_get_contents($path))); + + return 'hash=' . $hash; + }, + $old + ); + + if ($new !== $old) + { + file_put_contents($filepath, $new); + } +} From 3ce8510f88877b38391c43cb2c92cda4bb4a32c5 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Thu, 2 Jul 2020 23:21:31 +0200 Subject: [PATCH 3/7] [ticket/16543] Add script for automate it on builds PHPBB3-16543 --- ...tylesheet_cache_busters.php => stylesheet_cache_busters.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename build/{patch_stylesheet_cache_busters.php => stylesheet_cache_busters.php} (95%) diff --git a/build/patch_stylesheet_cache_busters.php b/build/stylesheet_cache_busters.php similarity index 95% rename from build/patch_stylesheet_cache_busters.php rename to build/stylesheet_cache_busters.php index cc7db550f4..7cc4b21153 100644 --- a/build/patch_stylesheet_cache_busters.php +++ b/build/stylesheet_cache_busters.php @@ -21,7 +21,7 @@ if (version_compare(PHP_VERSION, '7.1.3', '<')) die('patch_stylesheet_cache_busters.php requires at least PHP 7.1.3'); } -// Usage: "$ php build/patch_stylesheet_cache_busters.php" +// Usage: "$ php build/stylesheet_cache_busters.php" $targets = [dirname(dirname(__FILE__)) . '/phpBB/styles/prosilver/theme/stylesheet.css']; array_map('patch_glob', $targets); From b2affdff5b7ae6364fcf68831958c038dbb17454 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Thu, 2 Jul 2020 23:39:24 +0200 Subject: [PATCH 4/7] [ticket/16543] Add script for automate it on builds PHPBB3-16543 --- build/stylesheet_cache_busters.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/stylesheet_cache_busters.php b/build/stylesheet_cache_busters.php index 7cc4b21153..618f0090e5 100644 --- a/build/stylesheet_cache_busters.php +++ b/build/stylesheet_cache_busters.php @@ -18,7 +18,7 @@ if (php_sapi_name() !== 'cli') if (version_compare(PHP_VERSION, '7.1.3', '<')) { - die('patch_stylesheet_cache_busters.php requires at least PHP 7.1.3'); + die('stylesheet_cache_busters.php requires at least PHP 7.1.3'); } // Usage: "$ php build/stylesheet_cache_busters.php" From 39d700b87a4b013e420d21343c51f493ecfcca00 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Sun, 5 Jul 2020 01:47:06 +0200 Subject: [PATCH 5/7] [ticket/16543] Rename script PHPBB3-16543 --- ...t_cache_busters.php => update_stylesheet_querystrings.php} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename build/{stylesheet_cache_busters.php => update_stylesheet_querystrings.php} (89%) diff --git a/build/stylesheet_cache_busters.php b/build/update_stylesheet_querystrings.php similarity index 89% rename from build/stylesheet_cache_busters.php rename to build/update_stylesheet_querystrings.php index 618f0090e5..573d1fceba 100644 --- a/build/stylesheet_cache_busters.php +++ b/build/update_stylesheet_querystrings.php @@ -18,10 +18,10 @@ if (php_sapi_name() !== 'cli') if (version_compare(PHP_VERSION, '7.1.3', '<')) { - die('stylesheet_cache_busters.php requires at least PHP 7.1.3'); + die('update_stylesheet_querystrings.php requires at least PHP 7.1.3'); } -// Usage: "$ php build/stylesheet_cache_busters.php" +// Usage: "$ php build/update_stylesheet_querystrings.php" $targets = [dirname(dirname(__FILE__)) . '/phpBB/styles/prosilver/theme/stylesheet.css']; array_map('patch_glob', $targets); From 87dfa9a061d941e5777ab78ece61404c67193343 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Sun, 5 Jul 2020 20:48:07 +0200 Subject: [PATCH 6/7] [ticket/16543] Use hashes in query-strings PHPBB3-16543 --- phpBB/styles/prosilver/theme/stylesheet.css | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/phpBB/styles/prosilver/theme/stylesheet.css b/phpBB/styles/prosilver/theme/stylesheet.css index 7c134b17a4..dd30ee42da 100644 --- a/phpBB/styles/prosilver/theme/stylesheet.css +++ b/phpBB/styles/prosilver/theme/stylesheet.css @@ -7,15 +7,15 @@ -------------------------------------------------------------- */ -@import url("normalize.css?v=3.3.1"); -@import url("base.css?v=3.3.1"); -@import url("utilities.css?v=3.3.1"); -@import url("common.css?v=3.3.1"); -@import url("links.css?v=3.3.1"); -@import url("content.css?v=3.3.1"); -@import url("buttons.css?v=3.3.1"); -@import url("cp.css?v=3.3.1"); -@import url("forms.css?v=3.3.1"); -@import url("icons.css?v=3.3.1"); -@import url("colours.css?v=3.3.1"); -@import url("responsive.css?v=3.3.1"); +@import url("normalize.css?hash=48eb3f89"); +@import url("base.css?hash=3a7fafb1"); +@import url("utilities.css?hash=1034bac8"); +@import url("common.css?hash=009a715d"); +@import url("links.css?hash=da040ebb"); +@import url("content.css?hash=d7d65e66"); +@import url("buttons.css?hash=15c14833"); +@import url("cp.css?hash=5cc9ac0c"); +@import url("forms.css?hash=18ee8211"); +@import url("icons.css?hash=ed93c566"); +@import url("colours.css?hash=3b03ccfa"); +@import url("responsive.css?hash=438ff202"); From 80a6a58a84bfc928b5f56258ab865172449f59a5 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Wed, 8 Jul 2020 23:19:12 +0200 Subject: [PATCH 7/7] [ticket/16543] Add script for automate it on builds PHPBB3-16543 --- build/update_stylesheet_querystrings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/update_stylesheet_querystrings.php b/build/update_stylesheet_querystrings.php index 573d1fceba..e3a3f8de15 100644 --- a/build/update_stylesheet_querystrings.php +++ b/build/update_stylesheet_querystrings.php @@ -37,9 +37,9 @@ function patch_file(string $filepath): void $old = $file; $new = preg_replace_callback( '(^@import\\s+url\\([\'"](?\\w++\\.css)\\?\\K(?:hash|v)=[^\'"]++)m', - function ($m) use ($filepath) + function ($match) use ($filepath) { - $path = dirname($filepath) . DIRECTORY_SEPARATOR . $m['basename']; + $path = dirname($filepath) . DIRECTORY_SEPARATOR . $match['basename']; $hash = sprintf('%08x', crc32(file_get_contents($path))); return 'hash=' . $hash;