diff --git a/UPGRADE-3.x.md b/UPGRADE-3.x.md index 17046bb01..eea740408 100644 --- a/UPGRADE-3.x.md +++ b/UPGRADE-3.x.md @@ -8,6 +8,7 @@ UPGRADE FROM 3.x to 3.x Added implementation for `Gaufrette\Adapter\FileFactory` and `Gaufrette\Adapter\StreamFactory`. Method `createFileStream()` is deprecated in favor of `createStream()`. +Argument 3 (`?array $metadata = null`) in method `write()` is deprecated. ### Sonata\MediaBundle\Thumbnail\ResizableThumbnailInterface diff --git a/src/Filesystem/Replicate.php b/src/Filesystem/Replicate.php index 220fea2e7..ccb392fbd 100644 --- a/src/Filesystem/Replicate.php +++ b/src/Filesystem/Replicate.php @@ -108,13 +108,24 @@ public function exists($key) return $this->primary->exists($key); } + /** + * NEXT_MAJOR: Remove argument 3. + */ public function write($key, $content, ?array $metadata = null) { + if (3 === \func_num_args()) { + @trigger_error(sprintf( + 'Argument 3 in "%s()" method is deprecated since sonata-project/media-bundle 3.x' + .' and will be removed in version 4.0.', + __METHOD__ + ), \E_USER_DEPRECATED); + } + $ok = true; $return = false; try { - $return = $this->primary->write($key, $content, $metadata); + $return = $this->primary->write($key, $content); } catch (\Exception $e) { if ($this->logger) { $this->logger->critical(sprintf('Unable to write %s, error: %s', $key, $e->getMessage())); @@ -124,7 +135,7 @@ public function write($key, $content, ?array $metadata = null) } try { - $return = $this->secondary->write($key, $content, $metadata); + $return = $this->secondary->write($key, $content); } catch (\Exception $e) { if ($this->logger) { $this->logger->critical(sprintf('Unable to write %s, error: %s', $key, $e->getMessage()));