User tests: Successful: Unsuccessful:
My proposal to implement @brianteeman suggestion of refresh assets after version updates.
This method creates two new methods to JDocument
to allow to load versionable assets:
public function addScriptVersion($url, $version = null, $type = "text/javascript", $defer = false, $async = false)
and:
public function addStyleSheetVersion($url, $version = null, $type = "text/css", $media = null, $attribs = array())
The CMS is able to handle assets versions automatically but third part developers can also specify the assets versions.
Example to allow the system to automatically add version:
$doc->addScriptVersion('templates/' . $this->template . '/js/template.js');
Example to specify the asset version manually:
$doc->addScriptVersion('templates/' . $this->template . '/js/template.js', '1,87');
The automatic version is generated only:
So in the normal mode it would be created only 1 time per user session instead of 1 per page load. The version is built with:
$mediaTag = md5($this->getLongVersion() . $config->get('secret') . $date->toSql());
It uses Joomla! version + secret string in configuration + current date + time.
It also includes one extra check to not add mediatag to assets that already contain it. So in most cases in can directly replace addScript
& addStylesheet
methods.
This modifies JFactory to add the mediatag on document creation. I saw that JFactory is already using JVersion so it doesn't add additional dependencies. But with this same method we can do it outside JFactory (for example inside a template) with:
$doc->setMediatag('23424235346456');
Anyone can flush assets cache with:
$app = JFactory::getApplication()->flushAssets();
This pull request already includes the code to refresh assets in:
finaliseUpgrade()
method triggered after upgrading joomla.install()
, discover_install()
& uninstall()
methods.Feature tracker issue:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=31602
Google group discussion (please send your comments there to avoid duplicated discussions):
https://groups.google.com/forum/#!topic/joomla-dev-cms/81ZQ94MCV9A
I've merged and rebased it vs the latest master branch to ensure it's still mergeable with Travis approval.
@phproberto Could you update this?
I have updated the pull request with:
generateMediaVersion()
andrefreshMediaVersion()
to ease tests and use of media version by third part extension developers.JLibraryHelper
Tests
Update Joomla!
Install extension
Uninstall extension
Fix database