Skip to content

Commit 6393ec3

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: [DomCrawler] Invalid uri created from forms if base tag present [Console] update param type phpdoc for StreamOutput [Console] fix typo in OutputInterface Use stderr by default when a specific output is not injected [Debug] Fix case mismatch detection [HttpKernel] fix broken multiline <esi:remove> [DoctrineBridge] Fixed #14840 [FrameworkBundle] add a suggest for the serializer component [Yaml] Fix the parsing of float keys [Console] Ensure the console output is only detected as decorated when both stderr and stdout support colors [HttpKernel] fix DumpDataCollector compat with Twig 2.0 Improve exception messages. Fix that two DirectoryResources with different patterns would be deduplicated Tests fix clockmock [WebProfilerBundle] Added tabindex="-1" to not interfer with normal UX missing "YAML" in the exception message. [Translator][warmup][fallback locales] fixed missing cache file generation. [framework-bundle] Add Test for TranslationUpdateCommand Use ObjectManager interface instead of EntityManager
2 parents 9e32be3 + cafd4af commit 6393ec3

File tree

37 files changed

+400
-61
lines changed

37 files changed

+400
-61
lines changed

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,15 @@ protected function setMappingDriverAlias($mappingConfig, $mappingName)
129129
*/
130130
protected function setMappingDriverConfig(array $mappingConfig, $mappingName)
131131
{
132-
if (!is_dir($mappingConfig['dir'])) {
132+
$mappingDirectory = $mappingConfig['dir'];
133+
if (!is_dir($mappingDirectory)) {
133134
throw new \InvalidArgumentException(sprintf('Invalid Doctrine mapping path given. Cannot load Doctrine mapping/bundle named "%s".', $mappingName));
134135
}
135136

136-
$this->drivers[$mappingConfig['type']][$mappingConfig['prefix']] = realpath($mappingConfig['dir']);
137+
if (substr($mappingDirectory, 0, 7) !== 'phar://') {
138+
$mappingDirectory = realpath($mappingDirectory);
139+
}
140+
$this->drivers[$mappingConfig['type']][$mappingConfig['prefix']] = $mappingDirectory;
137141
}
138142

139143
/**

src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Form\Exception\UnexpectedTypeException;
1515
use Doctrine\ORM\QueryBuilder;
1616
use Doctrine\DBAL\Connection;
17-
use Doctrine\ORM\EntityManager;
17+
use Doctrine\Common\Persistence\ObjectManager;
1818

1919
/**
2020
* Loads entities using a {@link QueryBuilder} instance.
@@ -43,7 +43,7 @@ class ORMQueryBuilderLoader implements EntityLoaderInterface
4343
* deprecated and will not be
4444
* supported anymore as of
4545
* Symfony 3.0.
46-
* @param EntityManager $manager Deprecated.
46+
* @param ObjectManager $manager Deprecated.
4747
* @param string $class Deprecated.
4848
*
4949
* @throws UnexpectedTypeException
@@ -59,8 +59,8 @@ public function __construct($queryBuilder, $manager = null, $class = null)
5959
if ($queryBuilder instanceof \Closure) {
6060
@trigger_error('Passing a QueryBuilder closure to '.__CLASS__.'::__construct() is deprecated since version 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
6161

62-
if (!$manager instanceof EntityManager) {
63-
throw new UnexpectedTypeException($manager, 'Doctrine\ORM\EntityManager');
62+
if (!$manager instanceof ObjectManager) {
63+
throw new UnexpectedTypeException($manager, 'Doctrine\Common\Persistence\ObjectManager');
6464
}
6565

6666
@trigger_error('Passing an EntityManager to '.__CLASS__.'::__construct() is deprecated since version 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);

src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ public function close()
120120
*/
121121
public function onCommand(ConsoleCommandEvent $event)
122122
{
123-
$this->setOutput($event->getOutput());
123+
$output = $event->getOutput();
124+
if ($output instanceof ConsoleOutputInterface) {
125+
$output = $output->getErrorOutput();
126+
}
127+
128+
$this->setOutput($output);
124129
}
125130

126131
/**
@@ -149,11 +154,7 @@ public static function getSubscribedEvents()
149154
*/
150155
protected function write(array $record)
151156
{
152-
if ($record['level'] >= Logger::ERROR && $this->output instanceof ConsoleOutputInterface) {
153-
$this->output->getErrorOutput()->write((string) $record['formatted']);
154-
} else {
155-
$this->output->write((string) $record['formatted']);
156-
}
157+
$this->output->write((string) $record['formatted']);
157158
}
158159

159160
/**

src/Symfony/Bridge/Monolog/Tests/Handler/ConsoleHandlerTest.php

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function testGetFormatter()
110110

111111
public function testWritingAndFormatting()
112112
{
113-
$output = $this->getMock('Symfony\Component\Console\Output\ConsoleOutputInterface');
113+
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
114114
$output
115115
->expects($this->any())
116116
->method('getVerbosity')
@@ -122,19 +122,6 @@ public function testWritingAndFormatting()
122122
->with('<info>[2013-05-29 16:21:54] app.INFO:</info> My info message '."\n")
123123
;
124124

125-
$errorOutput = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
126-
$errorOutput
127-
->expects($this->once())
128-
->method('write')
129-
->with('<error>[2013-05-29 16:21:54] app.ERROR:</error> My error message '."\n")
130-
;
131-
132-
$output
133-
->expects($this->any())
134-
->method('getErrorOutput')
135-
->will($this->returnValue($errorOutput))
136-
;
137-
138125
$handler = new ConsoleHandler(null, false);
139126
$handler->setOutput($output);
140127

@@ -149,18 +136,6 @@ public function testWritingAndFormatting()
149136
);
150137

151138
$this->assertTrue($handler->handle($infoRecord), 'The handler finished handling the log as bubble is false.');
152-
153-
$errorRecord = array(
154-
'message' => 'My error message',
155-
'context' => array(),
156-
'level' => Logger::ERROR,
157-
'level_name' => Logger::getLevelName(Logger::ERROR),
158-
'channel' => 'app',
159-
'datetime' => new \DateTime('2013-05-29 16:21:54'),
160-
'extra' => array(),
161-
);
162-
163-
$this->assertTrue($handler->handle($errorRecord), 'The handler finished handling the log as bubble is false.');
164139
}
165140

166141
public function testLogsFromListeners()
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
13+
14+
use Symfony\Component\Console\Application;
15+
use Symfony\Component\Console\Tester\CommandTester;
16+
use Symfony\Bundle\FrameworkBundle\Command\TranslationUpdateCommand;
17+
use Symfony\Component\Filesystem\Filesystem;
18+
use Symfony\Component\DependencyInjection;
19+
use Symfony\Component\HttpKernel;
20+
21+
class TranslationUpdateCommandTest extends \PHPUnit_Framework_TestCase
22+
{
23+
private $fs;
24+
private $translationDir;
25+
26+
public function testDumpMessagesAndClean()
27+
{
28+
$tester = $this->createCommandTester($this->getContainer(array('foo' => 'foo')));
29+
$tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true));
30+
$this->assertRegExp('/foo/', $tester->getDisplay());
31+
}
32+
33+
protected function setUp()
34+
{
35+
$this->fs = new Filesystem();
36+
$this->translationDir = sys_get_temp_dir().'/'.uniqid('sf2_translation', true);
37+
$this->fs->mkdir($this->translationDir.'/Resources/translations');
38+
$this->fs->mkdir($this->translationDir.'/Resources/views');
39+
}
40+
41+
protected function tearDown()
42+
{
43+
$this->fs->remove($this->translationDir);
44+
}
45+
46+
/**
47+
* @return CommandTester
48+
*/
49+
private function createCommandTester(DependencyInjection\ContainerInterface $container)
50+
{
51+
$command = new TranslationUpdateCommand();
52+
$command->setContainer($container);
53+
54+
$application = new Application();
55+
$application->add($command);
56+
57+
return new CommandTester($application->find('translation:update'));
58+
}
59+
60+
private function getContainer($extractedMessages = array(), $loadedMessages = array(), HttpKernel\KernelInterface $kernel = null)
61+
{
62+
$translator = $this->getMockBuilder('Symfony\Component\Translation\Translator')
63+
->disableOriginalConstructor()
64+
->getMock();
65+
66+
$translator
67+
->expects($this->any())
68+
->method('getFallbackLocales')
69+
->will($this->returnValue(array('en')));
70+
71+
$extractor = $this->getMock('Symfony\Component\Translation\Extractor\ExtractorInterface');
72+
$extractor
73+
->expects($this->any())
74+
->method('extract')
75+
->will(
76+
$this->returnCallback(function ($path, $catalogue) use ($extractedMessages) {
77+
$catalogue->add($extractedMessages);
78+
})
79+
);
80+
81+
$loader = $this->getMock('Symfony\Bundle\FrameworkBundle\Translation\TranslationLoader');
82+
$loader
83+
->expects($this->any())
84+
->method('loadMessages')
85+
->will(
86+
$this->returnCallback(function ($path, $catalogue) use ($loadedMessages) {
87+
$catalogue->add($loadedMessages);
88+
})
89+
);
90+
91+
$writer = $this->getMock('Symfony\Component\Translation\Writer\TranslationWriter');
92+
$writer
93+
->expects($this->any())
94+
->method('getFormats')
95+
->will(
96+
$this->returnValue(array('xlf', 'yml'))
97+
);
98+
99+
if (null === $kernel) {
100+
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
101+
$kernel
102+
->expects($this->any())
103+
->method('getBundle')
104+
->will($this->returnValueMap(array(
105+
array('foo', true, $this->getBundle($this->translationDir)),
106+
array('test', true, $this->getBundle('test')),
107+
)));
108+
}
109+
110+
$kernel
111+
->expects($this->any())
112+
->method('getRootDir')
113+
->will($this->returnValue($this->translationDir));
114+
115+
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
116+
$container
117+
->expects($this->any())
118+
->method('get')
119+
->will($this->returnValueMap(array(
120+
array('translation.extractor', 1, $extractor),
121+
array('translation.loader', 1, $loader),
122+
array('translation.writer', 1, $writer),
123+
array('translator', 1, $translator),
124+
array('kernel', 1, $kernel),
125+
)));
126+
127+
return $container;
128+
}
129+
130+
private function getBundle($path)
131+
{
132+
$bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
133+
$bundle
134+
->expects($this->any())
135+
->method('getPath')
136+
->will($this->returnValue($path))
137+
;
138+
139+
return $bundle;
140+
}
141+
}

