From 9facb67fab0cc9556e681ff75ec59218eb2ba34b Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Thu, 18 Apr 2013 08:30:09 +0200 Subject: [PATCH 1/2] Let autoloader resolve paths under apps lib directory. --- lib/base.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/base.php b/lib/base.php index dde994a7e5..72645d0778 100644 --- a/lib/base.php +++ b/lib/base.php @@ -97,8 +97,14 @@ class OC { $path = 'public/' . strtolower(str_replace('\\', '/', substr($className, 3)) . '.php'); } elseif (strpos($className, 'OCA\\') === 0) { foreach (self::$APPSROOTS as $appDir) { - $path = $appDir['path'] . '/' . strtolower(str_replace('\\', '/', substr($className, 3)) . '.php'); - $fullPath = stream_resolve_include_path($path); + $path = strtolower(str_replace('\\', '/', substr($className, 4)) . '.php'); + $fullPath = stream_resolve_include_path($appDir['path'] . '/' . $path); + if (file_exists($fullPath)) { + require_once $fullPath; + return false; + } + $libpath = substr($path, 0, strpos($path, '/')) . '/lib' . substr($path, strpos($path, '/')); + $fullPath = stream_resolve_include_path($appDir['path'] . '/' . $libpath); if (file_exists($fullPath)) { require_once $fullPath; return false; From e09c17de5b25d6c728bc6b828dcc686ce66ae134 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Thu, 18 Apr 2013 22:29:50 +0200 Subject: [PATCH 2/2] Added explanation --- lib/base.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/base.php b/lib/base.php index 72645d0778..16b0da7c77 100644 --- a/lib/base.php +++ b/lib/base.php @@ -103,6 +103,7 @@ class OC { require_once $fullPath; return false; } + // If not found in the root of the app directory, insert '/lib' after app id and try again. $libpath = substr($path, 0, strpos($path, '/')) . '/lib' . substr($path, strpos($path, '/')); $fullPath = stream_resolve_include_path($appDir['path'] . '/' . $libpath); if (file_exists($fullPath)) {