Merge pull request #24732 from owncloud/autoloader_fix

Autoloader fix
This commit is contained in:
Vincent Petry 2016-05-21 19:09:22 +02:00
commit 7a6966cdfe
4 changed files with 2 additions and 22 deletions

View File

@ -102,8 +102,6 @@ class Autoloader {
} }
} elseif (strpos($class, 'OC_') === 0) { } elseif (strpos($class, 'OC_') === 0) {
$paths[] = \OC::$SERVERROOT . '/lib/private/legacy/' . strtolower(str_replace('_', '/', substr($class, 3)) . '.php'); $paths[] = \OC::$SERVERROOT . '/lib/private/legacy/' . strtolower(str_replace('_', '/', substr($class, 3)) . '.php');
} elseif (strpos($class, 'OCP\\') === 0) {
$paths[] = \OC::$SERVERROOT . '/lib/public/' . strtolower(str_replace('\\', '/', substr($class, 4)) . '.php');
} elseif (strpos($class, 'OCA\\') === 0) { } elseif (strpos($class, 'OCA\\') === 0) {
list(, $app, $rest) = explode('\\', $class, 3); list(, $app, $rest) = explode('\\', $class, 3);
$app = strtolower($app); $app = strtolower($app);

View File

@ -481,11 +481,7 @@ class OC {
$loaderStart = microtime(true); $loaderStart = microtime(true);
require_once __DIR__ . '/autoloader.php'; require_once __DIR__ . '/autoloader.php';
self::$loader = new \OC\Autoloader([ self::$loader = new \OC\Autoloader([
OC::$SERVERROOT . '/lib', OC::$SERVERROOT . '/lib/private/legacy',
OC::$SERVERROOT . '/core',
OC::$SERVERROOT . '/settings',
OC::$SERVERROOT . '/ocs',
OC::$SERVERROOT . '/ocs-provider',
]); ]);
if (defined('PHPUNIT_RUN')) { if (defined('PHPUNIT_RUN')) {
self::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); self::$loader->addValidRoot(OC::$SERVERROOT . '/tests');

View File

@ -19,18 +19,6 @@ class AutoLoaderTest extends TestCase {
$this->loader = new \OC\AutoLoader([]); $this->loader = new \OC\AutoLoader([]);
} }
public function testLeadingSlashOnClassName() {
$this->assertEquals([
\OC::$SERVERROOT . '/lib/public/files/storage/local.php',
], $this->loader->findClass('\OCP\Files\Storage\Local'));
}
public function testNoLeadingSlashOnClassName() {
$this->assertEquals([
\OC::$SERVERROOT . '/lib/public/files/storage/local.php',
], $this->loader->findClass('OCP\Files\Storage\Local'));
}
public function testLegacyPath() { public function testLegacyPath() {
$this->assertEquals([ $this->assertEquals([
\OC::$SERVERROOT . '/lib/private/legacy/files.php', \OC::$SERVERROOT . '/lib/private/legacy/files.php',
@ -50,9 +38,7 @@ class AutoLoaderTest extends TestCase {
} }
public function testLoadPublicNamespace() { public function testLoadPublicNamespace() {
$this->assertEquals([ $this->assertEquals([], $this->loader->findClass('OCP\Foo\Bar'));
\OC::$SERVERROOT . '/lib/public/foo/bar.php',
], $this->loader->findClass('OCP\Foo\Bar'));
} }
public function testLoadAppNamespace() { public function testLoadAppNamespace() {