src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public function testWarmup()
273273

274274
// prime the cache
275275
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml');
276-
$translator->setLocale('fr');
276+
$translator->setFallbackLocales(array('fr'));
277277
$translator->warmup($this->tmpDir);
278278

279279
$loader = $this->getMock('Symfony\Component\Translation\Loader\LoaderInterface');
@@ -283,6 +283,7 @@ public function testWarmup()
283283

284284
$translator = $this->getTranslator($loader, array('cache_dir' => $this->tmpDir, 'resource_files' => $resourceFiles), 'yml');
285285
$translator->setLocale('fr');
286+
$translator->setFallbackLocales(array('fr'));
286287
$this->assertEquals('répertoire', $translator->trans('folder'));
287288
}
288289

src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,13 @@ public function warmUp($cacheDir)
8282
return;
8383
}
8484

85-
foreach ($this->resourceLocales as $locale) {
85+
$locales = array_merge($this->getFallbackLocales(), array($this->getLocale()), $this->resourceLocales);
86+
foreach (array_unique($locales) as $locale) {
87+
// reset catalogue in case it's already loaded during the dump of the other locales.
88+
if (isset($this->catalogues[$locale])) {
89+
unset($this->catalogues[$locale]);
90+
}
91+
8692
$this->loadCatalogue($locale);
8793
}
8894
}

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"symfony/console": "For using the console commands",
5353
"symfony/finder": "For using the translation loader and cache warmer",
5454
"symfony/form": "For using forms",
55+
"symfony/serializer": "For using the serializer service",
5556
"symfony/validator": "For using validation",
5657
"symfony/yaml": "For using the debug:config and lint:yaml commands",
5758
"doctrine/cache": "For using alternative cache drivers"

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- START of Symfony Web Debug Toolbar -->
22
{% if 'normal' != position %}
33
<div id="sfMiniToolbar-{{ token }}" class="sf-minitoolbar" data-no-turbolink>
4-
<a href="javascript:void(0);" title="Show Symfony toolbar" onclick="
4+
<a href="javascript:void(0);" title="Show Symfony toolbar" tabindex="-1" accesskey="D" onclick="
55
var elem = this.parentNode;
66
if (elem.style.display == 'none') {
77
document.getElementById('sfToolbarMainContent-{{ token }}').style.display = 'none';
@@ -37,7 +37,7 @@
3737
{% endfor %}
3838

3939
{% if 'normal' != position %}
40-
<a class="hide-button" title="Close Toolbar" onclick="
40+
<a class="hide-button" title="Close Toolbar" tabindex="-1" accesskey="D" onclick="
4141
var p = this.parentNode;
4242
p.style.display = 'none';
4343
(p.previousElementSibling || p.previousSibling).style.display = 'none';

src/Symfony/Component/Config/Resource/DirectoryResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct($resource, $pattern = null)
3838
*/
3939
public function __toString()
4040
{
41-
return (string) $this->resource;
41+
return md5(serialize(array($this->resource, $this->pattern)));
4242
}
4343

4444
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy