From 3a03de0787b07b0af046a65f19eb867ca5c53030 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 21 May 2017 11:15:41 +0200 Subject: [PATCH] [Translation] remove deprecated features --- .../Component/Translation/CHANGELOG.md | 5 ++++ .../Translation/Dumper/FileDumper.php | 23 ++++++------------- .../Tests/Dumper/FileDumperTest.php | 23 ------------------- .../Translation/Writer/TranslationWriter.php | 1 + 4 files changed, 13 insertions(+), 39 deletions(-) diff --git a/src/Symfony/Component/Translation/CHANGELOG.md b/src/Symfony/Component/Translation/CHANGELOG.md index 349faceb0c8f..033b623e1b91 100644 --- a/src/Symfony/Component/Translation/CHANGELOG.md +++ b/src/Symfony/Component/Translation/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +4.0.0 +----- + + * removed the backup feature of the `FileDumper` class + 3.2.0 ----- diff --git a/src/Symfony/Component/Translation/Dumper/FileDumper.php b/src/Symfony/Component/Translation/Dumper/FileDumper.php index b2b50cfc9470..51b111821c8c 100644 --- a/src/Symfony/Component/Translation/Dumper/FileDumper.php +++ b/src/Symfony/Component/Translation/Dumper/FileDumper.php @@ -17,7 +17,6 @@ /** * FileDumper is an implementation of DumperInterface that dump a message catalogue to file(s). - * Performs backup of already existing files. * * Options: * - path (mandatory): the directory where the files should be saved @@ -33,13 +32,6 @@ abstract class FileDumper implements DumperInterface */ protected $relativePathTemplate = '%domain%.%locale%.%extension%'; - /** - * Make file backup before the dump. - * - * @var bool - */ - private $backup = true; - /** * Sets the template for the relative paths to files. * @@ -57,7 +49,12 @@ public function setRelativePathTemplate($relativePathTemplate) */ public function setBackup($backup) { - $this->backup = $backup; + if (false !== $backup) { + throw new \LogicException('The backup feature is no longer supported.'); + } + + // the method is only present to not break BC + // to be deprecated in 4.1 } /** @@ -71,14 +68,8 @@ public function dump(MessageCatalogue $messages, $options = array()) // save a file for each domain foreach ($messages->getDomains() as $domain) { - // backup $fullpath = $options['path'].'/'.$this->getRelativePath($domain, $messages->getLocale()); - if (file_exists($fullpath)) { - if ($this->backup) { - @trigger_error('Creating a backup while dumping a message catalogue is deprecated since version 3.1 and will be removed in 4.0. Use TranslationWriter::disableBackup() to disable the backup.', E_USER_DEPRECATED); - copy($fullpath, $fullpath.'~'); - } - } else { + if (!file_exists($fullpath)) { $directory = dirname($fullpath); if (!file_exists($directory) && !@mkdir($directory, 0777, true)) { throw new RuntimeException(sprintf('Unable to create directory "%s".', $directory)); diff --git a/src/Symfony/Component/Translation/Tests/Dumper/FileDumperTest.php b/src/Symfony/Component/Translation/Tests/Dumper/FileDumperTest.php index 9ed4c91eca4c..7c734fc169bc 100644 --- a/src/Symfony/Component/Translation/Tests/Dumper/FileDumperTest.php +++ b/src/Symfony/Component/Translation/Tests/Dumper/FileDumperTest.php @@ -30,29 +30,6 @@ public function testDump() $this->assertFileExists($tempDir.'/messages.en.concrete'); } - /** - * @group legacy - */ - public function testDumpBackupsFileIfExisting() - { - $tempDir = sys_get_temp_dir(); - $file = $tempDir.'/messages.en.concrete'; - $backupFile = $file.'~'; - - @touch($file); - - $catalogue = new MessageCatalogue('en'); - $catalogue->add(array('foo' => 'bar')); - - $dumper = new ConcreteFileDumper(); - $dumper->dump($catalogue, array('path' => $tempDir)); - - $this->assertFileExists($backupFile); - - @unlink($file); - @unlink($backupFile); - } - public function testDumpCreatesNestedDirectoriesAndFile() { $tempDir = sys_get_temp_dir(); diff --git a/src/Symfony/Component/Translation/Writer/TranslationWriter.php b/src/Symfony/Component/Translation/Writer/TranslationWriter.php index 901a8894e1c4..6c10fb2e82ca 100644 --- a/src/Symfony/Component/Translation/Writer/TranslationWriter.php +++ b/src/Symfony/Component/Translation/Writer/TranslationWriter.php @@ -46,6 +46,7 @@ public function addDumper($format, DumperInterface $dumper) */ public function disableBackup() { + // to be deprecated in 4.1 foreach ($this->dumpers as $dumper) { if (method_exists($dumper, 'setBackup')) { $dumper->setBackup(false);