Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix ClassLoader to respect foreign class loaders #88

Closed
wants to merge 1 commit into from

2 participants

@beberlei
Owner

This was already fixed in latest common several days ago.

@beberlei beberlei closed this
@juzna

Thanks, I encountered the problem before Xmas but didn't have enough time to submit this pull request until now. It's great how quickly you solve such issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 27, 2011
  1. @juzna
This page is out of date. Refresh to see the latest.
View
2  lib/Doctrine/Common/ClassLoader.php
@@ -236,7 +236,7 @@ public static function classExists($className)
}
}
- return false;
+ return class_exists($className, false); // test again since loader may have loaded it while not returning true
}
/**
View
12 tests/Doctrine/Tests/Common/ClassLoaderTest.php
@@ -42,4 +42,16 @@ public function testGetClassLoader()
$this->assertNull(ClassLoader::getClassLoader('This\Class\Does\Not\Exist'));
$cl->unregister();
}
+
+ public function testForeignClassLoader()
+ {
+ $this->assertFalse(ClassLoader::classExists('ClassLoaderTest\ClassE'));
+ $badLoader = function($className) {
+ require __DIR__ . '/ClassLoaderTest/ClassE.php';
+ // do not return anything like most classloaders
+ };
+ spl_autoload_register($badLoader);
+ $this->assertTrue(ClassLoader::classExists('ClassLoaderTest\ClassE'));
+ spl_autoload_unregister($badLoader);
+ }
}
View
5 tests/Doctrine/Tests/Common/ClassLoaderTest/ClassE.php
@@ -0,0 +1,5 @@
+<?php
+
+namespace ClassLoaderTest;
+
+class ClassE {}
Something went wrong with that request. Please try again.