8000 Fixed autoloader leakage in tests · fixe/symfony@878c239 · GitHub
[go: up one dir, main page]

Skip to content

Commit 878c239

Browse files
committed
Fixed autoloader leakage in tests
The autoloader for proxies is now unregistered on shutdown to avoid having several instances registered at the same time in tests.
1 parent b062cc7 commit 878c239

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Symfony/Bundle/DoctrineBundle/DoctrineBundle.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
class DoctrineBundle extends Bundle
2626
{
27+
private $autoloader;
28+
2729
public function build(ContainerBuilder $container)
2830
{
2931
parent::build($container);
@@ -44,7 +46,7 @@ class_exists('Doctrine\ORM\Mapping\Driver\AnnotationDriver');
4446
$dir = $this->container->getParameter('doctrine.orm.proxy_dir');
4547
$container =& $this->container;
4648

47-
spl_autoload_register(function($class) use ($namespace, $dir, &$container) {
49+
$this->autoloader = function($class) use ($namespace, $dir, &$container) {
4850
if (0 === strpos($class, $namespace)) {
4951
$className = substr($class, strlen($namespace) +1);
5052
$file = $dir.DIRECTORY_SEPARATOR.$className.'.php';
@@ -78,7 +80,16 @@ class_exists('Doctrine\ORM\Mapping\Driver\AnnotationDriver');
7880

7981
require $file;
8082
}
81-
});
83+
};
84+
spl_autoload_register($this->autoloader);
85+
}
86+
}
87+
88+
public function shutdown()
89+
{
90+
if (null !== $this->autoloader) {
91+
spl_autoload_unregister($this->autoloader);
92+
$this->autoloader = null;
8293
}
8394
}
8495
}

0 commit comments

Comments
 (0)
0