-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Translation][Writer] avoid calling setBackup if the dumper is not FileDumper #16912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
aitboudad
commented
Dec 8, 2015
Q | A |
---|---|
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | ~ |
License | MIT |
Doc PR | n/a |
@@ -45,7 +46,9 @@ public function addDumper($format, DumperInterface $dumper) | ||
public function disableBackup() | ||
{ | ||
foreach ($this->dumpers as $dumper) { | ||
$dumper->setBackup(false); | ||
if ($dumper instanceof FileDumper) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using method_exists()
here instead to support users who create their own dumpers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
b4f2a7c
to
6c700c1
Compare
👍 Status: Reviewed |
@@ -13,6 +13,7 @@ | ||
|
||
use Symfony\Component\Translation\MessageCatalogue; | ||
use Symfony\Component\Translation\Dumper\DumperInterface; | ||
use Symfony\Component\Translation\Dumper\FileDumper; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should now be removed again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed thanks!
6c700c1
to
6c43dc0
Compare
|
||
$writer = new TranslationWriter(); | ||
$writer->addDumper('test', $dumper); | ||
$writer->writeTranslations(new MessageCatalogue([]), 'test'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I missed that but tests are failing: We cannot use the short array syntax here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should work now, I'll pay more attention next time ;)
Status: Needs work |
… instance of FileDumper.
6c43dc0
to
369b2d4
Compare
Would it make sense to create an interface for setBackup on 3.1? method_exists is quite fragile imho |
Thank you @aitboudad. |
…r is not FileDumper (aitboudad) This PR was merged into the 2.7 branch. Discussion ---------- [Translation][Writer] avoid calling setBackup if the dumper is not FileDumper | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | n/a Commits ------- 369b2d4 [Translation][Writer] avoid calling setBackup if the dumper is not an instance of FileDumper.
This PR was merged into the 3.1-dev branch. Discussion ---------- [Translation] deprecate the backup feature | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #16912 (comment) | License | MIT | Doc PR | Commits ------- 6c3ddf1 [Translation] deprecate the backup feature