8000 Merge branch '3.4' · symfony/symfony@18ed089 · GitHub
[go: up one dir, main page]

Skip to content

Commit 18ed089

Browse files
Merge branch '3.4'
* 3.4: [Webprofiler] Added blocks that allows extension of the profiler page. [Dotenv] Get env using $_SERVER to work with fastcgi_param and workaround thread safety issues [Dotenv][WebServerBundle] Override previously loaded variables Create an interface for TranslationWriter [Translation] Adding the ability do dump <notes> in xliff2.0 [DI] Use GlobResource for non-tracked directories [DI] Fix resolving env vars when compiling a ContainerBuilder [SecurityBundle] resolve class name parameter inside AddSecurityVotersPass [FrameworkBundle] Add soft conflict rule of "cache:clear" + HttpKernel 3.4 [WebProfilerBundle] Re add missing link to the controller
2 parents d6a1289 + 85f03e1 commit 18ed089

File tree

24 files changed

+406
-68
lines changed

24 files changed

+406
-68
lines changed

UPGRADE-3.4.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,13 @@ SecurityBundle
160160

161161
* `FirewallContext::getListeners()` now returns `\Traversable|array`
162162

163+
Translation
164+
-----------
165+
166+
* `Symfony\Component\Translation\Writer\TranslationWriter::writeTranslations` has been deprecated
167+
and will be removed in 4.0, use `Symfony\Component\Translation\Writer\TranslationWriter::write`
168+
instead.
169+
163170
TwigBridge
164171
----------
165172

UPGRADE-4.0.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,9 @@ Translation
587587
-----------
588588

589589
* Removed the backup feature from the file dumper classes.
590+
591+
* Removed `Symfony\Component\Translation\Writer\TranslationWriter::writeTranslations`,
592+
use `Symfony\Component\Translation\Writer\TranslationWriter::write` instead.
590593

591594
TwigBundle
592595
----------

src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use Symfony\Component\Console\Input\InputOption;
2323
use Symfony\Component\Translation\Extractor\ExtractorInterface;
2424
use Symfony\Component\Translation\MessageCatalogue;
25-
use Symfony\Component\Translation\Writer\TranslationWriter;
25+
use Symfony\Component\Translation\Writer\TranslationWriterInterface;
2626

2727
/**
2828
* A command that parses templates to extract translation messages and adds them
@@ -40,12 +40,12 @@ class TranslationUpdateCommand extends Command
4040
private $defaultLocale;
4141

4242
/**
43-
* @param TranslationWriter $writer
44-
* @param TranslationLoader $loader
45-
* @param ExtractorInterface $extractor
46-
* @param string $defaultLocale
43+
* @param TranslationWriterInterface $writer
44+
* @param TranslationLoader $loader
45+
* @param ExtractorInterface $extractor
46+
* @param string $defaultLocale
4747
*/
48-
public function __construct(TranslationWriter $writer, TranslationLoader $loader, ExtractorInterface $extractor, $defaultLocale)
48+
public function __construct(TranslationWriterInterface $writer, TranslationLoader $loader, ExtractorInterface $extractor, $defaultLocale)
4949
{
5050
parent::__construct();
5151

@@ -237,7 +237,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
237237
$bundleTransPath = end($transPaths).'translations';
238238
}
239239

240-
$this->writer->writeTranslations($operation->getResult(), $input->getOption('output-format'), array('path' => $bundleTransPath, 'default_locale' => $this->defaultLocale));
240+
$this->writer->write($operation->getResult(), $input->getOption('output-format'), array('path' => $bundleTransPath, 'default_locale' => $this->defaultLocale));
241241

242242
if (true === $input->getOption('dump-messages')) {
243243
$resultMessage .= ' and translation files were updated';

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
13151315
$fileRecorder('yml', $file);
13161316
}
13171317

1318-
if ($container->fileExists($dir = $dirname.'/Resources/config/serialization')) {
1318+
if ($container->fileExists($dir = $dirname.'/Resources/config/serialization', '/^$/')) {
13191319
$this->registerMappingFilesFromDir($dir, $fileRecorder);
13201320
}
13211321
}

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/AddSecurityVotersPass.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public function process(ContainerBuilder $container)
4242
}
4343

