8000 Merge branch '2.8' into 3.2 · symfony/symfony@8a8d92d · GitHub
[go: up one dir, main page]

Skip to content

Commit 8a8d92d

Browse files
Merge branch '2.8' into 3.2
* 2.8: Fixed the flickering when loading complex profiler panels [DI] Add missing check in PhpDumper [Serializer] XmlEncoder: fix negative int and large numbers handling [Console] Fix dispatching throwables from ConsoleEvents::COMMAND
2 parents 2145f56 + 3adff11 commit 8a8d92d

File tree

8 files changed

+149
-77
lines changed

8 files changed

+149
-77
lines changed

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

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

8585
<div id="content" class="container">
8686
<div id="main">
87-
<div id="collector-wrapper">
88-
<div id="collector-content">
89-
{{ include('@WebProfiler/Profiler/base_js.html.twig') }}
90-
{% block panel '' %}
91-
</div>
92-
</div>
93-
9487
<div id="sidebar">
9588
<div id="sidebar-shortcuts">
9689
<div class="shortcuts">
@@ -128,6 +121,13 @@
128121
</ul>
129122
{% endif %}
130123
</div>
124+
< 57AE /td>
125+
<div id="collector-wrapper">
126+
<div id="collector-content">
127+
{{ include('@WebProfiler/Profiler/base_js.html.twig') }}
128+
{% block panel '' %}
129+
</div>
130+
</div>
131131
</div>
132132
</div>
133133
<script>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/profiler.css.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ tr.status-warning td {
440440
}
441441
#main {
442442
display: flex;
443-
flex-direction: row-reverse;
443+
flex-direction: row;
444444
min-height: 100%;
445445
}
446446
#sidebar {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div id="sidebar-search">
1+
<div id="sidebar-search" class="hidden">
22
<form action="{{ path('_profiler_search') }}" method="get">
33
<div class="form-group">
44
<label for="ip">IP</label>

src/Symfony/Component/Console/Application.php

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,17 @@ public function run(InputInterface $input = null, OutputInterface $output = null
120120
$this->configureIO($input, $output);
121121

122122
try {
123+
$e = null;
123124
$exitCode = $this->doRun($input, $output);
124-
} catch (\Exception $e) {
125+
} catch (\Exception $x) {
126+
$e = $x;
127+
} catch (\Throwable $x) {
128+
$e = new FatalThrowableError($x);
129+
}
130+
131+
if (null !== $e) {
125132
if (!$this->catchExceptions) {
126-
throw $e;
133+
throw $x;
127134
}
128135

129136
if ($output instanceof ConsoleOutputInterface) {
@@ -185,6 +192,7 @@ public function doRun(InputInterface $input, OutputInterface $output)
185192
$input = new ArrayInput(array('command' => $this->defaultCommand));
186193
}
187194

195+
$this->runningCommand = null;
188196
// the command name MUST be the first element of the input
189197
$command = $this->find($name);
190198

@@ -824,13 +832,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
824832
}
825833

826834
if (null === $this->dispatcher) {
827-
try {
828-
return $command->run($input, $output);
829-
} catch (\Exception $e) {
830-
throw $e;
831-
} catch (\Throwable $e) {
832-
throw new FatalThrowableError($e);
833-
}
835+
return $command->run($input, $output);
834836
}
835837

836838
// bind before the console.command event, so the listeners have access to input options/arguments
@@ -842,37 +844,37 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
842844
}
843845

844846
$event = new ConsoleCommandEvent($command, $input, $output);
845-
$this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
847+
$e = null;
848+
849+
try {
850+
$this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
846851

847-
if ($event->commandShouldRun()) {
848-
try {
849-
$e = null;
852+
if ($event->commandShouldRun()) {
850853
$exitCode = $command->run($input, $output);
851-
} catch (\Exception $x) {
852-
$e = $x;
853-
} catch (\Throwable $x) {
854-
$e = new FatalThrowableError($x);
854+
} else {
855+
$exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
855856
}
856-
if (null !== $e) {
857-
$event = new ConsoleExceptionEvent($command, $input, $output, $e, $e->getCode());
858-
$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
859-
860-
if ($e !== $event->getException()) {
861-
$x = $e = $event->getException();
862-
}
863-
864-
$event = new ConsoleTerminateEvent($command, $input, $output, $e->getCode());
865-
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
857+
} catch (\Exception $e) {
858+
} catch (\Throwable $e) {
859+
}
860+
if (null !== $e) {
861+
$x = $e instanceof \Exception ? $e : new FatalThrowableError($e);
862+
$event = new ConsoleExceptionEvent($command, $input, $output, $x, $x->getCode());
863+
$this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
866864

867-
throw $x;
865+
if ($x !== $event->getException()) {
866+
$e = $event->getException();
868867
}
869-
} else {
870-
$exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
868+
$exitCode = $e->getCode();
871869
}
872870

873871
$event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
874872
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
875873

874+
if (null !== $e) {
875+
throw $e;
876+
}
877+
876878
return $event->getExitCode();
877879
}
878880

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -969,15 +969,28 @@ public function testRunDispatchesAllEventsWithException()
969969
$this->assertContains('before.foo.caught.after.', $tester->getDisplay());
970970
}
971971

972-
public function testRunWithError()
972+
public function testRunDispatchesAllEventsWithExceptionInListener()
973973
{
974-
if (method_exists($this, 'expectException')) {
975-
$this->expectException('Exception');
976-
$this->expectExceptionMessage('dymerr');
977-
} else {
978-
$this->setExpectedException('Exception', 'dymerr');
979-
}
974+
$dispatcher = $this->getDispatcher();
975+
$dispatcher->addListener('console.command', function () {
976+
throw new \RuntimeException('foo');
977+
});
978+
979+
$application = new Application();
980+
$application->setDispatcher($dispatcher);
981+
$application->setAutoExit(false);
982+
983+
$application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) {
984+
$output->write('foo.');
985+
});
986+
987+
$tester = new ApplicationTester($application);
988+
$tester->run(array('command' => 'foo'));
989+
$this->assertContains('before.caught.after.', $tester->getDisplay());
990+
}
980991

992+
public function testRunWithError()
993+
{
981994
$application = new Application();
982995
$application->setAutoExit(false);
983996
$application->setCatchExceptions(false);
@@ -989,7 +1002,13 @@ public function testRunWithError()
9891002
});
9901003

9911004
$tester = new ApplicationTester($application);
992-
$tester->run(array('command' => 'dym'));
1005+
1006+
try {
1007+
$tester->run(array('command' => 'dym'));
1008+
$this->fail('Error expected.');
1009+
} catch (\Error $e) {
1010+
$this->assertSame('dymerr', $e->getMessage());
1011+
}
9931012
}
9941013

