8000 Merge branch '3.0' · SCIF/symfony@676ddab · GitHub
[go: up one dir, main page]

Skip to content

Commit 676ddab

Browse files
Merge branch '3.0'
* 3.0: [Process] Fix transient test on Windows [Process] Make tests more deterministic [PropertyAccess] Reorder elements array after PropertyPathBuilder::replace [Validator] fixed wrong php docs Improved the design of the web debug toolbar [Routing] Skip PhpGeneratorDumperTest::testDumpWithTooManyRoutes on HHVM [Process] More robustness and deterministic tests
2 parents e93ef5d + 6c5f736 commit 676ddab

File tree

11 files changed

+232
-233
lines changed

11 files changed

+232
-233
lines changed

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
'subtle_border_and_shadow': 'background: #FFF; border: 1px solid #E0E0E0; box-shadow: 0px 0px 1px rgba(128, 128, 128, .2);'
88
} %}
99

10+
{# when updating any of these colors, do the same in toolbar.css.twig #}
11+
{% set colors = { 'success': '#4F805D', 'warning': '#A46A1F', 'error': '#B0413E' } %}
12+
1013
{# Normalization
1114
(normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css)
1215
========================================================================= #}
@@ -232,9 +235,9 @@ table tbody ul {
232235
padding: 3px 7px;
233236
white-space: nowrap;
234237
}
235-
.label.status-success { background: #5E976E; color: #FFF; }
236-
.label.status-warning { background: #BC8034; color: #FFF; }
237-
.label.status-error { background: #B0413E; color: #FFF; }
238+
.label.status-success { background: {{ colors.success|raw }}; color: #FFF; }
239+
.label.status-warning { background: {{ colors.warning|raw }}; color: #FFF; }
240+
.label.status-error { background: {{ colors.error|raw }}; color: #FFF; }
238241

239242
{# Metrics
240243
------------------------------------------------------------------------- #}
@@ -341,11 +344,11 @@ tr.status-warning td {
341344
border-top: 1px solid #FAFAFA;
342345
}
343346

344-
.status-warning .colored {
345-
color: #BC8034;
347+
.status-warning .colored {
348+
color: {{ colors.warning|raw }};
346349
}
347350
.status-error .colored {
348-
color: #B0413E;
351+
color: {{ colors.error|raw }};
349352
}
350353

351354
{# Syntax highlighting
@@ -469,9 +472,9 @@ tr.status-warning td {
469472
text-decoration: underline;
470473
}
471474

472-
#summary .status-success { background: #5E976E; }
473-
#summary .status-warning { background: #BC8034; }
474-
#summary .status-error { background: #B0413E; }
475+
#summary .status-success { background: {{ colors.success|raw }}; }
476+
#summary .status-warning { background: {{ colors.warning|raw }}; }
477+
#summary .status-error { background: {{ colors.error|raw }}; }
475478

476479
#summary .status-success h2,
477480
#summary .status-success h2 a,
@@ -670,10 +673,10 @@ tr.status-warning td {
670673
}
671674

672675
#menu-profiler .label-status-warning .count {
673-
background: #BC8034;
676+
background: {{ colors.warning|raw }};
674677
}
675678
#menu-profiler .label-status-error .count {
676-
background: #B0413E;
679+
background: {{ colors.error|raw }};
677680
}
678681

679682
{# Timeline panel

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
{# when updating any of these colors, do the same in profiler.css.twig #}
2+
{% set colors = { 'success': '#4F805D', 'warning': '#A46A1F', 'error': '#B0413E' } %}
3+
14
.sf-minitoolbar {
25
background-color: #222;
36
border-top-left-radius: 4px;
@@ -46,8 +49,8 @@
4649
}
4750
.sf-toolbarreset svg,
4851
.sf-toolbarreset img {
49-
max-height: 24px;
50-
max-width: 24px;
52+
max-height: 20px;
53+
max-width: 20px;
5154
}
5255

5356
.sf-toolbarreset .hide-button {
@@ -180,30 +183,31 @@
180183
padding: 3px 6px;
181184
margin-bottom: 2px;
182185
vertical-align: middle;
183-
min-width: 6px;
186+
min-width: 15px;
184187
min-height: 13px;
188+
text-align: center;
185189
}
186190

187191
.sf-toolbar-block .sf-toolbar-status-green {
188-
background-color: rgba(117, 158, 43, 0.8);
192+
background-color: {{ colors.success|raw }};
189193
}
190194
.sf-toolbar-block .sf-toolbar-status-red {
191-
background-color: rgba(200, 43, 43, 0.8);
195+
background-color: {{ colors.error|raw }};
192196
}
193197
.sf-toolbar-block .sf-toolbar-status-yellow {
194-
background-color: rgb(189, 132, 0);
198+
background-color: {{ colors.warning|raw }};
195199
}
196200

197201
.sf-toolbar-block.sf-toolbar-status-green {
198-
background-color: rgba(117, 158, 43, 0.8);
202+
background-color: {{ colors.success|raw }};
199203
color: #FFF;
200204
}
201205
.sf-toolbar-block.sf-toolbar-status-red {
202-
background-color: rgba(200, 43, 43, 0.8);
206+
background-color: {{ colors.error|raw }};
203207
color: #FFF;
204208
}
205209
.sf-toolbar-block.sf-toolbar-status-yellow {
206-
background-color: rgb(189, 132, 0);
210+
background-color: {{ colors.warning|raw }};
207211
color: #FFF;
208212
}
209213

src/Symfony/Component/Process/PhpProcess.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ public function __construct($script, $cwd = null, array $env = null, $timeout =
4646
$php .= ' '.ProcessUtils::escapeArgument($file);
4747
$script = null;
4848
}
49+
if ('\\' !== DIRECTORY_SEPARATOR && null !== $php) {
50+
// exec is mandatory to deal with sending a signal to the process
51+
// see https://github.com/symfony/symfony/issues/5030 about prepending
52+
// command with exec
53+
$php = 'exec '.$php;
54+
}
4955

5056
parent::__construct($php, $cwd, $env, $script, $timeout, $options);
5157
}

src/Symfony/Component/Process/Process.php

Lines changed: 41 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ class Process
7676

7777
private static $sigchild;
7878
private static $posixSignals = array(
79-
1 => 1, // SIGHUP
80-
2 => 2, // SIGINT
81-
3 => 3, // SIGQUIT
82-
6 => 6, // SIGABRT
83-
14 => 14, // SIGALRM
84-
15 => 15, // SIGTERM
79+
1, // SIGHUP
80+
2, // SIGINT
81+
3, // SIGQUIT
82+
6, // SIGABRT
83+
14, // SIGALRM
84+
15, // SIGTERM
8585
);
8686

8787
/**
@@ -285,27 +285,35 @@ public function start(callable $callback = null)
285285
if (!isset($this->options['bypass_shell'])) {
286286
$this->options['bypass_shell'] = true;
287287
}
288-
}
288+
} elseif (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
289+
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
290+
$descriptors[3] = array('pipe', 'w');
291+
292+
$commandline = '';
293+
foreach (self::$posixSignals as $s) {
294+
$commandline .= "trap 'echo s$s >&3' $s;";
295+
}
289296

290-
$ptsWorkaround = null;
297+
// See https://unix.stackexchange.com/questions/71205/background-process-pipe-input
298+
$commandline .= '{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
299+
$commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo x$code >&3; exit $code';
291300

292-
if (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
293301
// Workaround for the bug, when PTS functionality is enabled.
294302
// @see : https://bugs.php.net/69442
295303
$ptsWorkaround = fopen(__FILE__, 'r');
296304
}
297305

298306
$this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options);
299307

300-
if ($ptsWorkaround) {
301-
fclose($ptsWorkaround);
302-
}
303-
304308
if (!is_resource($this->process)) {
305309
throw new RuntimeException('Unable to launch a new process.');
306310
}
307311
$this->status = self::STATUS_STARTED;
308312

313+
if (isset($descriptors[3])) {
314+
$this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]);
315+
}
316+
309317
if ($this->tty) {
310318
return;
311319
}
@@ -596,8 +604,6 @@ public function clearErrorOutput()
596604
public function getExitCode()
597605
{
598606
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
599-
$this->stop(0);
600-
601607
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
602608
}
603609

@@ -651,8 +657,6 @@ public function hasBeenSignaled()
651657
$this->requireProcessIsTerminated(__FUNCTION__);
652658

653659
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
654-
$this->stop(0);
655-
656660
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
657661
}
658662

@@ -674,8 +678,6 @@ public function getTermSignal()
674678
$this->requireProcessIsTerminated(__FUNCTION__);
675679

676680
if ($this->isSigchildEnabled() && (!$this->enhanceSigchildCompatibility || -1 === $this->processInformation['termsig'])) {
677-
$this->stop(0);
678-
679681
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
680682
}
681683

@@ -1185,14 +1187,7 @@ public static function isPtySupported()
11851187
return $result = false;
11861188
}
11871189

1188-
$proc = @proc_open('echo 1', array(array('pty'), array('pty'), array('pty')), $pipes);
1189-
if (is_resource($proc)) {
1190-
proc_close($proc);
1191-
1192-
return $result = true;
1193-
}
1194-
1195-
return $result = false;
1190+
return $result = (bool) @proc_open('echo 1', array(array('pty'), array('pty'), array('pty')), $pipes);
11961191
}
11971192

11981193
/**
@@ -1207,22 +1202,8 @@ private function getDescriptors()
12071202
} else {
12081203
$this->processPipes = UnixPipes::create($this, $this->input);
12091204
}
1210-
$descriptors = $this->processPipes->getDescriptors($this->outputDisabled);
1211-
1212-
if (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
1213-
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
1214-
$descriptors[3] = array('pipe', 'w');
1215-
1216-
$trap = '';
1217-
foreach (self::$posixSignals as $s) {
1218-
$trap .= "trap 'echo s$s >&3' $s;";
1219-
}
1220-
1221-
$this->commandline = $trap.'{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
1222-
$this->commandline .= 'pid=$!; echo p$pid >&3; wait $pid; code=$?; echo x$code >&3; exit $code';
1223-
}
12241205

1225-
return $descriptors;
1206+
return $this->processPipes->getDescriptors($this->outputDisabled);
12261207
}
12271208

12281209
/**
@@ -1340,8 +1321,11 @@ private function readPipes($blocking, $close)
13401321
$this->fallbackStatus['signaled'] = true;
13411322
$this->fallbackStatus['exitcode'] = -1;
13421323
$this->fallbackStatus['termsig'] = (int) substr($data, 1);
1343-
} elseif ('x' === $data[0] && !isset($this->fallbackStatus['signaled'])) {
1344-
$this->fallbackStatus['exitcode'] = (int) substr($data, 1);
1324+
} elseif ('x' === $data[0]) {
1325+
$this->fallbackStatus['running'] = false;
1326+
if (!isset($this->fallbackStatus['signaled'])) {
1327+
$this->fallbackStatus['exitcode'] = (int) substr($data, 1);
1328+
}
13451329
}
13461330
}
13471331
} else {
@@ -1423,14 +1407,6 @@ private function doSignal($signal, $throwException)
14231407
return false;
14241408
}
14251409

1426-
if ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled() && !isset(self::$posixSignals[$signal]) && !(function_exists('posix_kill') && @posix_kill($this->getPid(), $signal))) {
1427-
if ($throwException) {
1428-
throw new RuntimeException('This PHP has been compiled with --enable-sigchild and posix_kill() is not available.');
1429-
}
1430-
1431-
return false;
1432-
}
1433-
14341410
if ('\\' === DIRECTORY_SEPARATOR) {
14351411
exec(sprintf('taskkill /F /T /PID %d 2>&1', $this->getPid()), $output, $exitCode);
14361412
if ($exitCode && $this->isRunning()) {
@@ -1440,14 +1416,21 @@ private function doSignal($signal, $throwException)
14401416

14411417
return false;
14421418
}
1443-
}
1444-
1445-
if (true !== @proc_terminate($this->process, $signal) && '\\' !== DIRECTORY_SEPARATOR) {
1446-
if ($throwException) {
1447-
throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal));
1419+
} else {
1420+
if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
1421+
$ok = @proc_terminate($this->process, $signal);
1422+
} elseif (function_exists('posix_kill')) {
1423+
$ok = @posix_kill($this->getPid(), $signal);
1424+
} elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $this->getPid()), array(2 => array('pipe', 'w')), $pipes)) {
1425+
$ok = false === fgets($pipes[2]);
14481426
}
1427+
if (!$ok) {
1428+
if ($throwException) {
1429+
throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal));
1430+
}
14491431

1450-
return false;
1432+
return false;
1433+
}
14511434
}
14521435

14531436
$this->latestSignal = (int) $signal;

src/Symfony/Component/Process/Tests/NonStopableProcess.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@ function handleSignal($signal)
3030
break;
3131
}
3232

33-
echo "received signal $name\n";
33+
echo "signal $name\n";
3434
}
3535

36-
declare (ticks = 1);
3736
pcntl_signal(SIGTERM, 'handleSignal');
3837
pcntl_signal(SIGINT, 'handleSignal');
3938

39+
echo 'received ';
40+
4041
$duration = isset($argv[1]) ? (int) $argv[1] : 3;
4142
$start = microtime(true);
4243

4344
while ($duration > (microtime(true) - $start)) {
44-
usleep(1000);
45+
usleep(10000);
46+
pcntl_signal_dispatch();
4547
}

0 commit comments

Comments
 (0)
0