diff --git a/lib/classes/media/subdef.php b/lib/classes/media/subdef.php index 53b8b290bc..7f4f2739bd 100644 --- a/lib/classes/media/subdef.php +++ b/lib/classes/media/subdef.php @@ -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 */