8000 Merge branch '3.2' · symfony/symfony@8701cae · GitHub
[go: up one dir, main page]

Skip to content

Commit 8701cae

Browse files
Merge branch '3.2'
* 3.2: Fixed the flickering when loading complex profiler panels [Console] Fix bar width with multilines ProgressBar's format [DI] Add missing check in PhpDumper [Serializer] XmlEncoder: fix negative int and large numbers handling [Console] Fix dispatching throwables from ConsoleEvents::COMMAND
2 parents 00a33dd + 8a8d92d commit 8701cae

File tree

10 files changed

+113
-38
lines changed

10 files changed

+113
-38
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
@@ -86,13 +86,6 @@
8686

8787
<div id="content" class="container">
8888
<div id="main">
89-
<div id="collector-wrapper">
90-
<div id="collector-content">
91-
{{ include('@WebProfiler/Profiler/base_js.html.twig') }}
92-
{% block panel '' %}
93-
</div>
94-
</div>
95-
9689
<div id="sidebar">
9790
<div id="sidebar-shortcuts">
9891
<div class="shortcuts">
@@ -130,6 +123,13 @@
130123
</ul>
131124
{% endif %}
132125
</div>
126+
127+
<div id="collector-wrapper">
128+
<div id="collector-content">
129+
{{ include('@WebProfiler/Profiler/base_js.html.twig') }}
130+
{% block panel '' %}
131+
</div>
132+
</div>
133133
</div>
134134
</div>
135135
<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
@@ -444,7 +444,7 @@ tr.status-warning td {
444444
}
445445
#main {
446446
display: flex;
447-
flex-direction: row-reverse;
447+
flex-direction: row;
448448
min-height: 100%;
449449
}
450450
#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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,9 +878,9 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
878878
}
879879

880880
$event = new ConsoleCommandEvent($command, $input, $output);
881+
$e = null;
881882

882883
try {
883-
$e = null;
884884
$this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
885885

886886
if ($event->commandShouldRun()) {

src/Symfony/Component/Console/Helper/ProgressBar.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,13 +603,19 @@ private function buildLine()
603603
};
604604
$line = preg_replace_callback($regex, $callback, $this->format);
605605

606-
$lineLength = Helper::strlenWithoutDecoration($this->output->getFormatter(), $line);
606+
// gets string length for each sub line with multiline format
607+
$linesLength = array_map(function ($subLine) {
608+
return Helper::strlenWithoutDecoration($this->output->getFormatter(), rtrim($subLine, "\r"));
609+
}, explode("\n", $line));
610+
611+
$linesWidth = max($linesLength);
612+
607613
$terminalWidth = $this->terminal->getWidth();
608-
if ($lineLength <= $terminalWidth) {
614+
if ($linesWidth <= $terminalWidth) {
609615
return $line;
610616
}
611617

612-
$this->setBarWidth($this->barWidth - $lineLength + $terminalWidth);
618+
$this->setBarWidth($this->barWidth - $linesWidth + $terminalWidth);
613619

614620
return preg_replace_callback($regex, $callback, $this->format);
615621
}

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,28 @@ public function testRunDispatchesAllEventsWithExceptionInListener()
10391039
$this->assertContains('before.error.after.', $tester->getDisplay());
10401040
}
10411041

1042+
public function testRunWithError()
1043+
{
1044+
$application = new Application();
1045+
$application->setAutoExit(false);
1046+
$application->setCatchExceptions(false);
1047+
1048+
$application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) {
1049+
$output->write('dym.');
1050+
1051+
throw new \Error('dymerr');
1052+
});
1053+
1054+
$tester = new ApplicationTester($application);
1055+
1056+
try {
1057+
$tester->run(array('command' => 'dym'));
1058+
$this->fail('Error expected.');
1059+
} catch (\Error $e) {
1060+
$this->assertSame('dymerr', $e->getMessage());
1061+
}
1062+
}
1063+
10421064
public function testRunAllowsErrorListenersToSilenceTheException()
10431065
{
10441066
$dispatcher = $this->getDispatcher();
@@ -1112,28 +1134,6 @@ public function testLegacyExceptionListenersAreStillTriggered()
11121134
$this->assertContains('replaced in caught.', $tester->getDisplay());
11131135
}
11141136

