Skip to content

Commit 6567abe

Browse files
Merge branch '5.1'
* 5.1: Fix abstract method name in PHP doc block Various cleanups [HttpClient] fix issues in tests Fixes sprintf(): Too few arguments in form transformer [Console] Fix QuestionHelper::disableStty() [Validator] Use Mime component to determine mime type for file validator validate subforms in all validation groups Update Hungarian translations Add meaningful message when Process is not installed (ProcessHelper) [Messenger] Change the default notify timeout value for PostgreSQL [PropertyAccess] Fix TypeError parsing again. [TwigBridge] fix fallback html-to-txt body converter [Security/Http] fix merge [ErrorHandler] fix setting $trace to null in FatalError [Form] add missing Czech validators translation [Validator] add missing Czech translations never directly validate Existence (Required/Optional) constraints
2 parents f9411ab + 51da623 commit 6567abe

File tree

54 files changed

+327
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+327
-98
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ before_install:
151151
INI=~/.phpenv/versions/$PHP/etc/conf.d/travis.ini
152152
echo date.timezone = Europe/Paris >> $INI
153153
echo memory_limit = -1 >> $INI
154+
echo default_socket_timeout = 10 >> $INI
154155
echo session.gc_probability = 0 >> $INI
155156
echo opcache.enable_cli = 1 >> $INI
156157
echo apc.enable_cli = 1 >> $INI

src/Symfony/Bridge/Monolog/Command/ServerLogCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
102102
}
103103

104104
if (!$socket = stream_socket_server($host, $errno, $errstr)) {
105-
throw new RuntimeException(sprintf('Server start failed on "%s": '.$errstr.' '.$errno, $host));
105+
throw new RuntimeException(sprintf('Server start failed on "%s": ', $host).$errstr.' '.$errno);
106106
}
107107

108108
foreach ($this->getLogs($socket) as $clientId => $message) {

src/Symfony/Bridge/Twig/Mime/BodyRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ private function convertHtmlToText(string $html): string
7474
return $this->converter->convert($html);
7575
}
7676

77-
return strip_tags($html);
77+
return strip_tags(preg_replace('{<(head|style)\b.*?</\1>}i', '', $html));
7878
}
7979
}

src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ public function testRenderTextOnly(): void
2929

3030
public function testRenderHtmlOnly(): void
3131
{
32-
$email = $this->prepareEmail(null, '<b>HTML</b>');
32+
$html = '<head>head</head><b>HTML</b><style type="text/css">css</style>';
33+
$email = $this->prepareEmail(null, $html);
3334
$body = $email->getBody();
3435
$this->assertInstanceOf(AlternativePart::class, $body);
3536
$this->assertEquals('HTML', $body->getParts()[0]->bodyToString());
36-
$this->assertEquals('<b>HTML</b>', $body->getParts()[1]->bodyToString());
37+
$this->assertEquals(str_replace('=', '=3D', $html), $body->getParts()[1]->bodyToString());
3738
}
3839

3940
public function testRenderHtmlOnlyWithTextSet(): void

src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private function getManifestPath(string $path): ?string
5959

