Merge branch '3.2'

* 3.2:
  [WebProfilerBundle] Fix whitespace control in layout.html.twig
  [HttpKernel] Fix open_basedir compat in DataCollector
  [Validator] Fix init of YamlFileLoader::$classes for empty files
This commit is contained in:
Nicolas Grekas 2016-12-08 17:03:21 +01:00
commit 3165e134de
4 changed files with 10 additions and 12 deletions

View File

@ -113,11 +113,11 @@
<ul id="menu-profiler"> <ul id="menu-profiler">
{% for name, template in templates %} {% for name, template in templates %}
{% set menu -%} {% set menu -%}
{% if block('menu', template) is defined %} {%- if block('menu', template) is defined -%}
{% with { collector: profile.getcollector(name), profiler_markup_version: profiler_markup_version } %} {% with { collector: profile.getcollector(name), profiler_markup_version: profiler_markup_version } %}
{{- block('menu', template) -}} {{- block('menu', template) -}}
{% endwith %} {% endwith %}
{% endif %} {%- endif -%}
{%- endset %} {%- endset %}
{% if menu is not empty %} {% if menu is not empty %}
<li class="{{ name }} {{ name == panel ? 'selected' : '' }}"> <li class="{{ name }} {{ name == panel ? 'selected' : '' }}">

View File

@ -135,7 +135,7 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
return self::$stubsCache[$var] = new ClassStub($var); return self::$stubsCache[$var] = new ClassStub($var);
} }
} }
if (false !== strpos($var, DIRECTORY_SEPARATOR) && false === strpos($var, '://') && false === strpos($var, "\0") && is_file($var)) { if (false !== strpos($var, DIRECTORY_SEPARATOR) && false === strpos($var, '://') && false === strpos($var, "\0") && @is_file($var)) {
return self::$stubsCache[$var] = new LinkStub($var); return self::$stubsCache[$var] = new LinkStub($var);
} }
} }

View File

@ -107,7 +107,7 @@ class YamlFileLoader extends FileLoader
* *
* @param string $path The path of the YAML file * @param string $path The path of the YAML file
* *
* @return array|null The class descriptions or null, if the file was empty * @return array The class descriptions
* *
* @throws \InvalidArgumentException If the file could not be loaded or did * @throws \InvalidArgumentException If the file could not be loaded or did
* not contain a YAML array * not contain a YAML array
@ -122,7 +122,7 @@ class YamlFileLoader extends FileLoader
// empty file // empty file
if (null === $classes) { if (null === $classes) {
return; return array();
} }
// not an array // not an array
@ -139,13 +139,7 @@ class YamlFileLoader extends FileLoader
$this->yamlParser = new YamlParser(); $this->yamlParser = new YamlParser();
} }
// This method may throw an exception. Do not modify the class' $this->classes = $this->parseFile($this->file);
// state before it completes
if (false === ($classes = $this->parseFile($this->file))) {
return;
}
$this->classes = $classes;
if (isset($this->classes['namespaces'])) { if (isset($this->classes['namespaces'])) {
foreach ($this->classes['namespaces'] as $alias => $namespace) { foreach ($this->classes['namespaces'] as $alias => $namespace) {

View File

@ -31,6 +31,10 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
$metadata = new ClassMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity'); $metadata = new ClassMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity');
$this->assertFalse($loader->loadClassMetadata($metadata)); $this->assertFalse($loader->loadClassMetadata($metadata));
$r = new \ReflectionProperty($loader, 'classes');
$r->setAccessible(true);
$this->assertSame(array(), $r->getValue($loader));
} }
/** /**