Skip to content

Commit dc66960

Browse files
committed
Merge branch '2.8' into 3.2
* 2.8: [Bridge\Doctrine] Fix change breaking doctrine-bundle test suite [HttpFoundation][bugfix] should always be initialized MockArraySessionStorage: updated phpdoc for $bags so that IDE autocompletion would work normalize paths before making them relative
2 parents 3526d23 + d175340 commit dc66960

File tree

5 files changed

+62
-3
lines changed

5 files changed

+62
-3
lines changed

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private function groupByConnection(array $services, $isListener = false)
122122
}
123123
$instance['event'] = array($instance['event']);
124124

125-
if (isset($instance['lazy']) && $instance['lazy']) {
125+
if ($lazy = !empty($instance['lazy'])) {
126126
$this->container->getDefinition($id)->setPublic(true);
127127
}
128128
}

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,31 @@ public function makePathRelative($endPath, $startPath)
446446
$startPathArr = explode('/', trim($startPath, '/'));
447447
$endPathArr = explode('/', trim($endPath, '/'));
448448

449+
if ('/' !== $startPath[0]) {
450+
array_shift($startPathArr);
451+
}
452+
453+
if ('/' !== $endPath[0]) {
454+
array_shift($endPathArr);
455+
}
456+
457+
$normalizePathArray = function ($pathSegments) {
458+
$result = array();
459+
460+
foreach ($pathSegments as $segment) {
461+
if ('..' === $segment) {
462+
array_pop($result);
463+
} else {
464+
$result[] = $segment;
465+
}
466+
}
467+
468+
return $result;
469+
};
470+
471+
$startPathArr = $normalizePathArray($startPathArr);
472+
$endPathArr = $normalizePathArray($endPathArr);
473+
449474
// Find for which directory the common path stops
450475
$index = 0;
451476
while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) {

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,16 @@ public function providePathsForMakePathRelative()
11171117
array('/a/aab/bb/', '/b/aab', '../../a/aab/bb/'),
11181118
array('/aab/bb', '/aa', '../aab/bb/'),
11191119
array('/aab', '/aa', '../aab/'),
1120+
array('/aa/bb/cc', '/aa/dd/..', 'bb/cc/'),
1121+
array('/aa/../bb/cc', '/aa/dd/..', '../bb/cc/'),
1122+
array('/aa/bb/../../cc', '/aa/../dd/..', 'cc/'),
1123+
array('/../aa/bb/cc', '/aa/dd/..', 'bb/cc/'),
1124+
array('/../../aa/../bb/cc', '/aa/dd/..', '../bb/cc/'),
1125+
array('C:/aa/bb/cc', 'C:/aa/dd/..', 'bb/cc/'),
1126+
array('c:/aa/../bb/cc', 'c:/aa/dd/..', '../bb/cc/'),
1127+
array('C:/aa/bb/../../cc', 'C:/aa/../dd/..', 'cc/'),
1128+
array('C:/../aa/bb/cc', 'C:/aa/dd/..', 'bb/cc/'),
1129+
array('C:/../../aa/../bb/cc', 'C:/aa/dd/..', '../bb/cc/'),
11201130
);
11211131

11221132
if ('\\' === DIRECTORY_SEPARATOR) {

src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ class MockArraySessionStorage implements SessionStorageInterface
5858
protected $metadataBag;
5959

6060
/**
61-
* @var array
61+
* @var array|SessionBagInterface[]
6262
*/
63-
protected $bags;
63+
protected $bags = array();
6464

6565
/**
6666
* Constructor.

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,30 @@ public function testGetId()
9797
$this->assertNotEquals('', $this->storage->getId());
9898
}
9999

100+
public function testClearClearsBags()
101+
{
102+
$this->storage->clear();
103+
104+
$this->assertSame(array(), $this->storage->getBag('attributes')->all());
105+
$this->assertSame(array(), $this->storage->getBag('flashes')->peekAll());
106+
}
107+
108+
public function testClearStartsSession()
109+
{
110+
$this->storage->clear();
111+
112+
$this->assertTrue($this->storage->isStarted());
113+
}
114+
115+
public function testClearWithNoBagsStartsSession()
116+
{
117+
$storage = new MockArraySessionStorage();
118+
119+
$storage->clear();
120+
121+
$this->assertTrue($storage->isStarted());
122+
}
123+
100124
/**
101125
* @expectedException \RuntimeException
102126
*/

0 commit comments

Comments
 (0)