Skip to content

Commit 1da8591

Browse files
Merge branch '3.4' into 4.0
* 3.4: SCA with Php Inspections (EA Extended) Add test case for symfony#25264 Fixed the null value exception case. Remove rc/beta suffix from composer.json files Throw an exception is expression language is not installed Fail as early and noisily as possible [Console][DI] Fail gracefully [FrameworkBundle] Fix visibility of a test helper [link] clear the cache after linking [DI] Trigger deprecation when setting a to-be-private synthetic service [link] Prevent warnings when running link with 2.7 [Validator] ExpressionValidator should use OBJECT_TO_STRING to allow value in message do not eagerly filter comment lines [WebProfilerBundle], [TwigBundle] Fix Profiler breaking XHTML pages (Content-Type: application/xhtml+xml)
2 parents 86fb66f + 0b0542d commit 1da8591

File tree

30 files changed

+203
-65
lines changed

30 files changed

+203
-65
lines changed

link

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ if (!is_dir("$argv[1]/vendor/symfony")) {
3535
}
3636

3737
$sfPackages = array('symfony/symfony' => __DIR__);
38+
39+
$filesystem = new Filesystem();
3840
foreach (glob(__DIR__.'/src/Symfony/{Bundle,Bridge,Component,Component/Security}/*', GLOB_BRACE | GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
39-
$sfPackages[json_decode(file_get_contents("$dir/composer.json"))->name] = $dir;
41+
if ($filesystem->exists($composer = "$dir/composer.json")) {
42+
$sfPackages[json_decode(file_get_contents($composer))->name] = $dir;
43+
}
4044
}
4145

42-
$filesystem = new Filesystem();
4346
foreach (glob("$argv[1]/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
4447
$package = 'symfony/'.basename($dir);
4548
if (is_link($dir)) {
@@ -57,3 +60,7 @@ foreach (glob("$argv[1]/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir)
5760
$filesystem->symlink($sfDir, $dir);
5861
echo "\"$package\" has been linked to \"$sfPackages[$package]\".".PHP_EOL;
5962
}
63+
64+
foreach (glob("$argv[1]/var/cache/*") as $cacheDir) {
65+
$filesystem->remove($cacheDir);
66+
}

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
5959
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? '(del /S /F /Q %s & rmdir %1$s) >nul': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION"));
6060
}
6161
if (extension_loaded('openssl') && ini_get('allow_url_fopen') && !isset($_SERVER['http_proxy']) && !isset($_SERVER['https_proxy'])) {
62-
stream_copy_to_stream(fopen("https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip", 'rb'), fopen("$PHPUNIT_VERSION.zip", 'wb'));
62+
$remoteZip = "https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip";
63+
$remoteZipStream = @fopen($remoteZip, 'rb');
64+
if (!$remoteZipStream) {
65+
throw new \RuntimeException("Could not find $remoteZip");
66+
}
67+
stream_copy_to_stream($remoteZipStream, fopen("$PHPUNIT_VERSION.zip", 'wb'));
6368
} else {
6469
@unlink("$PHPUNIT_VERSION.zip");
6570
passthru("wget https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip");

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"symfony/asset": "~3.4|~4.0",
2525
"symfony/dependency-injection": "~3.4|~4.0",
2626
"symfony/finder": "~3.4|~4.0",
27-
"symfony/form": "~3.4-beta4|~4.0-beta4",
27+
"symfony/form": "~3.4|~4.0",
2828
"symfony/http-foundation": "~3.4|~4.0",
2929
"symfony/http-kernel": "~3.4|~4.0",
3030
"symfony/polyfill-intl-icu": "~1.0",

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ private function createRedirectController($httpPort = null, $httpsPort = null)
252252
return new RedirectController(null, $httpPort, $httpsPort);
253253
}
254254

255-
public function assertRedirectUrl(Response $returnResponse, $expectedUrl)
255+
private function assertRedirectUrl(Response $returnResponse, $expectedUrl)
256256
{
257257
$this->assertTrue($returnResponse->isRedirect($expectedUrl), "Expected: $expectedUrl\nGot: ".$returnResponse->headers->get('Location'));
258258
}

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"symfony/cache": "~3.4|~4.0",
2222
"symfony/dependency-injection": "~3.4|~4.0",
2323
"symfony/config": "~3.4|~4.0",
24-
"symfony/event-dispatcher": "~3.4-beta4|~4.0-beta4",
24+
"symfony/event-dispatcher": "~3.4|~4.0",
2525
"symfony/http-foundation": "~3.4|~4.0",
2626
"symfony/http-kernel": "~3.4|~4.0",
2727
"symfony/polyfill-mbstring": "~1.0",

src/Symfony/Bundle/SecurityBundle/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": "^7.1.3",
2020
"ext-xml": "*",
21-
"symfony/security": "~3.4-beta5|~4.0-beta5",
21+
"symfony/security": "~3.4|~4.0",
2222
"symfony/dependency-injection": "~3.4|~4.0",
2323
"symfony/http-kernel": "~3.4|~4.0"
2424
},
@@ -30,7 +30,7 @@
3030
"symfony/dom-crawler": "~3.4|~4.0",
3131
"symfony/event-dispatcher": "~3.4|~4.0",
3232
"symfony/form": "~3.4|~4.0",
33-
"symfony/framework-bundle": "~3.4-rc1|~4.0-rc1",
33+
"symfony/framework-bundle": "~3.4|~4.0",
3434
"symfony/http-foundation": "~3.4|~4.0",
3535
"symfony/translation": "~3.4|~4.0",
3636
"symfony/twig-bundle": "~3.4|~4.0",

src/Symfony/Bundle/TwigBundle/Resources/views/base_js.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{# This file is based on WebProfilerBundle/Resources/views/Profiler/base_js.html.twig.
22
If you make any change in this file, verify the same change is needed in the other file. #}
3-
<script{% if csp_script_nonce is defined and csp_script_nonce %} nonce={{ csp_script_nonce }}{% endif %}>/*<![CDATA[*/
3+
<script{% if csp_script_nonce is defined and csp_script_nonce %} nonce="{{ csp_script_nonce }}"{% endif %}>/*<![CDATA[*/
44
{# Caution: the contents of this file are processed by Twig before loading
55
them as JavaScript source code. Always use '/*' comments instead
66
of '//' comments to avoid impossible-to-debug side-effects #}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{# This file is partially duplicated in TwigBundle/Resources/views/base_js.html.twig. If you
22
make any change in this file, verify the same change is needed in the other file. #}
3-
<script{% if csp_script_nonce is defined and csp_script_nonce %} nonce={{ csp_script_nonce }}{% endif %}>/*<![CDATA[*/
3+
<script{% if csp_script_nonce is defined and csp_script_nonce %} nonce="{{ csp_script_nonce }}"{% endif %}>/*<![CDATA[*/
44
{# Caution: the contents of this file are processed by Twig before loading
55
them as JavaScript source code. Always use '/*' comments instead
66
of '//' comments to avoid impossible-to-debug side-effects #}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<style{% if csp_style_nonce %} nonce="{{ csp_style_nonce }}"{% endif %}>
44
{{ include('@WebProfiler/Profiler/toolbar.css.twig') }}
55
</style>
6-
<script{% if csp_script_nonce %} nonce={{ csp_script_nonce }}{% endif %}>/*<![CDATA[*/
6+
<script{% if csp_script_nonce %} nonce="{{ csp_script_nonce }}"{% endif %}>/*<![CDATA[*/
77
(function () {
88
Sfjs.load(
99
'sfwdt{{ token }}',

src/Symfony/Component/Console/Application.php

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
4040
use Symfony\Component\Console\Exception\CommandNotFoundException;
4141
use Symfony\Component\Console\Exception\LogicException;
42+
use Symfony\Component\Debug\ErrorHandler;
43+
use Symfony\Component\Debug\Exception\FatalThrowableError;
4244
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
4345

4446
/**
@@ -116,6 +118,25 @@ public function run(InputInterface $input = null, OutputInterface $output = null
116118
$output = new ConsoleOutput();
117119
}
118120

121+
$renderException = function ($e) use ($output) {
122+
if (!$e instanceof \Exception) {
123+
$e = class_exists(FatalThrowableError::class) ? new FatalThrowableError($e) : new \ErrorException($e->getMessage(), $e->getCode(), E_ERROR, $e->getFile(), $e->getLine());
124+
}
125+
if ($output instanceof ConsoleOutputInterface) {
126+
$this->renderException($e, $output->getErrorOutput());
127+
} else {
128+
$this->renderException($e, $output);
129+
}
130+
};
131+
if ($phpHandler = set_exception_handler($renderException)) {
132+
restore_exception_handler();
133+
if (!is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) {
134+
$debugHandler = true;
135+
} elseif ($debugHandler = $phpHandler[0]->setExceptionHandler($renderException)) {
136+
$phpHandler[0]->setExceptionHandler($debugHandler);
137+
}
138+
}
139+
119140
$this->configureIO($input, $output);
120141

121142
try {
@@ -125,11 +146,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null
125146
throw $e;
126147
}
127148

128-
if ($output instanceof ConsoleOutputInterface) {
129-
$this->renderException($e, $output->getErrorOutput());
130-
} else {
131-
$this->renderException($e, $output);
132-
}
149+
$renderException($e);
133150

134151
$exitCode = $e->getCode();
135152
if (is_numeric($exitCode)) {
@@ -140,6 +157,12 @@ public function run(InputInterface $input = null, OutputInterface $output = null
140157
} else {
141158
$exitCode = 1;
142159
}
160+
} finally {
161+
if (!$phpHandler) {
162+
restore_exception_handler();
163+
} elseif (!$debugHandler) {
164+
$phpHandler[0]->setExceptionHandler(null);
165+
}
143166
}
144167

145168
if ($this->autoExit) {

0 commit comments

Comments
 (0)