1115-
public function testRunWithError()
1116-
{
1117-
$application = new Application();
1118-
$application->setAutoExit(false);
1119-
$application->setCatchExceptions(false);
1120-
1121-
$application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) {
1122-
$output->write('dym.');
1123-
1124-
throw new \Error('dymerr');
1125-
});
1126-
1127-
$tester = new ApplicationTester($application);
1128-
1129-
try {
1130-
$tester->run(array('command' => 'dym'));
1131-
$this->fail('Error expected.');
1132-
} catch (\Error $e) {
1133-
$this->assertSame('dymerr', $e->getMessage());
1134-
}
1135-
}
1136-
11371137
/**
11381138
* @requires PHP 7
11391139
*/

src/Symfony/Component/Console/Tests/Helper/ProgressBarTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,4 +771,22 @@ protected function generateOutput($expected)
771771

772772
return "\x0D\x1B[2K".($count ? str_repeat("\x1B[1A\x1B[2K", $count) : '').$expected;
773773
}
774+
775+
public function testBarWidthWithMultilineFormat()
776+
{
777+
putenv('COLUMNS=10');
778+
779+
$bar = new ProgressBar($output = $this->getOutputStream());
780+
$bar->setFormat("%bar%\n0123456789");
781+
782+
// before starting
783+
$bar->setBarWidth(5);
784+
$this->assertEquals(5, $bar->getBarWidth());
785+
786+
// after starting
787+
$bar->start();
788+
rewind($output->getStream());
789+
$this->assertEquals(5, $bar->getBarWidth(), stream_get_contents($output->getStream()));
790+
putenv('COLUMNS=120');
791+
}
774792
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,9 @@ private function dumpValue($value, $interpolate = true)
14511451
if ($value->getMethodCalls()) {
14521452
throw new RuntimeException('Cannot dump definitions which have method calls.');
14531453
}
1454+
if ($value->getProperties()) {
1455+
throw new RuntimeException('Cannot dump definitions which have properties.');
1456+
}
14541457
if (null !== $value->getConfigurator()) {
14551458
throw new RuntimeException('Cannot dump definitions which have a configurator.');
14561459
}

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

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

308308
foreach ($node->attributes as $attr) {
309-
if (ctype_digit($attr->nodeValue)) {
310-
$data['@'.$attr->nodeName] = (int) $attr->nodeValue;
311-
} else {
309+
if (!is_numeric($attr->nodeValue)) {
312310
$data['@'.$attr->nodeName] = $attr->nodeValue;
311+
312+
continue;
313+
}
314+
315+
if (false !== $val = filter_var($attr->nodeValue, FILTER_VALIDATE_INT)) {
316+
$data['@'.$attr->nodeName] = $val;
317+
318+
continue;
313319
}
320+
321+
$data['@'.$attr->nodeName] = (float) $attr->nodeValue;
314322
}
315323

316324
return $data;

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

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

247+
public function testDecodeBigDigitAttributes()
248+
{
249+
$source = <<<XML
250+
<?xml version="1.0"?>
251+
<document index="182077241760011681341821060401202210011000045913000000017100">Name</document>
252+
XML;
253+
254+
$this->assertSame(array('@index' => 182077241760011681341821060401202210011000045913000000017100, '#' => 'Name'), $this->encoder->decode($source, 'xml'));
255+
}
256+
257+
public function testDecodeNegativeIntAttribute()
258+
{
259+
$source = <<<XML
260+
<?xml version="1.0"?>
261+
<document index="-1234">Name</document>
262+
XML;
263+
264+
$this->assertSame(array('@index' => -1234, '#' => 'Name'), $this->encoder->decode($source, 'xml'));
265+
}
266+
267+
public function testDecodeFloatAttribute()
268+
{
269+
$source = <<<XML
270+
<?xml version="1.0"?>
271+
<document index="-12.11">Name</document>
272+
XML;
273+
274+
$this->assertSame(array('@index' => -12.11, '#' => 'Name'), $this->encoder->decode($source, 'xml'));
275+
}
276+
277+
public function testDecodeNegativeFloatAttribute()
278+
{
279+
$source = <<<XML
280+
<?xml version="1.0"?>
281+
<document index="-12.11">Name</document>
282+
XML;
283+
284+
$this->assertSame(array('@index' => -12.11, '#' => 'Name'), $this->encoder->decode($source, 'xml'));
285+
}
286+
247287
public function testEncode()
248288
{
249289
$source = $this->getXmlSource();

0 commit comments

Comments
 (0)
0