4444
foreach ($voters as $voter) {
45-
$class = $container->getDefinition((string) $voter)->getClass();
45+
$definition = $container->getDefinition((string) $voter);
46+
$class = $container->getParameterBag()->resolveValue($definition->getClass());
4647

4748
if (!is_a($class, VoterInterface::class, true)) {
4849
throw new LogicException(sprintf('%s must implement the %s when used as a voter.', $class, VoterInterface::class));

src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Bridge\Twig\Extension\WebLinkExtension;
1515
use Symfony\Component\Config\FileLocator;
16+
use Symfony\Component\Config\Resource\FileExistenceResource;
1617
use Symfony\Component\Console\Application;
1718
use Symfony\Component\DependencyInjection\ContainerBuilder;
1819
use Symfony\Component\DependencyInjection\Reference;
@@ -124,9 +125,10 @@ public function load(array $configs, ContainerBuilder $container)
124125
}
125126
}
126127

127-
if ($container->fileExists($dir = $container->getParameter('kernel.root_dir').'/Resources/views', false)) {
128+
if (file_exists($dir = $container->getParameter('kernel.root_dir').'/Resources/views')) {
128129
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($dir));
129130
}
131+
$container->addResource(new FileExistenceResource($dir));
130132

131133
if (!empty($config['globals'])) {
132134
$def = $container->getDefinition('twig');
@@ -172,13 +174,15 @@ private function getBundleHierarchy(ContainerBuilder $container)
172174
);
173175
}
174176

