diff --git a/build/update_stylesheet_querystrings.php b/build/update_stylesheet_querystrings.php new file mode 100644 index 0000000000..e3a3f8de15 --- /dev/null +++ b/build/update_stylesheet_querystrings.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('update_stylesheet_querystrings.php requires at least PHP 7.1.3'); +} + +// Usage: "$ php build/update_stylesheet_querystrings.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 ($match) use ($filepath) + { + $path = dirname($filepath) . DIRECTORY_SEPARATOR . $match['basename']; + $hash = sprintf('%08x', crc32(file_get_contents($path))); + + return 'hash=' . $hash; + }, + $old + ); + + if ($new !== $old) + { + file_put_contents($filepath, $new); + } +} diff --git a/phpBB/styles/prosilver/theme/stylesheet.css b/phpBB/styles/prosilver/theme/stylesheet.css index c402d563c6..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"); -@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?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");