Merge pull request #3879 from alchemy-fr/PHRAS-3541-rotation-nok

PHRAS-3541 merge prod - Image rotation NOK - ETAG is not renew - File is correctly rotated but not invalidate in browser cache.
This commit is contained in:
Nicolas Maillat
2021-10-15 11:44:06 +02:00
committed by GitHub

View File

@@ -362,11 +362,10 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
public function getEtag()
{
if (!$this->etag && $this->is_physically_present()) {
if ((!$this->etag && $this->is_physically_present())) {
$file = new SplFileInfo($this->getRealPath());
if ($file->isFile()) {
$this->setEtag(md5($file->getRealPath() . $file->getMTime()));
$this->generateEtag($file);
}
}
@@ -573,7 +572,11 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
$this->width = $media->getWidth();
$this->height = $media->getHeight();
return $this->save();
// generate a new etag after rotation
$file = new SplFileInfo($this->getRealPath());
$this->generateEtag($file); // with repository save
return $this;
}
/**
@@ -799,6 +802,14 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
return $this->app['phraseanet.h264']->getUrl($this->getRealPath());
}
/**
* @param SplFileInfo $file
*/
private function generateEtag(SplFileInfo $file)
{
$this->setEtag(md5($file->getRealPath() . $file->getMTime()));
}
/**
* @return $this
*/