diff --git a/lib/classes/media/Permalink/Adapter.class.php b/lib/classes/media/Permalink/Adapter.class.php
index 418a1d62ee..193f0135c3 100644
--- a/lib/classes/media/Permalink/Adapter.class.php
+++ b/lib/classes/media/Permalink/Adapter.class.php
@@ -146,14 +146,15 @@ class media_Permalink_Adapter implements media_Permalink_Interface, cache_cachea
{
$registry = registry::get_instance();
- return sprintf('%spermalink/v1/%d/%d/%s/%s.%s?token=%s',
+ return sprintf('%spermalink/v1/%d/%d/%s/%s.%s?token=%s&etag=%s',
$registry->get('GV_ServerName'),
$this->media_subdef->get_sbas_id(),
$this->media_subdef->get_record_id(),
$this->media_subdef->get_name(),
$this->get_label(),
pathinfo($this->media_subdef->get_file(), PATHINFO_EXTENSION),
- $this->get_token()
+ $this->get_token(),
+ $this->media_subdef->getEtag()
);
}
diff --git a/lib/classes/media/subdef.class.php b/lib/classes/media/subdef.class.php
index 45653030f1..ad85fc5301 100644
--- a/lib/classes/media/subdef.class.php
+++ b/lib/classes/media/subdef.class.php
@@ -229,7 +229,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
, 'height' => $this->height
, 'etag' => $this->etag
, 'path' => $this->path
- , 'url' => $this->url
+ , 'url' => $this->url . ($this->is_physically_present ? '?etag=' . $this->etag : '')
, 'file' => $this->file
, 'physically_present' => $this->is_physically_present
, 'is_substituted' => $this->is_substituted
diff --git a/templates/web/common/thumbnail.html b/templates/web/common/thumbnail.html
index 85ef7cd840..c9bd842fae 100644
--- a/templates/web/common/thumbnail.html
+++ b/templates/web/common/thumbnail.html
@@ -60,7 +60,7 @@
{% else %}
- {% set url = url ~ '?tag=' ~ thumbnail.getEtag() %}
diff --git a/tests/media/Permalink/media_Permalink_AdapterTest.php b/tests/media/Permalink/media_Permalink_AdapterTest.php
index 308eac74ce..7d5d5ac6f9 100644
--- a/tests/media/Permalink/media_Permalink_AdapterTest.php
+++ b/tests/media/Permalink/media_Permalink_AdapterTest.php
@@ -8,12 +8,14 @@ class media_Permalink_AdapterTest extends PhraseanetPHPUnitAbstract
* @var media_Permalink_Adapter
*/
static $object;
+ static $subdef;
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$databox = static::$records['record_1']->get_databox();
- static::$object = media_Permalink_Adapter::getPermalink($databox, static::$records['record_1']->get_subdef('document'));
+ static::$subdef = static::$records['record_1']->get_subdef('document');
+ static::$object = media_Permalink_Adapter::getPermalink($databox, static::$subdef);
}
public function testGet_label()
@@ -55,7 +57,8 @@ class media_Permalink_AdapterTest extends PhraseanetPHPUnitAbstract
. static::$records['record_1']->get_record_id()
. '/document/' . static::$object->get_label()
. '.' . pathinfo(static::$records['record_1']->get_subdef('document')->get_file(), PATHINFO_EXTENSION)
- . '?token=' . static::$object->get_token();
+ . '?token=' . static::$object->get_token()
+ . '&etag=' . static::$subdef->getEtag();
$this->assertEquals($url, static::$object->get_url($registry));
}
@@ -63,7 +66,8 @@ class media_Permalink_AdapterTest extends PhraseanetPHPUnitAbstract
public function testGet_Previewurl()
{
$databox = static::$records['record_1']->get_databox();
- $previewPermalink = media_Permalink_Adapter::getPermalink($databox, static::$records['record_1']->get_subdef('preview'));
+ $subdef = static::$records['record_1']->get_subdef('preview');
+ $previewPermalink = media_Permalink_Adapter::getPermalink($databox, $subdef);
$registry = registry::get_instance();
$url = $registry->get('GV_ServerName') . 'permalink/v1/'
@@ -71,7 +75,8 @@ class media_Permalink_AdapterTest extends PhraseanetPHPUnitAbstract
. static::$records['record_1']->get_record_id()
. '/preview/' . $previewPermalink->get_label()
. '.' . pathinfo(static::$records['record_1']->get_subdef('preview')->get_file(), PATHINFO_EXTENSION)
- . '?token=' . $previewPermalink->get_token();
+ . '?token=' . $previewPermalink->get_token()
+ . '&etag=' . $subdef->getEtag();
$this->assertEquals($url, $previewPermalink->get_url($registry));
}
@@ -83,7 +88,7 @@ class media_Permalink_AdapterTest extends PhraseanetPHPUnitAbstract
. static::$records['record_1']->get_sbas_id() . '/'
. static::$records['record_1']->get_record_id()
. '/document/'
- . '?token=' . static::$object->get_token();
+ . '?token=' . static::$object->get_token();
$this->assertEquals($url, static::$object->get_page($registry));
}