Skip to content
Browse files

merged branch stof/doctrine_autoload (PR #3584)

Commits
-------

878c239 Fixed autoloader leakage in tests

Discussion
----------

Doctrine autoload

The autoloader for proxies is now unregistered on shutdown to avoid
having several instances registered at the same time in tests.
  • Loading branch information...
2 parents b062cc7 + 878c239 commit e335fa208c1c44202651f760503816869994ea86 @fabpot fabpot committed Mar 13, 2012
Showing with 13 additions and 2 deletions.
  1. +13 −2 src/Symfony/Bundle/DoctrineBundle/DoctrineBundle.php
View
15 src/Symfony/Bundle/DoctrineBundle/DoctrineBundle.php
@@ -24,6 +24,8 @@
*/
class DoctrineBundle extends Bundle
{
+ private $autoloader;
+
public function build(ContainerBuilder $container)
{
parent::build($container);
@@ -44,7 +46,7 @@ class_exists('Doctrine\ORM\Mapping\Driver\AnnotationDriver');
$dir = $this->container->getParameter('doctrine.orm.proxy_dir');
$container =& $this->container;
- spl_autoload_register(function($class) use ($namespace, $dir, &$container) {
+ $this->autoloader = function($class) use ($namespace, $dir, &$container) {
if (0 === strpos($class, $namespace)) {
$className = substr($class, strlen($namespace) +1);
$file = $dir.DIRECTORY_SEPARATOR.$className.'.php';
@@ -78,7 +80,16 @@ class_exists('Doctrine\ORM\Mapping\Driver\AnnotationDriver');
require $file;
}
- });
+ };
+ spl_autoload_register($this->autoloader);
+ }
+ }
+
+ public function shutdown()
+ {
+ if (null !== $this->autoloader) {
+ spl_autoload_unregister($this->autoloader);
+ $this->autoloader = null;
}
}
}

0 comments on commit e335fa2

Please sign in to comment.
Something went wrong with that request. Please try again.