10000 Merge branch '2.8' · symfony/symfony@f20f2f0 · GitHub
[go: up one dir, main page]

Skip to content

Commit f20f2f0

Browse files
committed
Merge branch '2.8'
* 2.8: add subject variable to expression context [Process] Fix signaling/stopping logic on Windows Forward compatibility with AbstractLayout* 2.8 tests [Yaml] minor CS cleaning [Console] do not encode backslashes in console default description
2 parents 70f7b1c + 9b6f592 commit f20f2f0

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

src/Symfony/Component/Console/Descriptor/TextDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ private function writeText($content, array $options = array())
235235
*/
236236
private function formatDefaultValue($default)
237237
{
238-
return json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
238+
return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
239239
}
240240

241241
/**

src/Symfony/Component/Process/Process.php

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -775,36 +775,24 @@ public function getStatus()
775775
* Stops the process.
776776
*
777777
* @param int|float $timeout The timeout in seconds
778-
* @param int $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL
778+
* @param int $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL (9)
779779
*
780780
* @return int The exit-code of the process
781-
*
782-
* @throws RuntimeException if the process got signaled
783781
*/
784782
public function stop($timeout = 10, $signal = null)
785783
{
786784
$timeoutMicro = microtime(true) + $timeout;
787785
if ($this->isRunning()) {
788-
if ('\\' === DIRECTORY_SEPARATOR && !$this->isSigchildEnabled()) {
789-
exec(sprintf('taskkill /F /T /PID %d 2>&1', $this->getPid()), $output, $exitCode);
790-
if ($exitCode > 0) {
791-
throw new RuntimeException('Unable to kill the process');
792-
}
793-
}
794786
// given `SIGTERM` may not be defined and that `proc_terminate` uses the constant value and not the constant itself, we use the same here
795787
$this->doSignal(15, false);
796788
do {
797789
usleep(1000);
798790
} while ($this->isRunning() && microtime(true) < $timeoutMicro);
799791

800792
if ($this->isRunning() && !$this->isSigchildEnabled()) {
801-
if (null !== $signal || defined('SIGKILL')) {
802-
// avoid exception here :
803-
// process is supposed to be running, but it might have stop
804-
// just after this line.
805-
// in any case, let's silently discard the error, we can not do anything
806-
$this->doSignal($signal ?: SIGKILL, false);
807-
}
793+
// Avoid exception here: process is supposed to be running, but it might have stopped just
794+
// after this line. In any case, let's silently discard the error, we cannot do anything.
795+
$this->doSignal($signal ?: 9, false);
808796
}
809797
}
810798

@@ -1434,7 +1422,18 @@ private function doSignal($signal, $throwException)
14341422
return false;
14351423
}
14361424

1437-
if (true !== @proc_terminate($this->process, $signal)) {
1425+
if ('\\' === DIRECTORY_SEPARATOR) {
1426+
exec(sprintf('taskkill /F /T /PID %d 2>&1', $this->getPid()), $output, $exitCode);
1427+
if ($exitCode) {
1428+
if ($throwException) {
1429+
throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output)));
1430+
}
1431+
1432+
return false;
1433+
}
1434+
}
1435+
1436+
if (true !== @proc_terminate($this->process, $signal) && '\\' !== DIRECTORY_SEPARATOR) {
14381437
if ($throwException) {
14391438
throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal));
14401439
}

src/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ private function getVariables(TokenInterface $token, $subject)
8686
'token' => $token,
8787
'user' => $token->getUser(),
8888
'object' => $subject,
89+
'subject' => $subject,
8990
'roles' => array_map(function ($role) { return $role->getRole(); }, $roles),
9091
'trust_resolver' => $this->trustResolver,
9192
);

src/Symfony/Component/Yaml/Parser.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
345345
if (null === $indentation) {
346346
$newIndent = $this->getCurrentLineIndentation();
347347

348-
$unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem($this->currentLine);
348+
$unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem();
349349

350350
if (!$this->isCurrentLineEmpty() && 0 === $newIndent && !$unindentedEmbedBlock) {
351351
throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
@@ -371,7 +371,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
371371
return;
372372
}
373373

374-
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine);
374+
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem();
375375

376376
// Comments must not be removed inside a block scalar
377377
$removeCommentsPattern = '~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~';
@@ -384,7 +384,7 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
384384
$removeComments = !preg_match($removeCommentsPattern, $this->currentLine);
385385
}
386386

387-
if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine) && $newIndent === $indent) {
387+
if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) {
388388
$this->moveToPreviousLine();
389389
break;
390390
}
@@ -693,7 +693,7 @@ private function isNextLineUnIndentedCollection()
693693
if (
694694
$this->getCurrentLineIndentation() == $currentIndentation
695695
&&
696-
$this->isStringUnIndentedCollectionItem($this->currentLine)
696+
$this->isStringUnIndentedCollectionItem()
697697
) {
698698
$ret = true;
699699
}

0 commit comments

Comments
 (0)
0