Skip to content

Commit cd14b22

Browse files
Merge branch '3.4' into 4.1
* 3.4: [travis] fix composer.lock invalidation for deps=low [Security\Http] Restore laziness of listener iterator
2 parents a09809b + 6bab0c1 commit cd14b22

File tree

2 files changed

+87
-18
lines changed

2 files changed

+87
-18
lines changed

.github/rm-invalid-lowest-lock-files.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<?php
22

3+
error_reporting(-1);
4+
set_error_handler(function ($type, $message, $file, $line) {
5+
if (error_reporting()) {
6+
throw new \ErrorException($message, 0, $type, $file, $line);
7+
}
8+
});
39
array_shift($_SERVER['argv']);
410
$dirs = $_SERVER['argv'];
511

@@ -59,6 +65,8 @@ function getContentHash(array $composerJson)
5965
$composerJsons[$composerJson['name']] = array($dir, $composerLock['packages'], getRelevantContent($composerJson));
6066
}
6167

68+
$referencedCommits = array();
69+
6270
foreach ($composerJsons as list($dir, $lockedPackages)) {
6371
foreach ($lockedPackages as $lockedJson) {
6472
if (0 !== strpos($version = $lockedJson['version'], 'dev-') && '-dev' !== substr($version, -4)) {
@@ -83,5 +91,59 @@ function getContentHash(array $composerJson)
8391
@unlink($dir.'/composer.lock');
8492
continue 2;
8593
}
94+
95+
$referencedCommits[$name][$lockedJson['source']['reference']][] = $dir;
96+
}
97+
}
98+
99+
if (!$referencedCommits || (isset($_SERVER['TRAVIS_PULL_REQUEST']) && 'false' === $_SERVER['TRAVIS_PULL_REQUEST'])) {
100+
// cached commits cannot be stale for PRs
101+
return;
102+
}
103+
104+
@mkdir($_SERVER['HOME'].'/.cache/composer/repo/https---repo.packagist.org', 0777, true);
105+
106+
$ch = null;
107+
$mh = curl_multi_init();
108+
$sh = curl_share_init();
109+
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
110+
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
111+
curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
112+
$chs = array();
113+
114+
foreach ($referencedCommits as $name => $dirsByCommit) {
115+
$chs[] = $ch = array(curl_init(), fopen($_SERVER['HOME'].'/.cache/composer/repo/https---repo.packagist.org/provider-'.strtr($name, '/', '$').'.json', 'wb'));
116+
curl_setopt($ch[0], CURLOPT_URL, 'https://repo.packagist.org/p/'.$name.'.json');
117+
curl_setopt($ch[0], CURLOPT_FILE, $ch[1]);
118+
curl_setopt($ch[0], CURLOPT_SHARE, $sh);
119+
curl_multi_add_handle($mh, $ch[0]);
120+
}
121+
122+
do {
123+
curl_multi_exec($mh, $active);
124+
curl_multi_select($mh);
125+
} while ($active);
126+
127+
foreach ($chs as list($ch, $fd)) {
128+
curl_multi_remove_handle($mh, $ch);
129+
curl_close($ch);
130+
fclose($fd);
131+
}
132+
133+
foreach ($referencedCommits as $name => $dirsByCommit) {
134+
$repo = file_get_contents($_SERVER['HOME'].'/.cache/composer/repo/https---repo.packagist.org/provider-'.strtr($name, '/', '$').'.json');
135+
$repo = json_decode($repo, true);
136+
137+
foreach ($repo['packages'][$name] as $version) {
138+
unset($referencedCommits[$name][$version['source']['reference']]);
139+
}
140+
}
141+
142+
foreach ($referencedCommits as $name => $dirsByCommit) {
143+
foreach ($dirsByCommit as $dirs) {
144+
foreach ($dirs as $dir) {
145+
echo "$dir/composer.lock references old commit for $name.\n";
146+
@unlink($dir.'/composer.lock');
147+
}
86148
}
87149
}

src/Symfony/Component/Security/Http/Firewall.php

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,38 @@ public function onKernelRequest(GetResponseEvent $event)
5050
// register listeners for this firewall
5151
$listeners = $this->map->getListeners($event->getRequest());
5252

53-
$accessListener = null;
54-
$authenticationListeners = array();
55-
56-
foreach ($listeners[0] as $listener) {
57-
if ($listener instanceof AccessListener) {
58-
$accessListener = $listener;
59-
} else {
60-
$authenticationListeners[] = $listener;
61-
}
62-
}
53+
$authenticationListeners = $listeners[0];
54+
$exceptionListener = $listeners[1];
55+
$logoutListener = isset($listeners[2]) ? $listeners[2] : null;
6356

64-
if (null !== $exceptionListener = $listeners[1]) {
57+
if (null !== $exceptionListener) {
6558
$this->exceptionListeners[$event->getRequest()] = $exceptionListener;
6659
$exceptionListener->register($this->dispatcher);
6760
}
6861

69-
if (null !== $logoutListener = isset($listeners[2]) ? $listeners[2] : null) {
70-
$authenticationListeners[] = $logoutListener;
71-
}
62+
$authenticationListeners = function () use ($authenticationListeners, $logoutListener) {
63+
$accessListener = null;
7264

73-
if (null !== $accessListener) {
74-
$authenticationListeners[] = $accessListener;
75-
}
65+
foreach ($authenticationListeners as $listener) {
66+
if ($listener instanceof AccessListener) {
67+
$accessListener = $listener;
68+
69+
continue;
70+
}
71+
72+
yield $listener;
73+
}
74+
75+
if (null !== $logoutListener) {
76+
yield $logoutListener;
77+
}
78+
79+
if (null !== $accessListener) {
80+
yield $accessListener;
81+
}
82+
};
7683

77-
$this->handleRequest($event, $authenticationListeners);
84+
$this->handleRequest($event, $authenticationListeners());
7885
}
7986

8087
public function onKernelFinishRequest(FinishRequestEvent $event)

0 commit comments

Comments
 (0)