Skip to content

Commit 9973db8

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: (25 commits) [2.6] link to https://symfony.com where possible Do not override PHP constants, only use when available link to https://symfony.com where possible [FrameworkBundle] Added missing log in server:run command [Finder] Only use GLOB_BRACE when available [HttpFoundation] Allow curly braces in trusted host patterns Fix merge Fix typo in variable name [profiler][security] check authenticated user by tokenClass instead of username. [WebProfiler] fix html syntax for input types [TwigBundle] Fix deprecated use of FlattenException [DependencyInjection] Removed extra strtolower calls Use https://symfony.com/search for searching [Debug] PHP7 compatibility with BaseException [Validator] Fixed Choice when an empty array is used in the "choices" option Fixed tests [StringUtil] Fixed singularification of 'selfies' Fix Portuguese (Portugal) translation for Security improved exception when missing required component [DependencyInjection] resolve circular reference ... Conflicts: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig src/Symfony/Component/Form/README.md src/Symfony/Component/Intl/README.md src/Symfony/Component/Security/README.md src/Symfony/Component/Translation/README.md src/Symfony/Component/Validator/README.md
2 parents e06adb7 + afdf5c4 commit 9973db8

File tree

10 files changed

+56
-41
lines changed

10 files changed

+56
-41
lines changed

Command/ServerCommand.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,25 @@ protected function getLockFile($address)
4141
{
4242
return sys_get_temp_dir().'/'.strtr($address, '.:', '--').'.pid';
4343
}
44+
45+
protected function isOtherServerProcessRunning($address)
46+
{
47+
$lockFile = $this->getLockFile($address);
48+
49+
if (file_exists($lockFile)) {
50+
return true;
51+
}
52+
53+
list($hostname, $port) = explode(':', $address);
54+
55+
$fp = @fsockopen($hostname, $port, $errno, $errstr, 5);
56+
57+
if (false !== $fp) {
58+
fclose($fp);
59+
60+
return true;
61+
}
62+
63+
return false;
64+
}
4465
}

