use md5 for version instead of timestamp

This patch changes the way assets url are constructed: instead of a timestamp (which is always 1 in NixOS), it sets the md5 of the file.

Software
Roundcube
Tested software versions for the patch
Patch author
Immae
Patch license
GNU General Public License v3
Patch date
2022
Original sources
Patches
  • roundcube-1.4.15_md5.patch
    diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php
    index 0552b89c2..1b84e1b4e 100644
    --- a/program/include/rcmail_output_html.php
    +++ b/program/include/rcmail_output_html.php
    @@ -1013,13 +1013,13 @@ EOF;
             // use minified file if exists (not in development mode)
             if (!$this->devel_mode && !preg_match('/\.min\.' . $ext . '$/', $file)) {
                 $minified_file = substr($file, 0, strlen($ext) * -1) . 'min.' . $ext;
    -            if ($fs = @filemtime($this->assets_dir . $minified_file)) {
    -                return $minified_file . '?s=' . $fs;
    +            if ($fs = @md5_file($this->assets_dir . $minified_file)) {
    +                return $minified_file . '?s=' . substr($fs, 0, 6);
                 }
             }
     
    -        if ($fs = @filemtime($this->assets_dir . $file)) {
    -            $file .= '?s=' . $fs;
    +        if ($fs = @md5_file($this->assets_dir . $file)) {
    +            $file .= '?s=' . substr($fs, 0, 6);
             }
     
             return $file;