8000 merged 2.0 · symfony/symfony@8a4f9ea · GitHub
[go: up one dir, main page]

Skip to content

Commit 8a4f9ea

Browse files
committed
merged 2.0
2 parents d6f01df + 220d3d2 commit 8a4f9ea

File tree

15 files changed

+86
-10
lines changed

15 files changed

+86
-10
lines changed

src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
112112
$basename = substr($m->name, strrpos($m->name, '\\') + 1);
113113
$output->writeln(sprintf(' > backing up <comment>%s.php</comment> to <comment>%s.php~</comment>', $basename, $basename));
114114
}
115+
// Getting the metadata for the entity class once more to get the correct path if the namespace has multiple occurrences
116+
$entityMetadata = $manager->getClassMetadata($m->getName(), $input->getOption('path'));
117+
115118
$output->writeln(sprintf(' > generating <comment>%s</comment>', $m->name));
116-
$generator->generate(array($m), $metadata->getPath());
119+
$generator->generate(array($m), $entityMetadata->getPath());
117120

118121
if ($m->customRepositoryClassName && false !== strpos($m->customRepositoryClassName, $metadata->getNamespace())) {
119122
$repoGenerator->writeEntityRepositoryClass($m->customRepositoryClassName, $metadata->getPath());

src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
<tag name="templating.helper" alias="code" />
8787
<argument>%templating.helper.code.file_link_format%</argument>
8888
<argument>%kernel.root_dir%</argument>
89+
<argument>%kernel.charset%</argument>
8990
</service>
9091

9192
<service id="templating.helper.translator" class="%templating.helper.translator.class%">

src/Symfony/Bundle/FrameworkBundle/Resources/translations/validators.cs.xliff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
</trans-unit>
117117
<trans-unit id="29">
118118
<source>The uploaded file was too large. Please try to upload a smaller file</source>
119-
<target>Nahraný soubor je příliš velký. Nahrejte prosím menší soubor</target>
119+
<target>Nahraný soubor je příliš velký. Nahrajte prosím menší soubor</target>
120120
</trans-unit>
121121
<trans-unit id="30">
122122
<source>The CSRF token is invalid. Please try to resubmit the form</source>

src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313

1414
use Symfony\Component\Templating\Helper\Helper;
1515

16+
if (!defined('ENT_SUBSTITUTE')) {
17+
define('ENT_SUBSTITUTE', 8);
18+
}
19+
1620
/**
1721
* CodeHelper.
1822
*
@@ -22,17 +26,20 @@ class CodeHelper extends Helper
2226
{
2327
protected $fileLinkFormat;
2428
protected $rootDir;
29+
protected $charset;
2530

2631
/**
2732
* Constructor.
2833
*
2934
* @param string $fileLinkFormat The format for links to source files
3035
* @param string $rootDir The project root directory
36+
* @param string $charset The charset
3137
*/
32-
public function __construct($fileLinkFormat, $rootDir)
38+
public function __construct($fileLinkFormat, $rootDir, $charset)
3339
{
3440
$this->fileLinkFormat = empty($fileLinkFormat) ? ini_get('xdebug.file_link_format') : $fileLinkFormat;
3541
$this->rootDir = str_replace('\\', '/', $rootDir).'/';
42+
$this->charset = $charset;
3643
}
3744

3845
/**
@@ -173,7 +180,7 @@ public function formatFile($file, $line, $text = null)
173180
}
174181

175182
if (false !== $link = $this->getFileLink($file, $line)) {
176-
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', $link, $text);
183+
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, ENT_QUOTES | ENT_SUBSTITUTE, $this->charset), $text);
177184
}
178185

179186
return $text;

src/Symfony/Bundle/FrameworkBundle/Templating/Loader/FilesystemLoader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ public function isFresh(TemplateReferenceInterface $template, $time)
6565
return false;
6666
}
6767

68+
if (!is_readable((string) $storage)) {
69+
return false;
70+
}
71+
6872
return filemtime((string) $storage) < $time;
6973
}
7074
}

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/CodeHelperTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ class CodeHelperTest extends \PHPUnit_Framework_TestCase
1919

2020
static public function setUpBeforeClass()
2121
{
22-
self::$helper = new CodeHelper('format', '/root');
22+
self::$helper = new CodeHelper('txmt://open?url=file://%f&line=%l', '/root', 'UTF-8');
23+
}
24+
25+
public function testFormatFile()
26+
{
27+
$expected = sprintf('<a href="txmt://open?url=file://%s&amp;line=25" title="Click to open this file" class="file_link">%s at line 25</a>', __FILE__, __FILE__);
28+
$this->assertEquals($expected, self::$helper->formatFile(__FILE__, 25));
2329
}
2430

2531
/**

src/Symfony/Component/CssSelector/XPathExprOr.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct($items, $prefix = null)
4242
*/
4343
public function __toString()
4444
{
45-
$prefix = $this->prefix;
45+
$prefix = $this->getPrefix();
4646

4747
$tmp = array();
4848
foreach ($this->items as $i) {

src/Symfony/Component/DependencyInjection/Definition.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\DependencyInjection;
1313

14+
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
15+
1416
/**
1517
* Definition represents a service definition.
1618
*
@@ -308,10 +310,15 @@ public function setMethodCalls(array $calls = array())
308310
*
309311
* @return Definition The current instance
310312
*
313+
* @throws InvalidArgumentException on empty $method param
314+
*
311315
* @api
312316
*/
313317
public function addMethodCall($method, array $arguments = array())
314318
{
319+
if (empty($method)) {
320+
throw new InvalidArgumentException(sprintf('Method name cannot be empty.'));
321+
}
315322
$this->calls[] = array($method, $arguments);
316323

317324
return $this;

src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function getArguments(Request $request, $controller)
9595
{
9696
if (is_array($controller)) {
9797
$r = new \ReflectionMethod($controller[0], $controller[1]);
98-
} elseif (is_object($controller)) {
98+
} elseif (is_object($controller) && !$controller instanceof \Closure) {
9999
$r = new \ReflectionObject($controller);
100100
$r = $r->getMethod('__invoke');
101101
} else {

tests/Symfony/Tests/Component/Console/Helper/FormatterHelperTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ public function testFormatBlock()
5050
$formatter->formatBlock('Some text to display', 'error', true),
5151
'::formatBlock() formats a message in a block'
5252
);
53+
}
54+
55+
public function testFormatBlockWithDiacriticLetters()
56+
{
57+
if (!extension_loaded('mbstring')) {
58+
$this->markTestSkipped('This test requires mbstring to work.');
59+
}
60+
61+
$formatter = new FormatterHelper();
5362

5463
$this->assertEquals(
5564
'<error> </error>' . "\n" .

tests/Symfony/Tests/Component/CssSelector/Node/OrNodeTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,18 @@ public function testToXpath()
2626

2727
$this->assertEquals("h1 | h2 | h3", (string) $or->toXpath(), '->toXpath() returns the xpath representation of the node');
2828
}
29+
30+
public function testIssueMissingPrefix()
31+
{
32+
// h1, h2, h3
33+
$element1 = new ElementNode('*', 'h1');
34+
$element2 = new ElementNode('*', 'h2');
35+
$element3 = new ElementNode('*', 'h3');
36+
$or = new OrNode(array($element1, $element2, $element3));
37+
38+
$xPath = $or->toXPath();
39+
$xPath->addPrefix('descendant-or-self::');
40+
41+
$this->assertEquals("descendant-or-self::h1 | descendant-or-self::h2 | descendant-or-self::h3", (string) $xPath);
42+
}
2943
}

tests/Symfony/Tests/Component/DependencyInjection/DefinitionTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ public function testMethodCalls()
9595
$this->assertEquals(array(array('foo', array('foo'))), $def->getMethodCalls(), '->removeMethodCall() removes a method to call');
9696
}
9797

98+
/**
99+
* @expectedException Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
100+
* @expectedExceptionMessage Method name cannot be empty.
101+
*/
102+
public function testExceptionOnEmptyMethodCall()
103+
{
104+
$def = new Definition('stdClass');
105+
$def->addMethodCall('');
106+
}
107+
98108
/**
99109
* @covers Symfony\Component\DependencyInjection\Definition::setFile
100110
* @covers Symfony\Component\DependencyInjection\Definition::getFile

tests/Symfony/Tests/Component/HttpKernel/Controller/ControllerResolverTest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ public function testGetArguments()
102102
$controller = function ($foo) {};
103103
$this->assertEquals(array('foo'), $resolver->getArguments($request, $controller));
104104

105+
$request = Request::create('/');
106+
$request->attributes->set('foo', 'foo');
107+
$controller = function ($foo, $bar = 'bar') {};
108+
$this->assertEquals(array('foo', 'bar'), $resolver->getArguments($request, $controller));
109+
110+
$request = Request::create('/');
111+
$request->attributes->set('foo', 'foo');
112+
$controller = new self();
113+
$this->assertEquals(array('foo', null), $resolver->getArguments($request, $controller));
114+
$request->attributes->set('bar', 'bar');
115+
$this->assertEquals(array('foo', 'bar'), $resolver->getArguments($request, $controller));
116+
105117
$request = Request::create('/');
106118
$request->attributes->set('foo', 'foo');
107119
$request->attributes->set('foobar', 'foobar');
@@ -119,7 +131,7 @@ public function testGetArguments()
119131
$this->assertEquals(array($request), $resolver->getArguments($request, $controller), '->getArguments() injects the request');
120132
}
121133

122-
public function __invoke()
134+
public function __invoke($foo, $bar = null)
123135
{
124136
}
125137

tests/Symfony/Tests/Component/Process/PhpExecutableFinderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testFindWithSuffix()
4848
$current = $f->find();
4949

5050
//TODO maybe php executable is custom or even windows
51-
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
51+
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
5252
$this->assertEquals($current, PHP_BINDIR.DIRECTORY_SEPARATOR.'php', '::find() returns the executable php with suffixes');
5353
}
5454
}

tests/Symfony/Tests/Component/Yaml/InlineTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ public function testDumpNumericValueWithLocale()
4747
$this->markTestSkipped('Your platform does not support locales.');
4848
}
4949

50-
setlocale(LC_ALL, 'fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252');
50+
$required_locales = array('fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252');
51+
if (false === setlocale(LC_ALL, $required_locales)) {
52+
$this->markTestSkipped('Could not set any of required locales: ' . implode(", ", $required_locales));
53+
}
5154

5255
$this->assertEquals('1.2', Inline::dump(1.2));
5356
$this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0)));

0 commit comments

Comments
 (0)
0