Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c09128c

Browse filesBrowse files
committed
Merge branch '4.4'
* 4.4: [HttpFoundation] fix not sending Content-Type header for 204 responses [ErrorHandler] silence warning when zend.assertions=-1 [Console] Handle zero row count in appendRow() for Table
2 parents a603b14 + 1a7e4ea commit c09128c
Copy full SHA for c09128c

File tree

Expand file treeCollapse file tree

5 files changed

+41
-13
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+41
-13
lines changed

‎src/Symfony/Component/Console/Helper/Table.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/Table.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,9 @@ private function calculateRowCount(): int
589589
++$numberOfRows; // Add row for header separator
590590
}
591591

592-
++$numberOfRows; // Add row for footer separator
592+
if (\count($this->rows) > 0) {
593+
++$numberOfRows; // Add row for footer separator
594+
}
593595

594596
return $numberOfRows;
595597
}

‎src/Symfony/Component/Console/Tests/Helper/TableTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/Helper/TableTest.php
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,38 @@ public function testAppendRowWithoutSectionOutput()
951951
$table->appendRow(['9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens', '139.25']);
952952
}
953953

954+
public function testSectionOutputHandlesZeroRowsAfterRender()
955+
{
956+
$sections = [];
957+
$stream = $this->getOutputStream(true);
958+
$output = new ConsoleSectionOutput($stream->getStream(), $sections, $stream->getVerbosity(), $stream->isDecorated(), new OutputFormatter());
959+
$output->writeln('My Table');
960+
$table = new Table($output);
961+
$table
962+
->setHeaders(['ISBN', 'Title', 'Author', 'Price'])
963+
->setRows([]);
964+
965+
$table->render();
966+
967+
$table->appendRow(['9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens', '139.25']);
968+
969+
$expected =
970+
<<<TABLE
971+
My Table
972+
+------+-------+--------+-------+
973+
|\033[32m ISBN \033[39m|\033[32m Title \033[39m|\033[32m Author \033[39m|\033[32m Price \033[39m|
974+
+------+-------+--------+-------+
975+
\x1b[3A\x1b[0J+---------------+----------------------+-----------------+--------+
976+
|\033[32m ISBN \033[39m|\033[32m Title \033[39m|\033[32m Author \033[39m|\033[32m Price \033[39m|
977+
+---------------+----------------------+-----------------+--------+
978+
| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | 139.25 |
979+
+---------------+----------------------+-----------------+--------+
980+
981+
TABLE;
982+
983+
$this->assertEquals($expected, $this->getOutputContent($output));
984+
}
985+
954986
public function testIsNotDefinedStyleException()
955987
{
956988
$this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException');

‎src/Symfony/Component/ErrorHandler/Debug.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ErrorHandler/Debug.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static function enable(): ErrorHandler
2929
ini_set('display_errors', 1);
3030
}
3131

32-
ini_set('zend.assertions', 1);
32+
@ini_set('zend.assertions', 1);
3333
ini_set('assert.active', 1);
3434
ini_set('assert.warning', 0);
3535
ini_set('assert.exception', 1);

‎src/Symfony/Component/HttpFoundation/Response.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Response.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,12 @@ public function prepare(Request $request)
262262
$this->setContent(null);
263263
$headers->remove('Content-Type');
264264
$headers->remove('Content-Length');
265+
// prevent PHP from sending the Content-Type header based on default_mimetype
266+
ini_set('default_mimetype', '');
265267
} else {
266268
// Content-type based on the Request
267269
if (!$headers->has('Content-Type')) {
268-
$format = $request->getPreferredFormat();
270+
$format = $request->getPreferredFormat(null);
269271
if (null !== $format && $mimeType = $request->getMimeType($format)) {
270272
$headers->set('Content-Type', $mimeType);
271273
}

‎src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
+2-10Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -464,18 +464,10 @@ public function testSetVary()
464464

465465
public function testDefaultContentType()
466466
{
467-
$headerMock = $this->getMockBuilder('Symfony\Component\HttpFoundation\ResponseHeaderBag')->setMethods(['set'])->getMock();
468-
$headerMock->expects($this->at(0))
469-
->method('set')
470-
->with('Content-Type', 'text/html');
471-
$headerMock->expects($this->at(1))
472-
->method('set')
473-
->with('Content-Type', 'text/html; charset=UTF-8');
474-
475467
$response = new Response('foo');
476-
$response->headers = $headerMock;
477-
478468
$response->prepare(new Request());
469+
470+
$this->assertSame('text/html; charset=UTF-8', $response->headers->get('Content-Type'));
479471
}
480472

481473
public function testContentTypeCharset()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.