10000 Merge branch '2.0' into 2.1 · symfony/symfony@6485273 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6485273

Browse files
committed
Merge branch '2.0' into 2.1
* 2.0: [DependencyInjection] Allow frozen containers to be dumped to graphviz Add dot character `.` to legal mime subtype regular expression [HttpFoundation] fixed the creation of sub-requests under some circumstancies (closes #6923, closes #6936)
2 parents 0c63bbd + 8c250bd commit 6485273

File tree

8 files changed

+84
-3
lines changed

8 files changed

+84
-3
lines changed

src/Symfony/Component/DependencyInjection/Dumper/GraphvizDumper.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Symfony\Component\DependencyInjection\Reference;
1616
use Symfony\Component\DependencyInjection\Parameter;
1717
use Symfony\Component\DependencyInjection\ContainerInterface;
18+
use Symfony\Component\DependencyInjection\ContainerBuilder;
19+
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
1820

1921
/**
2022
* GraphvizDumper dumps a service container as a graphviz file.
@@ -159,7 +161,7 @@ private function findNodes()
159161
{
160162
$nodes = array();
161163

162-
$container = clone $this->container;
164+
$container = $this->cloneContainer();
163165

164166
foreach ($container->getDefinitions() as $id => $definition) {
165167
$nodes[$id] = array('class' => str_replace('\\', '\\\\', $this->container->getParameterBag()->resolveValue($definition->getClass())), 'attributes' => array_merge($this->options['node.definition'], array('style' => ContainerInterface::SCOPE_PROTOTYPE !== $definition->getScope() ? 'filled' : 'dotted')));
@@ -175,13 +177,31 @@ private function findNodes()
175177
}
176178

177179
if (!$container->hasDefinition($id)) {
178-
$nodes[$id] = array('class' => str_replace('\\', '\\\\', get_class($service)), 'attributes' => $this->options['node.instance']);
180+
$class = ('service_container' === $id) ? get_class($this->container) : get_class($service);
181+
$nodes[$id] = array('class' => str_replace('\\', '\\\\', $class), 'attributes' => $this->options['node.instance']);
179182
}
180183
}
181184

182185
return $nodes;
183186
}
184187

188+
private function cloneContainer()
189+
{
190+
$parameterBag = new ParameterBag($this->container->getParameterBag()->all());
191+
192+
$container = new ContainerBuilder($parameterBag);
193+
$container->setDefinitions($this->container->getDefinitions());
194+
$container->setAliases($this->container->getAliases());
195+
foreach ($this->container->getScopes() as $scope) {
196+
$container->addScope($scope);
197+
}
198+
foreach ($this->container->getExtensions() as $extension) {
199+
$container->registerExtension($extension);
200+
}
201+
202+
return $container;
203+
}
204+
185205
/**
186206
* Returns the start dot.
187207
*

src/Symfony/Component/DependencyInjection/Tests/Dumper/GraphvizDumperTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,18 @@ public function testDump()
5555
'node.missing' => array('fillcolor' => 'red', 'style' => 'empty'),
5656
)), str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services10-1.dot')), '->dump() dumps services');
5757
}
58+
59+
public function testDumpWithFrozenContainer()
60+
{
61+
$container = include self::$fixturesPath.'/containers/container13.php';
62+
$dumper = new GraphvizDumper($container);
63+
$this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services13.dot')), $dumper->dump(), '->dump() dumps services');
64+
}
65+
66+
public function testDumpWithFrozenCustomClassContainer()
67+
{
68+
$container = include self::$fixturesPath.'/containers/container14.php';
69+
$dumper = new GraphvizDumper($container);
70+
$this->assertEquals(str_replace('%path%', __DIR__, file_get_contents(self::$fixturesPath.'/graphviz/services14.dot')), $dumper->dump(), '->dump() dumps services');
71+
}
5872
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
use Symfony\Component\DependencyInjection\ContainerBuilder;
4+
use Symfony\Component\DependencyInjection\Definition;
5+
6+
$container = new ContainerBuilder();
7+
$container->
8+
register('foo', 'FooClass')->
9+
addArgument(new Reference('bar'))
10+
;
11+
$container->compile();
12+
13+
return $container;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Container14;
4+
5+
use Symfony\Component\DependencyInjection\ContainerBuilder;
6+
7+
class ProjectServiceContainer extends ContainerBuilder
8+
{
9+
}
10+
11+
return new ProjectServiceContainer();
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
digraph sc {
2+
ratio="compress"
3+
node [fontsize="11" fontname="Arial" shape="record"];
4+
edge [fontsize="9" fontname="Arial" color="grey" arrowhead="open" arrowsize="0.5"];
5+
6+
node_foo [label="foo\nFooClass\n", shape=record, fillcolor="#eeeeee", style="filled"];
7+
node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerBuilder\n", shape=record, fillcolor="#9999ff", style="filled"];
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
digraph sc {
2+
ratio="compress"
3+
node [fontsize="11" fontname="Arial" shape="record"];
4+
edge [fontsize="9" fontname="Arial" color="grey" arrowhead="open" arrowsize="0.5"];
5+
6+
node_service_container [label="service_container\nContainer14\\ProjectServiceContainer\n", shape=record, fillcolor="#9999ff", style="filled"];
7+
}

src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function guess($path)
7777

7878
$type = trim(ob_get_clean());
7979

80-
if (!preg_match('#^([a-z0-9\-]+/[a-z0-9\-]+)#i', $type, $match)) {
80+
if (!preg_match('#^([a-z0-9\-]+/[a-z0-9\-\.]+)#i', $type, $match)) {
8181
// it's not a type, but an error message
8282
return null;
8383
}

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,12 +1427,16 @@ protected function prepareRequestUri()
14271427
if ($this->headers->has('X_ORIGINAL_URL') && false !== stripos(PHP_OS, 'WIN')) {
14281428
// IIS with Microsoft Rewrite Module
14291429
$requestUri = $this->headers->get('X_ORIGINAL_URL');
1430+
$this->headers->remove('X_ORIGINAL_URL');
14301431
} elseif ($this->headers->has('X_REWRITE_URL') && false !== stripos(PHP_OS, 'WIN')) {
14311432
// IIS with ISAPI_Rewrite
14321433
$requestUri = $this->headers->get('X_REWRITE_URL');
1434+
$this->headers->remove('X_REWRITE_URL');
14331435
} elseif ($this->server->get('IIS_WasUrlRewritten') == '1' && $this->server->get('UNENCODED_URL') != '') {
14341436
// IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem)
14351437
$requestUri = $this->server->get('UNENCODED_URL');
1438+
$this->server->remove('UNENCODED_URL');
1439+
$this->server->remove('IIS_WasUrlRewritten');
14361440
} elseif ($this->server->has('REQUEST_URI')) {
14371441
$requestUri = $this->server->get('REQUEST_URI');
14381442
// HTTP proxy reqs setup request uri with scheme and host [and port] + the url path, only use url path
@@ -1446,8 +1450,12 @@ protected function prepareRequestUri()
14461450
if ('' != $this->server->get('QUERY_STRING')) {
14471451
$requestUri .= '?'.$this->server->get('QUERY_STRING');
14481452
}
1453+
$this->server->remove('ORIG_PATH_INFO');
14491454
}
14501455

1456+
// normalize the request URI to ease creating sub-requests from this request
1457+
$this->server->set('REQUEST_URI', $requestUri);
1458+
14511459
return $requestUri;
14521460
}
14531461

0 commit comments

Comments
 (0)
0