Skip to content

Commit 4ebecdb

Browse files
Merge branch '4.1'
* 4.1: [travis] cache composer.lock files for deps=low [Security] Remove wrong sentence about ACL Update validators.nl.xlf [Routing] Fixed scheme redirecting for root path [Form] Remove extra .form-group wrapper around file widget in bootstrap 4
2 parents b6f17f4 + 9654de3 commit 4ebecdb

22 files changed

+137
-49
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
array_shift($_SERVER['argv']);
4+
$dirs = $_SERVER['argv'];
5+
6+
function getContentHash($composerJson)
7+
{
8+
$relevantKeys = array(
9+
'name',
10+
'require',
11+
'require-dev',
12+
'conflict',
13+
'replace',
14+
'provide',
15+
'minimum-stability',
16+
'prefer-stable',
17+
'repositories',
18+
'extra',
19+
);
20+
21+
$relevantContent = array();
22+
23+
foreach (array_intersect($relevantKeys, array_keys($composerJson)) as $key) {
24+
$relevantContent[$key] = $composerJson[$key];
25+
}
26+
if (isset($composerJson['config']['platform'])) {
27+
$relevantContent['config']['platform'] = $composerJson['config']['platform'];
28+
}
29+
30+
ksort($relevantContent);
31+
32+
return md5(json_encode($relevantContent));
33+
}
34+
35+
$composerLocks = array();
36+
37+
foreach ($dirs as $dir) {
38+
if (!file_exists($dir.'/composer.lock') || !$composerLock = @json_decode(file_get_contents($dir.'/composer.lock'), true)) {
39+
echo "$dir/composer.lock not found or invalid.\n";
40+
@unlink($dir.'/composer.lock');
41+
continue;
42+
}
43+
if (!file_exists($dir.'/composer.json') || !$composerJson = @json_decode(file_get_contents($dir.'/composer.json'), true)) {
44+
echo "$dir/composer.json not found or invalid.\n";
45+
@unlink($dir.'/composer.lock');
46+
continue;
47+
}
48+
if (!isset($composerLock['content-hash']) || getContentHash($composerJson) !== $composerLock['content-hash']) {
49+
echo "$dir/composer.lock is outdated.\n";
50+
@unlink($dir.'/composer.lock');
51+
continue;
52+
}
53+
$composerLocks[$composerJson['name']] = array($dir, $composerLock, $composerJson);
54+
}
55+
56+
foreach ($composerLocks as list($dir, $composerLock)) {
57+
foreach ($composerLock['packages'] as $composerJson) {
58+
if (0 !== strpos($version = $composerJson['version'], 'dev-') && '-dev' !== substr($version, -4)) {
59+
continue;
60+
}
61+
62+
if (!isset($composerLocks[$name = $composerJson['name']])) {
63+
echo "$dir/composer.lock references missing $name.\n";
64+
@unlink($dir.'/composer.lock');
65+
continue 2;
66+
}
67+
68+
foreach (array('minimum-stability', 'prefer-stable', 'repositories') as $key) {
69+
if (array_key_exists($key, $composerLocks[$name][2])) {
70+
$composerJson[$key] = $composerLocks[$name][2][$key];
71+
}
72+
}
73+
74+
if (getContentHash($composerJson) !== $composerLocks[$name][1]['content-hash']) {
75+
echo "$dir/composer.lock is not in sync with $name.\n";
76+
@unlink($dir.'/composer.lock');
77+
continue 2;
78+
}
79+
}
80+
}

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,11 @@ install:
212212
if [[ $deps = high ]]; then
213213
echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP && $PHPUNIT_X$LEGACY'"
214214
elif [[ $deps = low ]]; then
215-
echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT_X'"
215+
[[ -e ~/php-ext/composer-lowest.lock.tar ]] && tar -xf ~/php-ext/composer-lowest.lock.tar
216+
tar -cf ~/php-ext/composer-lowest.lock.tar --files-from /dev/null
217+
php .github/rm-invalid-lowest-lock-files.php $COMPONENTS
218+
echo "$COMPONENTS" | parallel --gnu -j10% "tfold {} 'cd {} && ([ -e composer.lock ] && ${COMPOSER_UP/update/install} || $COMPOSER_UP --prefer-lowest --prefer-stable) && $PHPUNIT_X'"
219+
echo "$COMPONENTS" | xargs -n1 -I{} tar --append -f ~/php-ext/composer-lowest.lock.tar {}/composer.lock
216220
else
217221
echo "$COMPONENTS" | parallel --gnu "tfold {} $PHPUNIT_X {}"
218222
tfold src/Symfony/Component/Console.tty $PHPUNIT src/Symfony/Component/Console --group tty