6060
$this->manifestData = json_decode(file_get_contents($this->manifestPath), true);
6161
if (0 < json_last_error()) {
62-
throw new \RuntimeException(sprintf('Error parsing JSON from asset manifest file "%s": '.json_last_error_msg(), $this->manifestPath));
62+
throw new \RuntimeException(sprintf('Error parsing JSON from asset manifest file "%s": ', $this->manifestPath).json_last_error_msg());
6363
}
6464
}
6565

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ class ProcessHelper extends Helper
3636
*/
3737
public function run(OutputInterface $output, $cmd, string $error = null, callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process
3838
{
39+
if (!class_exists(Process::class)) {
40+
throw new \LogicException('The ProcessHelper cannot be run as the Process component is not installed. Try running "compose require symfony/process".');
41+
}
42+
3943
if ($output instanceof ConsoleOutputInterface) {
4044
$output = $output->getErrorOutput();
4145
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class QuestionHelper extends Helper
3535
{
3636
private $inputStream;
3737
private static $shell;
38-
private static $stty;
38+
private static $stty = true;
3939

4040
/**
4141
* Asks a question to the user.
@@ -109,7 +109,7 @@ private function doAsk(OutputInterface $output, Question $question)
109109
$inputStream = $this->inputStream ?: STDIN;
110110
$autocomplete = $question->getAutocompleterCallback();
111111

112-
if (null === $autocomplete || !Terminal::hasSttyAvailable()) {
112+
if (null === $autocomplete || !self::$stty || !Terminal::hasSttyAvailable()) {
113113
$ret = false;
114114
if ($question->isHidden()) {
115115
try {
@@ -416,7 +416,7 @@ private function getHiddenResponse(OutputInterface $output, $inputStream, bool $
416416
return $value;
417417
}
418418

419-
if (Terminal::hasSttyAvailable()) {
419+
if (self::$stty && Terminal::hasSttyAvailable()) {
420420
$sttyMode = shell_exec('stty -g');
421421

422422
shell_exec('stty -echo');

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Console\Tests\Helper;
1313

14+
use Symfony\Component\Console\Exception\InvalidArgumentException;
1415
use Symfony\Component\Console\Formatter\OutputFormatter;
1516
use Symfony\Component\Console\Helper\FormatterHelper;
1617
use Symfony\Component\Console\Helper\HelperSet;
@@ -783,6 +784,35 @@ public function testTraversableAutocomplete()
783784
$this->assertEquals('FooBundle', $dialog->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question));
784785
}
785786

787+
public function testDisableSttby()
788+
{
789+
if (!Terminal::hasSttyAvailable()) {
790+
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
791+
}
792+
793+
$this->expectException(InvalidArgumentException::class);
794+
$this->expectExceptionMessage('invalid');
795+
796+
QuestionHelper::disableStty();
797+
$dialog = new QuestionHelper();
798+
$dialog->setHelperSet(new HelperSet([new FormatterHelper()]));
799+
800+
$question = new ChoiceQuestion('Please select a bundle', [1 => 'AcmeDemoBundle', 4 => 'AsseticBundle']);
801+
$question->setMaxAttempts(1);
802+
803+
// <UP ARROW><UP ARROW><NEWLINE><DOWN ARROW><DOWN ARROW><NEWLINE>
804+
// Gives `AcmeDemoBundle` with stty
805+
$inputStream = $this->getInputStream("\033[A\033[A\n\033[B\033[B\n");
806+
807+
try {
808+
$dialog->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question);
809+
} finally {
810+
$reflection = new \ReflectionProperty(QuestionHelper::class, 'stty');
811+
$reflection->setAccessible(true);
812+
$reflection->setValue(null, true);
813+
}
814+
}
815+
786816
public function testTraversableMultiselectAutocomplete()
787817
{
788818
// <NEWLINE>

src/Symfony/Component/DependencyInjection/EnvVarProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv)
227227
$env = json_decode($env, true);
228228

229229
if (JSON_ERROR_NONE !== json_last_error()) {
230-
throw new RuntimeException(sprintf('Invalid JSON in env var "%s": '.json_last_error_msg(), $name));
230+
throw new RuntimeException(sprintf('Invalid JSON in env var "%s": ', $name).json_last_error_msg());
231231
}
232232

233233
if (null !== $env && !\is_array($env)) {

src/Symfony/Component/ErrorHandler/Error/FatalError.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ public function __construct(string $message, int $code, array $error, int $trace
7272
'line' => $error['line'],
7373
'trace' => $trace,
7474
] as $property => $value) {
75-
$refl = new \ReflectionProperty(\Error::class, $property);
76-
$refl->setAccessible(true);
77-
$refl->setValue($this, $value);
75+
if (null !== $value) {
76+
$refl = new \ReflectionProperty(\Error::class, $property);
77+
$refl->setAccessible(true);
78+
$refl->setValue($this, $value);
79+
}
7880
}
7981
}
8082

0 commit comments

Comments
 (0)