Skip to content

CSS/JS version parameter in templatelayout.php has to consider the app version #11374

Closed

Description

@LukasReschke

ownCloud offers the addStyle() and addScript() methods to app developers, using this method you can include Javascript or CSS files into the output.

For example:

OCP\Util::addStyle( "files", "files" );
OCP\Util::addscript( "files", "files" );

Will result in:

<link rel="stylesheet" href="/core/apps/files/css/files.css?v=07ac7cd13fd0eb1654ccdbd222b81437" type="text/css" media="screen" />
<script type="text/javascript" src="/core/apps/files/js/files.js?v=07ac7cd13fd0eb1654ccdbd222b81437"></script>

As you can see, a version parameter (?v=) is appended to the URL, this has the reason that browsers are caching the file and we want to ensure that always the newest file is delivered and there are no caching problems.

This version parameter is generated in lib/private/templatelayout.php as following:

$versionParameter = '?v=' . md5(implode(OC_Util::getVersion()));

The problem here is that it only considers the ownCloud version, but not the app version itself. Which means that independent apps might suffer from problems when calling addScript or addStyle and are being updated independently from the ownCloud version. In this case still the old hash would be used.

The solution here is to detect the version of the specified application and calculate the hash from the app version.

Activity

  1. changed the title [-]CSS version parameter in templatelayout.php has to consider the app version[/-] [+]CSS/JS version parameter in templatelayout.php has to consider the app version[/+] on Oct 1, 2014
  2. LukasReschke commented on Oct 1, 2014

    @LukasReschke
    ContributorAuthor

    @karlitschek Something to consider if we want to update apps in the future independently.

  3. karlitschek commented on Oct 1, 2014

    @karlitschek
    Contributor

    very good point. This should be indeed changed to use the core version plus the app version.

  4. added this to the milestone on Oct 15, 2014
  5. added a commit that references this issue on Oct 16, 2014
  6. modified the milestones: , on Jan 9, 2015
  7. locked as resolved and limited conversation to collaborators on Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions