Skip to content

Commit abd76ba

Browse files
Merge branch '3.3' into 3.4
* 3.3: Fail as early and noisily as possible [FrameworkBundle] Fix visibility of a test helper [link] clear the cache after linking [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 2adb67b + 5b997f1 commit abd76ba

File tree

11 files changed

+97
-21
lines changed

11 files changed

+97
-21
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/Bundle/FrameworkBundle/Tests/Controller/RedirectControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ private function createLegacyRedirectController($httpPort = null, $httpsPort = n
314314
return $controller;
315315
}
316316

317-
public function assertRedirectUrl(Response $returnResponse, $expectedUrl)
317+
private function assertRedirectUrl(Response $returnResponse, $expectedUrl)
318318
{
319319
$this->assertTrue($returnResponse->isRedirect($expectedUrl), "Expected: $expectedUrl\nGot: ".$returnResponse->headers->get('Location'));
320320
}

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', { 'position': position, 'floatable': true }) }}
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
{% if 'top' == position %}
99
var sfwdt = document.getElementById('sfwdt{{ token }}');

src/Symfony/Component/Validator/Constraints/ExpressionValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function validate($value, Constraint $constraint)
4545

4646
if (!$this->getExpressionLanguage()->evaluate($constraint->expression, $variables)) {
4747
$this->context->buildViolation($constraint->message)
48-
->setParameter('{{ value }}', $this->formatValue($value))
48+
->setParameter('{{ value }}', $this->formatValue($value, self::OBJECT_TO_STRING))
4949
->setCode(Expression::EXPRESSION_FAILED_ERROR)
5050
->addViolation();
5151
}

src/Symfony/Component/Validator/Tests/Constraints/ExpressionValidatorTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Validator\Constraints\ExpressionValidator;
1616
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
1717
use Symfony\Component\Validator\Tests\Fixtures\Entity;
18+
use Symfony\Component\Validator\Tests\Fixtures\ToString;
1819

1920
class ExpressionValidatorTest extends ConstraintValidatorTestCase
2021
{
@@ -87,6 +88,40 @@ public function testFailingExpressionAtObjectLevel()
8788
->assertRaised();
8889
}
8990

91+
public function testSucceedingExpressionAtObjectLevelWithToString()
92+
{
93+
$constraint = new Expression('this.data == 1');
94+
95+
$object = new ToString();
96+
$object->data = '1';
97+
98+
$this->setObject($object);
99+
100+
$this->validator->validate($object, $constraint);
101+
102+
$this->assertNoViolation();
103+
}
104+
105+
public function testFailingExpressionAtObjectLevelWithToString()
106+
{
107+
$constraint = new Expression(array(
108+
'expression' => 'this.data == 1',
109+
'message' => 'myMessage',
110+
));
111+
112+
$object = new ToString();
113+
$object->data = '2';
114+
115+
$this->setObject($object);
116+
117+
$this->validator->validate($object, $constraint);
118+
119+
$this->buildViolation('myMessage')
120+
->setParameter('{{ value }}', 'toString')
121+
->setCode(Expression::EXPRESSION_FAILED_ERROR)
122+
->assertRaised();
123+
}
124+
90125
public function testSucceedingExpressionAtPropertyLevel()
91126
{
92127
$constraint = new Expression('value == this.data');
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Validator\Tests\Fixtures;
13+
14+
class ToString
15+
{
16+
public $data;
17+
18+
public function __toString()
19+
{
20+
return 'toString';
21+
}
22+
}

src/Symfony/Component/Yaml/Parser.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -637,21 +637,10 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false)
637637
continue;
638638
}
639639

640-
// we ignore "comment" lines only when we are not inside a scalar block
641-
if (empty($blockScalarIndentations) && $this->isCurrentLineComment()) {
642-
// remember ignored comment lines (they are used later in nested
643-
// parser calls to determine real line numbers)
644-
//
645-
// CAUTION: beware to not populate the global property here as it
646-
// will otherwise influence the getRealCurrentLineNb() call here
647-
// for consecutive comment lines and subsequent embedded blocks
648-
$this->locallySkippedLineNumbers[] = $this->getRealCurrentLineNb();
649-
650-
continue;
651-
}
652-
653640
if ($indent >= $newIndent) {
654641
$data[] = substr($this->currentLine, $newIndent);
642+
} elseif ($this->isCurrentLineComment()) {
643+
$data[] = $this->currentLine;
655644
} elseif (0 == $indent) {
656645
$this->moveToPreviousLine();
657646

0 commit comments

Comments
 (0)