8000 Merge branch '2.1' · sam57/symfony@e7b55fc · GitHub
[go: up one dir, main page]

Skip to content

Commit e7b55fc

Browse files
committed
Merge branch '2.1'
* 2.1: [Form] removed comment now that PHPUnit 3.7 is out Add a Sigchild compatibility mode (set to false by default) fix Fatal error: Cannot access private property Conflicts: src/Symfony/Component/Process/Process.php
2 parents be331ca + f1e6063 commit e7b55fc

File tree

8 files changed

+442
-40
lines changed

8 files changed

+442
-40
lines changed

src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,8 @@ public function testCreateBuilder()
104104
->method('setDefaultOptions')
105105
->will($this->returnCallback($assertIndexAndAddOption(3, 'd', 'd_default')));
106106

107-
// Can only be uncommented when the following PHPUnit "bug" is fixed:
108-
// https://github.com/sebastianbergmann/phpunit-mock-objects/issues/47
109-
// $givenOptions = array('a' => 'a_custom', 'c' => 'c_custom');
110-
// $resolvedOptions = array('a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default');
111-
112-
$givenOptions = array();
113-
$resolvedOptions = array();
107+
$givenOptions = array('a' => 'a_custom', 'c' => 'c_custom');
108+
$resolvedOptions = array('a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default');
114109

115110
// Then the form is built for the super type
116111
$parentType->expects($this->once())

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
2323
*/
2424
private $mongo;
2525
private $storage;
26-
private $options;
26+
public $options;
2727

2828
protected function setUp()
2929
{

src/Symfony/Component/Process/Process.php

Lines changed: 79 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,16 @@ class Process
4747
private $stdout;
4848
private $stderr;
4949
private $enhanceWindowsCompatibility;
50+
private $enhanceSigchildCompatibility;
5051
private $pipes;
5152
private $process;
5253
private $status = self::STATUS_READY;
5354

5455
private $fileHandles;
5556
private $readBytes;
5657

58+
private static $sigchild;
59+
5760
/**
5861
* Exit codes translation table.
5962
*
@@ -137,6 +140,7 @@ public function __construct($commandline, $cwd = null, array $env = null, $stdin
137140
$this->stdin = $stdin;
138141
$this->setTimeout($timeout);
139142
$this->enhanceWindowsCompatibility = true;
143+
$this->enhanceSigchildCompatibility = !defined('PHP_WINDOWS_VERSION_BUILD') && $this->isSigchildEnabled();
140144
$this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options);
141145
}
142146

@@ -219,9 +223,16 @@ public function start($callback = null)
219223
array('pipe', 'r'), // stdin
220224
array('pipe', 'w'), // stdout
221225
array('pipe', 'w'), // stderr
222-
array('pipe', 'w') // last exit code is output on the fourth pipe and caught to work around --enable-sigchild
223226
);
224-
$this->commandline = '('.$this->commandline.') 3>/dev/null; code=$?; echo $code >&3; exit $code';
227+
228+
if ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
229+
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
230+
$descriptors = array_merge($descriptors, array(array('pipe', 'w')));
231+
232+
$this->commandline = '('.$this->commandline.') 3>/dev/null; code=$?; echo $code >&3; exit $code';
233+
} else {
234+
$this->commandline = 'exec ' . $this->commandline;
235+
}
225236
}
226237

227238
$commandline = $this->commandline;
@@ -421,10 +432,16 @@ public function getErrorOutput()
421432
*
422433
* @return integer The exit status code
423434
*
435+
* @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled
436+
*
424437
* @api
425438
*/
426439
public function getExitCode()
427440
{
441+
if ($this->isSigchildEnabled() && !$this->enhanceSigchildCompatibility) {
442+
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method');
443+
}
444+
428445
$this->updateStatus();
429446

430447
return $this->exitcode;
@@ -438,28 +455,30 @@ public function getExitCode()
438455
*
439456
* @return string A string representation for the exit status code
440457
*
458+
* @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled
459+
*
441460
* @see http://tldp.org/LDP/abs/html/exitcodes.html
442461
* @see http://en.wikipedia.org/wiki/Unix_signal
443462
*/
444463
public function getExitCodeText()
445464
{
446-
$this->updateStatus();
465+
$exitcode = $this->getExitCode();
447466

448-
return isset(self::$exitCodes[$this->exitcode]) ? self::$exitCodes[$this->exitcode] : 'Unknown error';
467+
return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error';
449468
}
450469

451470
/**
452471
* Checks if the process ended successfully.
453472
*
454473
* @return Boolean true if the process ended successfully, false otherwise
455474
*
475+
* @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled
476+
*
456477
* @api
457478
*/
458479
public function isSuccessful()
459480
{
460-
$this->updateStatus();
461-
462-
return 0 == $this->exitcode;
481+
return 0 == $this->getExitCode();
463482
}
464483

465484
/**
@@ -469,10 +488,16 @@ public function isSuccessful()
469488
*
470489
* @return Boolean
471490
*
491+
* @throws RuntimeException In case --enable-sigchild is activated
492+
*
472493
* @api
473494
*/
474495
public function hasBeenSignaled()
475496
{
497+
if ($this->isSigchildEnabled()) {
498+
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
499+
}
500+
476501
$this->updateStatus();
477502

478503
return $this->processInformation['signaled'];
@@ -485,10 +510,16 @@ public function hasBeenSignaled()
485510
*
486511
* @return integer
487512
*
513+
* @throws RuntimeException In case --enable-sigchild is activated
514+
*
488515
* @api
489516
*/
490517
public function getTermSignal()
491518
{
519+
if ($this->isSigchildEnabled()) {
520+
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved');
521+
}
522+
492523
$this->updateStatus();
493524

494525
return $this->processInformation['termsig'];
@@ -681,6 +712,30 @@ public function setEnhanceWindowsCompatibility($enhance)
681712
$this->enhanceWindowsCompatibility = (Boolean) $enhance;
682713
}
683714

715+
/**
716+
* Return whether sigchild compatibility mode is activated or not
717+
*
718+
* @return Boolean
719+
*/
720+
public function getEnhanceSigchildCompatibility()
721+
{
722+
return $this->enhanceSigchildCompatibility;
723+
}
724+
725+
/**
726+
* Activate sigchild compatibility mode
727+
*
728+
* Sigchild compatibility mode is required to get the exit code and
729+
* determine the success of a process when PHP has been compiled with
730+
* the --enable-sigchild option
731+
*
732+
* @param Boolean $enhance
733+
*/
734+
public function setEnhanceSigchildCompatibility($enhance)
735+
{
736+
$this->enhanceSigchildCompatibility = (Boolean) $enhance;
737+
}
738+
684739
/**
685740
* Builds up the callback used by wait().
686741
*
@@ -746,6 +801,23 @@ protected function updateOutput()
746801
}
747802
}
748803

804+
/**
805+
* Return whether PHP has been compiled with the '--enable-sigchild' option or not
806+
*
807+
* @return Boolean
808+
*/
809+
protected function isSigchildEnabled()
810+
{
811+
if (null !== self::$sigchild) {
812+
return self::$sigchild;
813+
}
814+
815+
ob_start();
816+
phpinfo(INFO_GENERAL);
817+
818+
return self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
819+
}
820+
749821
/**
750822
* Handles the windows file handles fallbacks
751823
*

0 commit comments

Comments
 (0)
0