Permalink
Browse files

Merge branch '3.4'

* 3.4:
  [Bridge\ProxyManager] Dont call __destruct() on non-instantiated services
  Consistently use 7 chars of sha256 for hash-based id generation
  Docblock improvement
  bumped Symfony version to 2.8.27
  updated VERSION for 2.8.26
  updated CHANGELOG for 2.8.26
  bumped Symfony version to 2.7.34
  updated VERSION for 2.7.33
  update CONTRIBUTORS for 2.7.33
  updated CHANGELOG for 2.7.33
  • Loading branch information...
2 parents 6cfb56f + 62bb068 commit d4f6b88561fa139a4651a820bfc2f58921baba41 @nicolas-grekas nicolas-grekas committed Aug 3, 2017
@@ -85,7 +85,7 @@ private function dumpXliff1($defaultLocale, MessageCatalogue $messages, $domain,
foreach ($messages->all($domain) as $source => $target) {
$translation = $dom->createElement('trans-unit');
- $translation->setAttribute('id', md5($source));
+ $translation->setAttribute('id', strtr(substr(base64_encode(hash('sha256', $source, true)), 0, 7), '/+', '._'));
$translation->setAttribute('resname', $source);
$s = $translation->appendChild($dom->createElement('source'));
@@ -145,7 +145,7 @@ private function dumpXliff2($defaultLocale, MessageCatalogue $messages, $domain,
foreach ($messages->all($domain) as $source => $target) {
$translation = $dom->createElement('unit');
- $translation->setAttribute('id', md5($source));
+ $translation->setAttribute('id', strtr(substr(base64_encode(hash('sha256', $source, true)), 0, 7), '/+', '._'));
$segment = $translation->appendChild($dom->createElement('segment'));
@@ -28,6 +28,8 @@ public function testDump()
$dumper->dump($catalogue, array('path' => $tempDir));
$this->assertFileExists($tempDir.'/messages.en.concrete');
+
+ @unlink($tempDir.'/messages.en.concrete');
}
public function testDumpCreatesNestedDirectoriesAndFile()
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="fr-FR" trgLang="en-US">
<file id="messages.en_US">
- <unit id="acbd18db4cc2f85cedef654fccc4a4d8">
+ <unit id="LCa0a2j">
<segment>
<source>foo</source>
<target>bar</target>
</segment>
</unit>
- <unit id="3c6e0b8a9c15224a8228b9a98ca1531d">
+ <unit id="LHDhK3o">
<segment>
<source>key</source>
<target order="1"></target>
</segment>
</unit>
- <unit id="18e6a493872558d949b4c16ea1fa6ab6">
+ <unit id="2DA_bnh">
<segment>
<source>key.with.cdata</source>
<target><![CDATA[<source> & <target>]]></target>
@@ -5,18 +5,18 @@
<tool tool-id="symfony" tool-name="Symfony"/>
</header>
<body>
- <trans-unit id="acbd18db4cc2f85cedef654fccc4a4d8" resname="foo">
+ <trans-unit id="LCa0a2j" resname="foo">
<source>foo</source>
<target>bar</target>
<note priority="1" from="bar">baz</note>
</trans-unit>
- <trans-unit id="3c6e0b8a9c15224a8228b9a98ca1531d" resname="key">
+ <trans-unit id="LHDhK3o" resname="key">
<source>key</source>
<target></target>
<note>baz</note>
<note>qux</note>
</trans-unit>
- <trans-unit id="18e6a493872558d949b4c16ea1fa6ab6" resname="key.with.cdata">
+ <trans-unit id="2DA_bnh" resname="key.with.cdata">
<source>key.with.cdata</source>
<target><![CDATA[<source> & <target>]]></target>
</trans-unit>
@@ -5,7 +5,7 @@
<tool tool-id="symfony" tool-name="Symfony"/>
</header>
<body>
- <trans-unit id="acbd18db4cc2f85cedef654fccc4a4d8" resname="foo">
+ <trans-unit id="LCa0a2j" resname="foo">
<source>foo</source>
<target state="needs-translation">bar</target>
</trans-unit>
@@ -5,7 +5,7 @@
<tool tool-id="foo" tool-name="foo" tool-version="0.0" tool-company="Foo"/>
</header>
<body>
- <trans-unit id="acbd18db4cc2f85cedef654fccc4a4d8" resname="foo">
+ <trans-unit id="LCa0a2j" resname="foo">
<source>foo</source>
<target>bar</target>
</trans-unit>
View
@@ -363,7 +363,7 @@ private function getFallbackContent(MessageCatalogue $catalogue)
private function getCatalogueCachePath($locale)
{
- return $this->cacheDir.'/catalogue.'.$locale.'.'.sha1(serialize($this->fallbackLocales)).'.php';
+ return $this->cacheDir.'/catalogue.'.$locale.'.'.strtr(substr(base64_encode(hash('sha256', serialize($this->fallbackLocales), true)), 0, 7), '/', '_').'.php';
}
private function doLoadCatalogue($locale)

0 comments on commit d4f6b88

Please sign in to comment.