src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,15 @@
115115
{%- endblock percent_widget %}
116116

117117
{% block file_widget -%}
118-
<div class="form-group">
119-
<{{ element|default('div') }} class="custom-file">
120-
{%- set type = type|default('file') -%}
121-
{{- block('form_widget_simple') -}}
122-
<label for="{{ form.vars.id }}" class="custom-file-label">
123-
{%- if attr.placeholder is defined -%}
124-
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
125-
{%- endif -%}
126-
</label>
127-
</{{ element|default('div') }}>
128-
</div>
118+
<{{ element|default('div') }} class="custom-file">
119+
{%- set type = type|default('file') -%}
120+
{{- block('form_widget_simple') -}}
121+
<label for="{{ form.vars.id }}" class="custom-file-label">
122+
{%- if attr.placeholder is defined -%}
123+
{{- translation_domain is same as(false) ? attr.placeholder : attr.placeholder|trans({}, translation_domain) -}}
124+
{%- endif -%}
125+
</label>
126+
</{{ element|default('div') }}>
129127
{% endblock %}
130128

131129
{% block form_widget_simple -%}

src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap4LayoutTest.php

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -942,17 +942,13 @@ public function testFile()
942942

943943
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'n/a', 'attr' => array('class' => 'my&class form-control-file')),
944944
'/div
945-
[@class="form-group"]
945+
[@class="custom-file"]
946946
[
947-
./div
948-
[@class="custom-file"]
949-
[
950-
./input
951-
[@type="file"]
952-
[@name="name"]
953-
/following-sibling::label
954-
[@for="name"]
955-
]
947+
./input
948+
[@type="file"]
949+
[@name="name"]
950+
/following-sibling::label
951+
[@for="name"]
956952
]
957953
'
958954
);
@@ -964,17 +960,13 @@ public function testFileWithPlaceholder()
964960

965961
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'n/a', 'attr' => array('class' => 'my&class form-control-file', 'placeholder' => 'Custom Placeholder')),
966962
'/div
967-
[@class="form-group"]
963+
[@class="custom-file"]
968964
[
969-
./div
970-
[@class="custom-file"]
971-
[
972-
./input
973-
[@type="file"]
974-
[@name="name"]
975-
/following-sibling::label
976-
[@for="name" and text() = "[trans]Custom Placeholder[/trans]"]
977-
]
965+
./input
966+
[@type="file"]
967+
[@name="name"]
968+
/following-sibling::label
969+
[@for="name" and text() = "[trans]Custom Placeholder[/trans]"]
978970
]
979971
'
980972
);

src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ private function compileRoutes(RouteCollection $routes, bool $matchHost): string
194194
}
195195

196196
// used to display the Welcome Page in apps that don't define a homepage
197-
$code .= " if ('/' === \$pathinfo && !\$allow) {\n";
197+
$code .= " if ('/' === \$pathinfo && !\$allow && !\$allowSchemes) {\n";
198198
$code .= " throw new Symfony\Component\Routing\Exception\NoConfigurationException();\n";
199199
$code .= " }\n";
200200

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher0.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function match($rawPathinfo)
2626
$canonicalMethod = 'GET';
2727
}
2828

29-
if ('/' === $pathinfo && !$allow) {
29+
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
3030
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
3131
}
3232

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public function match($rawPathinfo)
238238
$offset += strlen($m);
239239
}
240240
}
241-
if ('/' === $pathinfo && !$allow) {
241+
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
242242
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
243243
}
244244

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher10.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2821,7 +2821,7 @@ public function match($rawPathinfo)
28212821
$offset += strlen($m);
28222822
}
28232823
}
2824-
if ('/' === $pathinfo && !$allow) {
2824+
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
28252825
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
28262826
}
28272827

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher11.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private function doMatch(string $rawPathinfo, array &$allow = array(), array &$a
142142
$offset += strlen($m);
143143
}
144144
}
145-
if ('/' === $pathinfo && !$allow) {
145+
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
146146
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
147147
}
148148

src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher12.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function match($rawPathinfo)
9191
$offset += strlen($m);
9292
}
9393
}
94-
if ('/' === $pathinfo && !$allow) {
94+
if ('/' === $pathinfo && !$allow && !$allowSchemes) {
9595
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
9696
}
9797

0 commit comments

Comments
 (0)