]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add app version to JS and CSS
authorLukas Reschke <lukas@owncloud.com>
Wed, 15 Oct 2014 09:23:42 +0000 (11:23 +0200)
committerLukas Reschke <lukas@owncloud.com>
Wed, 15 Oct 2014 12:00:20 +0000 (14:00 +0200)
This leads to the regeneration of the hash in case a single application is updated.

Fixes https://github.com/owncloud/core/issues/11374

lib/private/templatelayout.php

index e9172fd2da551ea9f372739b587691cdbab637f1..0f8c056139b25f54b859cf95d89bba0ba2a30475 100644 (file)
@@ -14,6 +14,8 @@ use Assetic\Filter\CssImportFilter;
 
 class OC_TemplateLayout extends OC_Template {
 
+       private static $versionHash = '';
+
        /**
         * @param string $renderas
         * @param string $appid application id
@@ -70,26 +72,25 @@ class OC_TemplateLayout extends OC_Template {
                        parent::__construct('core', 'layout.base');
                }
 
-               $versionParameter = '?v=' . md5(implode(OC_Util::getVersion()));
+               if(empty(self::$versionHash)) {
+                       self::$versionHash = md5(implode(',', OC_App::getAppVersions()));
+               }
+               
                $useAssetPipeline = $this->isAssetPipelineEnabled();
                if ($useAssetPipeline) {
-
-                       $this->append( 'jsfiles', OC_Helper::linkToRoute('js_config') . $versionParameter);
-
+                       $this->append( 'jsfiles', OC_Helper::linkToRoute('js_config', array('v' => self::$versionHash)));
                        $this->generateAssets();
-
                } else {
-
                        // Add the js files
                        $jsfiles = self::findJavascriptFiles(OC_Util::$scripts);
                        $this->assign('jsfiles', array(), false);
                        if (OC_Config::getValue('installed', false) && $renderas!='error') {
-                               $this->append( 'jsfiles', OC_Helper::linkToRoute('js_config') . $versionParameter);
+                               $this->append( 'jsfiles', OC_Helper::linkToRoute('js_config', array('v' => self::$versionHash)));
                        }
                        foreach($jsfiles as $info) {
                                $web = $info[1];
                                $file = $info[2];
-                               $this->append( 'jsfiles', $web.'/'.$file . $versionParameter);
+                               $this->append( 'jsfiles', $web.'/'.$file . '?v=' . self::$versionHash);
                        }
 
                        // Add the css files
@@ -99,7 +100,7 @@ class OC_TemplateLayout extends OC_Template {
                                $web = $info[1];
                                $file = $info[2];
 
-                               $this->append( 'cssfiles', $web.'/'.$file . $versionParameter);
+                               $this->append( 'cssfiles', $web.'/'.$file . '?v=' . self::$versionHash);
                        }
                }
        }