Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
LukasReschke opened this issue Oct 1, 2014 · 2 comments · Fixed by #11591
Closed

Comments

@LukasReschke
Copy link
Member

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.

@LukasReschke LukasReschke 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 Oct 1, 2014
@LukasReschke
Copy link
Member Author

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

@karlitschek
Copy link
Contributor

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

@LukasReschke LukasReschke added this to the ownCloud 8 milestone Oct 15, 2014
LukasReschke added a commit that referenced this issue Oct 15, 2014
This leads to the regeneration of the hash in case a single application is updated.

Fixes #11374
LukasReschke added a commit that referenced this issue Oct 16, 2014
This leads to the regeneration of the hash in case a single application is updated.

Fixes #11374
@DeepDiver1975 DeepDiver1975 modified the milestones: ownCloud 8, 8.0-current Jan 9, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Aug 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants