8000 Merge branch '2.7' into 2.8 · symfony/symfony@d175340 · GitHub
[go: up one dir, main page]

Skip to content

Commit d175340

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: [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 f971f4f + 359a063 commit d175340

File tree

6 files changed

+72
-16
lines changed

6 files changed

+72
-16
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,12 @@ private function addTaggedListeners(ContainerBuilder $container)
109109
throw new RuntimeException(sprintf('The Doctrine connection "%s" referenced in service "%s" does not exist. Available connections names: %s', $con, $id, implode(', ', array_keys($this->connections))));
110110
}
111111

112-
if ($lazy = isset($tag['lazy']) && $tag['lazy']) {
112+
if ($lazy = !empty($tag['lazy'])) {
113113
$taggedListenerDef->setPublic(true);
114114
}
115115

116116
// we add one call per event per service so we have the correct order
117-
$this->getEventManagerDef($container, $con)->addMethodCall('addEventListener', array(
118-
$tag['event'],
119-
$lazy ? $id : new Reference($id),
120-
));
117+
$this->getEventManagerDef($container, $con)->addMethodCall('addEventListener', array(array($tag['event']), $lazy ? $id : new Reference($id)));
121118
}
122119
}
123120
}

src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPassTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ public function testProcessEventListenersWithPriorities()
9090

9191
$this->assertEquals(
9292
array(
93-
array('addEventListener', array('foo_bar', new Reference('c'))),
94-
array('addEventListener', array('foo_bar', new Reference('a'))),
95-
array('addEventListener', array('bar', new Reference('a'))),
96-
array('addEventListener', array('foo', new Reference('b'))),
97-
array('addEventListener', array('foo', new Reference('a'))),
93+
array('addEventListener', array(array('foo_bar'), new Reference('c'))),
94+
array('addEventListener', array(array('foo_bar'), new Reference('a'))),
95+
array('addEventListener', array(array('bar'), new Reference('a'))),
96+
array('addEventListener', array(array('foo'), new Reference('b'))),
97+
array('addEventListener', array(array('foo'), new Reference('a'))),
9898
),
9999
$methodCalls
100100
);
@@ -138,16 +138,16 @@ public function testProcessEventListenersWithMultipleConnections()
138138

139139
$this->assertEquals(
140140
array(
141-
array('addEventListener', array('onFlush', new Reference('a'))),
142-
array('addEventListener', array('onFlush', new Reference('b'))),
141+
array('addEventListener', array(array('onFlush'), new Reference('a'))),
142+
array('addEventListener', array(array('onFlush'), new Reference('b'))),
143143
),
144144
$container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls()
145145
);
146146

147147
$this->assertEquals(
148148
array(
149-
array('addEventListener', array('onFlush', new Reference('a'))),
150-
array('addEventListener', array('onFlush', new Reference('c'))),
149+
array('addEventListener', array(array('onFlush'), new Reference('a'))),
150+
array('addEventListener', array(array('onFlush'), new Reference('c'))),
151151
),
152152
$container->getDefinition('doctrine.dbal.second_connection.event_manager')->getMethodCalls()
153153
);

src/Symfony/Component/Filesystem/Filesystem.php

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

365+
if ('/' !== $startPath[0]) {
366+
array_shift($startPathArr);
367+
}
368+
369+
if ('/' !== $endPath[0]) {
370+
array_shift($endPathArr);
371+
}
372+
373+
$normalizePathArray = function ($pathSegments) {
374+
$result = array();
375+
376+
foreach ($pathSegments as $segment) {
377+
if ('..' === $segment) {
378+
array_pop($result);
379+
} else {
380+
$result[] = $segment;
381+
}
382+
}
383+
384+
return $result;
385+
};
386+
387+
$startPathArr = $normalizePathArray($startPathArr);
388+
$endPathArr = $normalizePathArray($endPathArr);
389+
365390
// Find for which directory the common path stops
366391
$index = 0;
367392
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
@@ -868,6 +868,16 @@ public function providePathsForMakePathRelative()
868868
array('/a/aab/bb/', '/b/aab', '../../a/aab/bb/'),
869869
array('/aab/bb', '/aa', '../aab/bb/'),
870870
array('/aab', '/aa', '../aab/'),
871+
array('/aa/bb/cc', '/aa/dd/..', 'bb/cc/'),
872+
array('/aa/../bb/cc', '/aa/dd/..', '../bb/cc/'),
873+
array('/aa/bb/../../cc', '/aa/../dd/..', 'cc/'),
874+
array('/../aa/bb/cc', '/aa/dd/..', 'bb/cc/'),
875+
array('/../../aa/../bb/cc', '/aa/dd/..', '../bb/cc/'),
876+
array('C:/aa/bb/cc', 'C:/aa/dd/..', 'bb/cc/'),
877+
array('c:/aa/../bb/cc', 'c:/aa/dd/..', '../bb/cc/'),
878+
array('C:/aa/bb/../../cc', 'C:/aa/../dd/..', 'cc/'),
879+
array('C:/../aa/bb/cc', 'C:/aa/dd/..', 'bb/cc/'),
880+
array('C:/../../aa/../bb/cc', 'C:/aa/dd/..', '../bb/cc/'),
871881
);
872882

873883
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)
0