175-
if ($container->fileExists($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$name.'/views', false)) {
177+
if (file_exists($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$name.'/views')) {
176178
$bundleHierarchy[$name]['paths'][] = $dir;
177179
}
180+
$container->addResource(new FileExistenceResource($dir));
178181

179-
if ($container->fileExists($dir = $bundle['path'].'/Resources/views', false)) {
182+
if (file_exists($dir = $bundle['path'].'/Resources/views')) {
180183
$bundleHierarchy[$name]['paths'][] = $dir;
181184
}
185+
$container->addResource(new FileExistenceResource($dir));
182186

183187
if (null === $bundle['parent']) {
184188
continue;

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
22

33
{% block toolbar %}
4+
{% import _self as helper %}
45
{% set request_handler %}
5-
{% import _self as helper %}
66
{{ helper.set_handler(collector.controller) }}
77
{% endset %}
88

99
{% if collector.redirect %}
1010
{% set redirect_handler %}
11-
{% import _self as helper %}
1211
{{ helper.set_handler(collector.redirect.controller, collector.redirect.route, 'GET' != collector.redirect.method ? collector.redirect.method) }}
1312
{% endset %}
1413
{% endif %}
1514

1615
{% if collector.forward|default(false) %}
1716
{% set forward_handler %}
18-
{% import _self as helper %}
1917
{{ helper.set_handler(collector.forward.controller) }}
2018
{% endset %}
2119
{% endif %}
@@ -108,6 +106,12 @@
108106
{% endblock %}
109107

110108
{% block panel %}
109+
{% import _self as helper %}
110+
111+
<h2>
112+
{{ helper.set_handler(collector.controller) }}
113+
</h2>
114+
111115
<div class="sf-tabs">
112116
<div class="tab">
113117
<h3 class="tab-title">Request</h3>
@@ -268,7 +272,7 @@
268272
{% for child in profile.children %}
269273
<h3>
270274
<a href="{{ path('_profiler', { token: child.token }) }}">
271-
{{- child.getcollector('request').identifier -}}
275+
{{ helper.set_handler(child.getcollector('request').controller) }}
272276
</a>
273277
<small>(token = {{ child.token }})</small>
274278
</h3>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282

8383
<h2>Translation Messages</h2>
8484

85+
{% block messages %}
86+
8587
{# sort translation messages in groups #}
8688
{% set messages_defined, messages_missing, messages_fallback = [], [], [] %}
8789
{% for message in collector.messages %}
@@ -108,7 +110,9 @@
108110
<p>None of the used translation messages are defined for the given locale.</p>
109111
</div>
110112
{% else %}
111-
{{ helper.render_table(messages_defined) }}
113+
{% block defined_messages %}
114+
{{ helper.render_table(messages_defined) }}
115+
{% endblock %}
112116
{% endif %}
113117
</div>
114118
</div>
@@ -127,7 +131,9 @@
127131
<p>No fallback translation messages were used.</p>
128132
</div>
129133
{% else %}
130-
{{ helper.render_table(messages_fallback) }}
134+
{% block fallback_messages %}
135+
{{ helper.render_table(messages_fallback) }}
136+
{% endblock %}
131137
{% endif %}
132138
</div>
133139
</div>
@@ -147,11 +153,16 @@
147153
<p>There are no messages of this category.</p>
148154
</div>
149155
{% else %}
150-
{{ helper.render_table(messages_missing) }}
156+
{% block missing_messages %}
157+
{{ helper.render_table(messages_missing) }}
158+
{% endblock %}
151159
{% endif %}
152160
</div>
153161
</div>
154162
</div>
163+
164+
{% endblock messages %}
165+
155166
{% endblock %}
156167

157168
{% macro render_table(messages) %}

src/Symfony/Bundle/WebServerBundle/WebServer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ private function createServerProcess(WebServerConfig $config)
154154
$process->setWorkingDirectory($config->getDocumentRoot());
155155
$process->setTimeout(null);
156156

157+
if (in_array('APP_ENV', explode(',', getenv('SYMFONY_DOTENV_VARS')))) {
158+
$process->setEnv(array('APP_ENV' => false));
159+
$process->inheritEnvironmentVariables();
160+
}
161+
157162
return $process;
158163
}
159164

src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,15 @@ public function __construct(Extension $extension, parent $resolvingBag)
9292
{
9393
$this->beforeProcessingEnvPlaceholders = $resolvingBag->getEnvPlaceholders();
9494
$config = $this->resolveEnvPlaceholders($extension->getProcessedConfigs());
95-
parent::__construct($this->resolveEnvReferences($config));
95+
parent::__construct($this->resolveValue($config));
96+
}
97+
98+
/**
99+
* {@inheritdoc}
100+
*/
101+
public function get($name)
102+
{
103+
return $this->has($name) || (0 === strpos($name, 'env(') && ')' === substr($name, -1) && 'env()' !== $name) ? parent::get($name) : '';
96104
}
97105

98106
/**
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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\Component\DependencyInjection\Compiler;
13+
14+
use Symfony\Component\DependencyInjection\Definition;
15+
16+
/**
17+
* Replaces env var placeholders by their current values.
18+
*/
19+
class ResolveEnvPlaceholdersPass extends AbstractRecursivePass
20+
{
21+
protected function processValue($value, $isRoot = false)
22+
{
23+
if (is_string($value)) {
24+
return $this->container->resolveEnvPlaceholders($value, true);
25+
}
26+
if ($value instanceof Definition) {
27+
$changes = $value->getChanges();
28+
if (isset($changes['class'])) {
29+
$value->setClass($this->container->resolveEnvPlaceholders($value->getClass(), true));
30+
}
31+
if (isset($changes['file'])) {
32+
$value->setFile($this->container->resolveEnvPlaceholders($value->getFile(), true));
33+
}
34+
}
35+
36+
$value = parent::processValue($value, $isRoot);
37+
38+
if ($value && is_array($value)) {
39+
$value = array_combine($this->container->resolveEnvPlaceholders(array_keys($value), true), $value);
40+
}
41+
42+
return $value;
43+
}
44+
}

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,13 @@ protected function getEnv($name)
341341
if (isset($this->envCache[$name]) || array_key_exists($name, $this->envCache)) {
342342
return $this->envCache[$name];
343343
}
344-
if (0 !== strpos($name, 'HTTP_') && isset($_SERVER[$name])) {
344+
if (isset($_SERVER[$name]) && 0 !== strpos($name, 'HTTP_')) {
345345
return $this->envCache[$name] = $_SERVER[$name];
346346
}
347347
if (isset($_ENV[$name])) {
348348
return $this->envCache[$name] = $_ENV[$name];
349349
}
350-
if (false !== $env = getenv($name)) {
350+
if (false !== ($env = getenv($name)) && null !== $env) { // null is a possible value because of thread safety issues
351351
return $this->envCache[$name] = $env;
352352
}
353353
if (!$this->hasParameter("env($name)")) {

0 commit comments

Comments
 (0)
0