Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 556ca0c

Browse files
committed
Merge branch '2.1' into 2.2
* 2.1: Options small typo [Console] fixed unparsed StringInput tokens [TwigBridge] fixed trans twig extractor [DomCrawler] fix handling of schemes by Link::getUri() [Console] Fixed comment [TwigBridge] fixed the translator extractor that were not trimming the text in trans tags (closes #7056) Fixed handling absent href attribute in base tag added a DebuClassLoader::findFile() method to make the wrapping less invasive fixed CHANGELOG bumped Symfony version to 2.1.9-DEV updated VERSION for 2.1.8 updated CHANGELOG for 2.1.8 StringInput resets the given options. Conflicts: src/Symfony/Component/HttpKernel/Kernel.php
2 parents ea5c7f1 + 08757db commit 556ca0c

18 files changed

+305
-17
lines changed

CHANGELOG-2.1.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,37 @@ in 2.1 minor versions.
77
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
88
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.1.0...v2.1.1
99

10+
* 2.1.8 (2013-02-23)
11+
12+
* b2080c4: [HttpFoundation] Remove Cache-Control when using https download via IE<9 (fixes #6750)
13+
* b7bd630: [Form] Fixed TimeType not to render a "size" attribute in select tags
14+
* 368f62f: Expanded fault-tolerance for unusual cookie dates
15+
* cb03074: [DomCrawler] lowered parsed protocol string (fixes #6986)
16+
* 3e40c17: [HttpKernel] fixed locale management when exiting sub-requests
17+
* 179cd58: [Process] Fix regression introduced in #6620 / 880da01c49a9255f5022ab7e18bca38c18f56370, fixes #7082
18+
* 18b139d: [FrameworkBundle] tweaked reference dumper command (see #7093)
19+
* 0eff68f: Fix REMOTE_ADDR for cached subrequests
20+
* 5e8d844: [Process] Warn user with a useful message when tmpfile() failed
21+
* 42d3c4c: added support for the X-Forwarded-For header (closes #6982, closes #7000)
22+
* 6a9c510: fixed the IP address in HttpCache when calling the backend
23+
* 87f3db7: [EventDispathcer] Fix removeListener
24+
* e0637fa: [DependencyInjection] Add clone for resources which were introduced in 2.1
25+
* bd0ad92: [DependencyInjection] Allow frozen containers to be dumped to graphviz
26+
* 83e9558: Fix 'undefined index' error, when entering scope recursively
27+
* 3615e19: [Security] fixed session creation on login (closes #7011)
28+
* a12744e: Add dot character `.` to legal mime subtype regular expression
29+
* e50d333: [HttpKernel] fixed the creation of the Profiler directory
30+
* ddf4678: [HttpFoundation] fixed the creation of sub-requests under some circumstancies (closes #6923, closes #6936)
31+
* 8ca00c5: [Security] fixed session creation when none is needed (closes #6917)
32+
* 74f2fcf: fixed a circular call (closes #6864)
33+
* 6f71948: [Yaml] fixed wrong merge (indentation default is 4 as of 2.1)
34+
* 4119caf: [DependencyInjection] fixed the creation of synthetic services in ContainerBuilder
35+
* 11aaa2e: Added an error message in the DebugClassLoader when using / instead of \.
36+
* ce38069: [FrameworkBundle] fixed Client::doRequest that must call its parent method (closes #6737)
37+
* 53ccc2c: [Yaml] fixed ignored text when parsing an inlined mapping or sequence (closes #6786)
38+
* ab0385c: [Yaml] fixed #6773
39+
* fea20b7: [Yaml] fixed #6770
40+
1041
* 2.1.7 (2013-01-17)
1142

1243
* e17e232: [Yaml] fixed default value

src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,17 @@ public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env)
3333
}
3434

3535
if ($node instanceof TransDefaultDomainNode) {
36-
$var = $env->getParser()->getVarName();
37-
$name = new \Twig_Node_Expression_AssignName($var, $node->getLine());
38-
$this->domain = new \Twig_Node_Expression_Name($var, $node->getLine());
36+
if ($node->getNode('expr') instanceof \Twig_Node_Expression_Constant) {
37+
$this->domain = $node->getNode('expr');
3938

40-
return new \Twig_Node_Set(false, new \Twig_Node(array($name)), new \Twig_Node(array($node->getNode('expr'))), $node->getLine());
39+
return $node;
40+
} else {
41+
$var = $env->getParser()->getVarName();
42+
$name = new \Twig_Node_Expression_AssignName($var, $node->getLine());
43+
$this->domain = new \Twig_Node_Expression_Name($var, $node->getLine());
44+
45+
return new \Twig_Node_Set(false, new \Twig_Node(array($name)), new \Twig_Node(array($node->getNode('expr'))), $node->getLine());
46+
}
4147
}
4248

4349
if (null === $this->domain) {
@@ -68,6 +74,10 @@ public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env)
6874
*/
6975
public function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env)
7076
{
77+
if ($node instanceof TransDefaultDomainNode) {
78+
return false;
79+
}
80+
7181
return $node;
7282
}
7383

@@ -76,6 +86,6 @@ public function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env)
7686
*/
7787
public function getPriority()
7888
{
79-
return 0;
89+
return -10;
8090
}
8191
}

src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121
class TranslationNodeVisitor implements \Twig_NodeVisitorInterface
2222
{
23+
const UNDEFINED_DOMAIN = '_undefined';
24+
2325
private $enabled = false;
2426
private $messages = array();
2527

@@ -57,7 +59,7 @@ public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env)
5759
// extract constant nodes with a trans filter
5860
$this->messages[] = array(
5961
$node->getNode('node')->getAttribute('value'),
60-
$node->getNode('arguments')->hasNode(1) ? $node->getNode('arguments')->getNode(1)->getAttribute('value') : null,
62+
$this->getReadDomainFromArguments($node->getNode('arguments'), 1),
6163
);
6264
} elseif (
6365
$node instanceof \Twig_Node_Expression_Filter &&
@@ -67,13 +69,13 @@ public function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env)
6769
// extract constant nodes with a trans filter
6870
$this->messages[] = array(
6971
$node->getNode('node')->getAttribute('value'),
70-
$node->getNode('arguments')->hasNode(2) ? $node->getNode('arguments')->getNode(2)->getAttribute('value') : null,
72+
$this->getReadDomainFromArguments($node->getNode('arguments'), 2),
7173
);
7274
} elseif ($node instanceof TransNode) {
7375
// extract trans nodes
7476
$this->messages[] = array(
7577
$node->getNode('body')->getAttribute('data'),
76-
null === $node->getNode('domain') ? 'messages' : $node->getNode('domain')->getAttribute('value'),
78+
$this->getReadDomainFromNode($node->getNode('domain')),
7779
);
7880
}
7981

@@ -93,6 +95,43 @@ public function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env)
9395
*/
9496
public function getPriority()
9597
{
96-
return -10;
98+
return 0;
99+
}
100+
101+
/**
102+
* @param \Twig_Node $arguments
103+
* @param int $index
104+
*
105+
* @return string|null
106+
*/
107+
private function getReadDomainFromArguments(\Twig_Node $arguments, $index)
108+
{
109+
if ($arguments->hasNode('domain')) {
110+
$argument = $arguments->getNode('domain');
111+
} elseif ($arguments->hasNode($index)) {
112+
$argument = $arguments->getNode($index);
113+
} else {
114+
return null;
115+
}
116+
117+
return $this->getReadDomainFromNode($argument);
118+
}
119+
120+
/**
121+
* @param \Twig_Node $node
122+
*
123+
* @return string|null
124+
*/
125+
private function getReadDomainFromNode(\Twig_Node $node = null)
126+
{
127+
if (null === $node) {
128+
return null;
129+
}
130+
131+
if ($node instanceof \Twig_Node_Expression_Constant) {
132+
return $node->getAttribute('value');
133+
}
134+
135+
return self::UNDEFINED_DOMAIN;
97136
}
98137
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace Symfony\Bridge\Twig\Tests\NodeVisitor;
4+
5+
use Symfony\Bridge\Twig\NodeVisitor\TranslationDefaultDomainNodeVisitor;
6+
use Symfony\Bridge\Twig\NodeVisitor\TranslationNodeVisitor;
7+
use Symfony\Bridge\Twig\Tests\TestCase;
8+
9+
class TranslationDefaultDomainNodeVisitorTest extends TestCase
10+
{
11+
private static $message = 'message';
12+
private static $domain = 'domain';
13+
14+
/** @dataProvider getDefaultDomainAssignmentTestData */
15+
public function testDefaultDomainAssignment(\Twig_Node $node)
16+
{
17+
$env = new \Twig_Environment(new \Twig_Loader_String(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
18+
19+
$visitor = new TranslationDefaultDomainNodeVisitor();
20+
21+
// visit trans_default_domain tag
22+
$defaultDomain = TwigNodeProvider::getTransDefaultDomainTag('domain');
23+
$visitor->enterNode($defaultDomain, $env);
24+
$visitor->leaveNode($defaultDomain, $env);
25+
26+
// visit tested node
27+
$enteredNode = $visitor->enterNode($node, $env);
28+
$leavedNode = $visitor->leaveNode($node, $env);
29+
$this->assertSame($node, $enteredNode);
30+
$this->assertSame($node, $leavedNode);
31+
32+
// extracting tested node messages
33+
$visitor = new TranslationNodeVisitor();
34+
$visitor->enable();
35+
$visitor->enterNode($node, $env);
36+
$visitor->leaveNode($node, $env);
37+
38+
$this->assertEquals(array(array(self::$message, self::$domain)), $visitor->getMessages());
39+
}
40+
41+
public function getDefaultDomainAssignmentTestData()
42+
{
43+
return array(
44+
array(TwigNodeProvider::getTransFilter(self::$message, self::$domain)),
45+
array(TwigNodeProvider::getTransChoiceFilter(self::$message, self::$domain)),
46+
array(TwigNodeProvider::getTransTag(self::$message, self::$domain)),
47+
);
48+
}
49+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
namespace Symfony\Bridge\Twig\Tests\NodeVisitor;
4+
5+
use Symfony\Bridge\Twig\NodeVisitor\TranslationNodeVisitor;
6+
use Symfony\Bridge\Twig\Tests\TestCase;
7+
8+
class TranslationNodeVisitorTest extends TestCase
9+
{
10+
/** @dataProvider getMessagesExtractionTestData */
11+
public function testMessagesExtraction(\Twig_Node $node, array $expectedMessages)
12+
{
13+
$env = new \Twig_Environment(new \Twig_Loader_String(), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
14+
$visitor = new TranslationNodeVisitor();
15+
$visitor->enable();
16+
$visitor->enterNode($node, $env);
17+
$visitor->leaveNode($node, $env);
18+
$this->assertEquals($expectedMessages, $visitor->getMessages());
19+
}
20+
21+
public function testMessageExtractionWithInvalidDomainNode()
22+
{
23+
$message = 'new key';
24+
25+
$node = new \Twig_Node_Expression_Filter(
26+
new \Twig_Node_Expression_Constant($message, 0),
27+
new \Twig_Node_Expression_Constant('trans', 0),
28+
new \Twig_Node(array(
29+
new \Twig_Node_Expression_Array(array(), 0),
30+
new \Twig_Node_Expression_Name('variable', 0),
31+
)),
32+
0
33+
);
34+
35+
$this->testMessagesExtraction($node, array(array($message, TranslationNodeVisitor::UNDEFINED_DOMAIN)));
36+
}
37+
38+
public function getMessagesExtractionTestData()
39+
{
40+
$message = 'new key';
41+
$domain = 'domain';
42+
43+
return array(
44+
array(TwigNodeProvider::getTransFilter($message), array(array($message, null))),
45+
array(TwigNodeProvider::getTransChoiceFilter($message), array(array($message, null))),
46+
array(TwigNodeProvider::getTransTag($message), array(array($message, null))),
47+
array(TwigNodeProvider::getTransFilter($message, $domain), array(array($message, $domain))),
48+
array(TwigNodeProvider::getTransChoiceFilter($message, $domain), array(array($message, $domain))),
49+
array(TwigNodeProvider::getTransTag($message, $domain), array(array($message, $domain))),
50+
);
51+
}
52+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace Symfony\Bridge\Twig\Tests\NodeVisitor;
4+
5+
use Symfony\Bridge\Twig\Node\TransDefaultDomainNode;
6+
use Symfony\Bridge\Twig\Node\TransNode;
7+
8+
class TwigNodeProvider
9+
{
10+
public static function getTransFilter($message, $domain = null)
11+
{
12+
$arguments = $domain ? array(
13+
new \Twig_Node_Expression_Array(array(), 0),
14+
new \Twig_Node_Expression_Constant($domain, 0),
15+
) : array();
16+
17+
return new \Twig_Node_Expression_Filter(
18+
new \Twig_Node_Expression_Constant($message, 0),
19+
new \Twig_Node_Expression_Constant('trans', 0),
20+
new \Twig_Node($arguments),
21+
0
22+
);
23+
}
24+
25+
public static function getTransChoiceFilter($message, $domain = null)
26+
{
27+
$arguments = $domain ? array(
28+
new \Twig_Node_Expression_Constant(0, 0),
29+
new \Twig_Node_Expression_Array(array(), 0),
30+
new \Twig_Node_Expression_Constant($domain, 0),
31+
) : array();
32+
33+
return new \Twig_Node_Expression_Filter(
34+
new \Twig_Node_Expression_Constant($message, 0),
35+
new \Twig_Node_Expression_Constant('transchoice', 0),
36+
new \Twig_Node($arguments),
37+
0
38+
);
39+
}
40+
41+
public static function getTransTag($message, $domain = null)
42+
{
43+
return new TransNode(
44+
new \Twig_Node_Body(array(), array('data' => $message)),
45+
$domain ? new \Twig_Node_Expression_Constant($domain, 0) : null
46+
);
47+
}
48+
49+
public static function getTransDefaultDomainTag($domain)
50+
{
51+
return new TransDefaultDomainNode(
52+
new \Twig_Node_Expression_Constant($domain, 0)
53+
);
54+
}
55+
}

src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,19 @@ public function getExtractData()
6363
array('{{ "new key" | transchoice(1) | upper }}', array('new key' => 'messages')),
6464
array('{{ "new key" | transchoice(1, {}, "domain") }}', array('new key' => 'domain')),
6565
array('{% trans %}new key{% endtrans %}', array('new key' => 'messages')),
66+
array('{% trans %} new key {% endtrans %}', array('new key' => 'messages')),
6667
array('{% trans from "domain" %}new key{% endtrans %}', array('new key' => 'domain')),
6768
array('{% set foo = "new key" | trans %}', array('new key' => 'messages')),
6869
array('{{ 1 ? "new key" | trans : "another key" | trans }}', array('new key' => 'messages', 'another key' => 'messages')),
70+
71+
// make sure 'trans_default_domain' tag is supported
72+
array('{% trans_default_domain "domain" %}{{ "new key"|trans }}', array('new key' => 'domain')),
73+
array('{% trans_default_domain "domain" %}{{ "new key"|transchoice }}', array('new key' => 'domain')),
74+
array('{% trans_default_domain "domain" %}{% trans %}new key{% endtrans %}', array('new key' => 'domain')),
75+
76+
// make sure this works with twig's named arguments
77+
array('{{ "new key" | trans(domain="domain") }}', array('new key' => 'domain')),
78+
array('{{ "new key" | transchoice(domain="domain", count=1) }}', array('new key' => 'domain')),
6979
);
7080
}
7181
}

src/Symfony/Bridge/Twig/Translation/TwigExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected function extractTemplate($template, MessageCatalogue $catalogue)
7878
$this->twig->parse($this->twig->tokenize($template));
7979

8080
foreach ($visitor->getMessages() as $message) {
81-
$catalogue->set($message[0], $this->prefix.$message[0], $message[1] ? $message[1] : $this->defaultDomain);
81+
$catalogue->set(trim($message[0]), $this->prefix.trim($message[0]), $message[1] ? $message[1] : $this->defaultDomain);
8282
}
8383

8484
$visitor->disable();

src/Symfony/Bundle/FrameworkBundle/Console/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(KernelInterface $kernel)
4040
parent::__construct('Symfony', Kernel::VERSION.' - '.$kernel->getName().'/'.$kernel->getEnvironment().($kernel->isDebug() ? '/debug' : ''));
4141

4242
$this->getDefinition()->addOption(new InputOption('--shell', '-s', InputOption::VALUE_NONE, 'Launch the shell.'));
43-
$this->getDefinition()->addOption(new InputOption('--process-isolation', null, InputOption::VALUE_NONE, 'Launch commands from shell as a separate processes.'));
43+
$this->getDefinition()->addOption(new InputOption('--process-isolation', null, InputOption::VALUE_NONE, 'Launch commands from shell as a separate process.'));
4444
$this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment()));
4545
$this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'));
4646
}

src/Symfony/Component/ClassLoader/DebugClassLoader.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ public function unregister()
6969
spl_autoload_unregister(array($this, 'loadClass'));
7070
}
7171

72+
/**
73+
* Finds a file by class name
74+
*
75+
* @param string $class A class name to resolve to file
76+
*
77+
* @return string|null
78+
*/
79+
public function findFile($class)
80+
{
81+
return $this->classFinder->findFile($class);
82+
}
83+
7284
/**
7385
* Loads the given class or interface.
7486
*

src/Symfony/Component/Console/Input/ArgvInput.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function __construct(array $argv = null, InputDefinition $definition = nu
6868
protected function setTokens(array $tokens)
6969
{
7070
$this->tokens = $tokens;
71+
$this->parse();
7172
}
7273

7374
/**

src/Symfony/Component/Console/Output/Output.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function getVerbosity()
123123
/**
124124
* Writes a message to the output and adds a newline at the end.
125125
*
126-
* @param string|array $messages The message as an array of lines of a single string
126+
* @param string|array $messages The message as an array of lines or a single string
127127
* @param integer $type The type of output
128128
*
129129
* @api
@@ -136,7 +136,7 @@ public function writeln($messages, $type = 0)
136136
/**
137137
* Writes a message to the output.
138138
*
139-
* @param string|array $messages The message as an array of lines of a single string
139+
* @param string|array $messages The message as an array of lines or a single string
140140
* @param Boolean $newline Whether to add a newline or not
141141
* @param integer $type The type of output
142142
*

0 commit comments

Comments
 (0)