Command/ServerRunCommand.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
* @author Michał Pipa <michal.pipa.xsolve@gmail.com>
2525
*/
26-
class ServerRunCommand extends ContainerAwareCommand
26+
class ServerRunCommand extends ServerCommand
2727
{
2828
/**
2929
* {@inheritdoc}
@@ -96,15 +96,28 @@ protected function execute(InputInterface $input, OutputInterface $output)
9696
}
9797

9898
$env = $this->getContainer()->getParameter('kernel.environment');
99+
$address = $input->getArgument('address');
100+
101+
if (false === strpos($address, ':')) {
102+
$output->writeln('The address has to be of the form <comment>bind-address:port</comment>.');
103+
104+
return 1;
105+
}
106+
107+
if ($this->isOtherServerProcessRunning($address)) {
108+
$output->writeln(sprintf('<error>A process is already listening on http://%s.</error>', $address));
109+
110+
return 1;
111+
}
99112

100113
if ('prod' === $env) {
101114
$output->writeln('<error>Running PHP built-in server in production environment is NOT recommended!</error>');
102115
}
103116

104-
$output->writeln(sprintf("Server running on <info>http://%s</info>\n", $input->getArgument('address')));
117+
$output->writeln(sprintf("Server running on <info>http://%s</info>\n", $address));
105118
$output->writeln('Quit the server with CONTROL-C.');
106119

107-
if (null === $builder = $this->createPhpProcessBuilder($input, $output, $env)) {
120+
if (null === $builder = $this->createPhpProcessBuilder($output, $address, $input->getOption('router'), $env)) {
108121
return 1;
109122
}
110123

@@ -131,9 +144,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
131144
return $process->getExitCode();
132145
}
133146

134-
private function createPhpProcessBuilder(InputInterface $input, OutputInterface $output, $env)
147+
private function createPhpProcessBuilder(OutputInterface $output, $address, $router, $env)
135148
{
136-
$router = $input->getOption('router') ?: $this
149+
$router = $router ?: $this
137150
->getContainer()
138151
->get('kernel')
139152
->locateResource(sprintf('@FrameworkBundle/Resources/config/router_%s.php', $env))
@@ -154,6 +167,6 @@ private function createPhpProcessBuilder(InputInterface $input, OutputInterface
154167
return;
155168
}
156169

157-
return new ProcessBuilder(array($binary, '-S', $input->getArgument('address'), $router));
170+
return new ProcessBuilder(array($binary, '-S', $address, $router));
158171
}
159172
}

Command/ServerStartCommand.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -167,27 +167,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
167167
}
168168
}
169169

170-
private function isOtherServerProcessRunning($address)
171-
{
172-
$lockFile = $this->getLockFile($address);
173-
174-
if (file_exists($lockFile)) {
175-
return true;
176-
}
177-
178-
list($hostname, $port) = explode(':', $address);
179-
180-
$fp = @fsockopen($hostname, $port, $errno, $errstr, 5);
181-
182-
if (false !== $fp) {
183-
fclose($fp);
184-
185-
return true;
186-
}
187-
188-
return false;
189-
}
190-
191170
/**
192171
* Determine the absolute file path for the router script, using the environment to choose a standard script
193172
* if no custom router script is specified.

Command/TranslationUpdateCommand.php

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

155-
if ($input->getOption('output-format') == 'xliff') {
155+
if ($input->getOption('output-format') == 'xlf') {
156156
$output->writeln('Xliff output version is <info>1.2</info>');
157157
}
158158
}

Command/YamlLintCommand.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Command;
1313

14-
if (!defined('JSON_PRETTY_PRINT')) {
15-
define('JSON_PRETTY_PRINT', 128);
16-
}
17-
1814
use Symfony\Component\Console\Command\Command;
1915
use Symfony\Component\Console\Input\InputInterface;
2016
use Symfony\Component\Console\Input\InputOption;
@@ -161,7 +157,7 @@ private function displayJson(OutputInterface $output, $filesInfo)
161157
}
162158
});
163159

164-
$output->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT));
160+
$output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0));
165161

166162
return min($errors, 1);
167163
}

Console/Descriptor/JsonDescriptor.php

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

1212
namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;
1313

14-
if (!defined('JSON_PRETTY_PRINT')) {
15-
define('JSON_PRETTY_PRINT', 128);
16-
}
17-
1814
use Symfony\Component\DependencyInjection\Alias;
1915
use Symfony\Component\DependencyInjection\ContainerBuilder;
2016
use Symfony\Component\DependencyInjection\Definition;
@@ -174,7 +170,13 @@ protected function describeContainerParameter($parameter, array $options = array
174170
*/
175171
private function writeData(array $data, array $options)
176172
{
177-
$this->write(json_encode($data, (isset($options['json_encoding']) ? $options['json_encoding'] : 0) | JSON_PRETTY_PRINT)."\n");
173+
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
174+
175+
if (defined('JSON_PRETTY_PRINT')) {
176+
$flags |= JSON_PRETTY_PRINT;
177+
}
178+
179+
$this->write(json_encode($data, $flags)."\n");
178180
}
179181

180182
/**

Resources/config/router_dev.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@
3434
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'app_dev.php';
3535

3636
require 'app_dev.php';
37+
38+
error_log(sprintf('%s:%d [%d]: %s', $_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_PORT'], http_response_code(), $_SERVER['REQUEST_URI']), 4);

Resources/config/router_prod.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@
3434
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'app.php';
3535

3636
require 'app.php';
37+
38+
error_log(sprintf('%s:%d [%d]: %s', $_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_PORT'], http_response_code(), $_SERVER['REQUEST_URI']), 4);

Translation/PhpStringTokenParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class PhpStringTokenParser
5151
{
5252
protected static $replacements = array(
5353
'\\' => '\\',
54-
'$' => '$',
54+
'$' => '$',
5555
'n' => "\n",
5656
'r' => "\r",
5757
't' => "\t",

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "symfony-bundle",
44
"description": "Symfony FrameworkBundle",
55
"keywords": [],
6-
"homepage": "http://symfony.com",
6+
"homepage": "https://symfony.com",
77
"license": "MIT",
88
"authors": [
99
{
@@ -12,7 +12,7 @@
1212
},
1313
{
1414
"name": "Symfony Community",
15-
"homepage": "http://symfony.com/contributors"
15+
"homepage": "https://symfony.com/contributors"
1616
}
1717
],
1818
"require": {

0 commit comments

Comments
 (0)