9951014
/**
@@ -1139,32 +1158,6 @@ public function testTerminalDimensions()
11391158
$this->assertSame(array($width, 80), $application->getTerminalDimensions());
11401159
}
11411160

1142-
protected function getDispatcher($skipCommand = false)
1143-
{
1144-
$dispatcher = new EventDispatcher();
1145-
$dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use ($skipCommand) {
1146-
$event->getOutput()->write('before.');
1147-
1148-
if ($skipCommand) {
1149-
$event->disableCommand();
1150-
}
1151-
});
1152-
$dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($skipCommand) {
1153-
$event->getOutput()->writeln('after.');
1154-
1155-
if (!$skipCommand) {
1156-
$event->setExitCode(113);
1157-
}
1158-
});
1159-
$dispatcher->addListener('console.exception', function (ConsoleExceptionEvent $event) {
1160-
$event->getOutput()->write('caught.');
1161-
1162-
$event->setException(new \LogicException('caught.', $event->getExitCode(), $event->getException()));
1163-
});
1164-
1165-
return $dispatcher;
1166-
}
1167-
11681161
public function testSetRunCustomDefaultCommand()
11691162
{
11701163
$command = new \FooCommand();
@@ -1221,6 +1214,32 @@ public function testCanCheckIfTerminalIsInteractive()
12211214
$inputStream = $tester->getInput()->getStream();
12221215
$this->assertEquals($tester->getInput()->isInteractive(), @posix_isatty($inputStream));
12231216
}
1217+
1218+
protected function getDispatcher($skipCommand = false)
1219+
{
1220+
$dispatcher = new EventDispatcher();
1221+
$dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) use ($skipCommand) {
1222+
$event->getOutput()->write('before.');
1223+
1224+
if ($skipCommand) {
1225+
$event->disableCommand();
1226+
}
1227+
});
1228+
$dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($skipCommand) {
1229+
$event->getOutput()->writeln('after.');
1230+
1231+
if (!$skipCommand) {
1232+
$event->setExitCode(ConsoleCommandEvent::RETURN_CODE_DISABLED);
1233+
}
1234+
});
1235+
$dispatcher->addListener('console.exception', function (ConsoleExceptionEvent $event) {
1236+
$event->getOutput()->write('caught.');
1237+
1238+
$event->setException(new \LogicException('caught.', $event->getExitCode(), $event->getException()));
1239+
});
1240+
1241+
return $dispatcher;
1242+
}
12241243
}
12251244

12261245
class CustomApplication extends Application

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,9 +1349,12 @@ private function dumpValue($value, $interpolate = true)
13491349
if (null !== $this->definitionVariables && $this->definitionVariables->contains($value)) {
13501350
return $this->dumpValue($this->definitionVariables->offsetGet($value), $interpolate);
13511351
}
1352-
if (count($value->getMethodCalls()) > 0) {
1352+
if ($value->getMethodCalls()) {
13531353
throw new RuntimeException('Cannot dump definitions which have method calls.');
13541354
}
1355+
if ($value->getProperties()) {
1356+
throw new RuntimeException('Cannot dump definitions which have properties.');
1357+
}
13551358
if (null !== $value->getConfigurator()) {
13561359
throw new RuntimeException('Cannot dump definitions which have a configurator.');
13571360
}

src/Symfony/Component/Serializer/Encoder/XmlEncoder.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,19 @@ private function parseXmlAttributes(\DOMNode $node)
304304
$data = array();
305305

306306
foreach ($node->attributes as $attr) {
307-
if (ctype_digit($attr->nodeValue)) {
308-
$data['@'.$attr->nodeName] = (int) $attr->nodeValue;
309-
} else {
307+
if (!is_numeric($attr->nodeValue)) {
310308
$data['@'.$attr->nodeName] = $attr->nodeValue;
309+
310+
continue;
311+
}
312+
313+
if (false !== $val = filter_var($attr->nodeValue, FILTER_VALIDATE_INT)) {
314+
$data['@'.$attr->nodeName] = $val;
315+
316+
continue;
311317
}
318+
319+
$data['@'.$attr->nodeName] = (float) $attr->nodeValue;
312320
}
313321

314322
return $data;

src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,46 @@ public function testDecodeScalar()
222222
$this->assertEquals('foo', $this->encoder->decode($source, 'xml'));
223223
}
224224

225+
public function testDecodeBigDigitAttributes()
226+
{
227+
$source = <<<XML
228+
<?xml version="1.0"?>
229+
<document index="182077241760011681341821060401202210011000045913000000017100">Name</document>
230+
XML;
231+
232+
$this->assertSame(array('@index' => 182077241760011681341821060401202210011000045913000000017100, '#' => 'Name'), $this->encoder->decode($source, 'xml'));
233+
}
234+
235+
public function testDecodeNegativeIntAttribute()
236+
{
237+
$source = <<<XML
238+
<?xml version="1.0"?>
239+
<document index="-1234">Name</document>
240+
XML;
241+
242+
$this->assertSame(array('@index' => -1234, '#' => 'Name'), $this->encoder->decode($source, 'xml'));
243+
}
244+
245+
public function testDecodeFloatAttribute()
246+
{
247+
$source = <<<XML
248+
<?xml version="1.0"?>
249+
<document index="-12.11">Name</document>
250+
XML;
251+
252+
$this->assertSame(array('@index' => -12.11, '#' => 'Name'), $this->encoder->decode($source, 'xml'));
253+
}
254+
255+
public function testDecodeNegativeFloatAttribute()
256+
{
257+
$source = <<<XML
258+
<?xml version="1.0"?>
259+
<document index="-12.11">Name</document>
260+
XML;
261+
262+
$this->assertSame(array('@index' => -12.11, '#' => 'Name'), $this->encoder->decode($source, 'xml'));
263+
}
264+
225265
public function testEncode()
226266
{
227267
$source = $this->getXmlSource();

0 commit comments

Comments
 (0)
0