MDL-50153 core: Use directory_separator when autoloading psr0 classes
authorAndrew Nicols <andrew@nicols.co.uk>
Fri, 8 May 2015 02:15:58 +0000 (10:15 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Fri, 8 May 2015 04:14:48 +0000 (12:14 +0800)
lib/classes/component.php

index 3a7c37b..519bbab 100644 (file)
@@ -707,12 +707,12 @@ $cache = '.var_export($cache, true).';
      */
     protected static function load_psr_classes($basedir, $subdir = null) {
         if ($subdir) {
-            $fulldir = implode(DIRECTORY_SEPARATOR, array($basedir, $subdir));
-            $classnameprefix = preg_replace('/\//', '_', $subdir);
+            $fulldir = realpath($basedir . DIRECTORY_SEPARATOR . $subdir);
+            $classnameprefix = preg_replace('#' . preg_quote(DIRECTORY_SEPARATOR) . '#', '_', $subdir);
         } else {
             $fulldir = $basedir;
         }
-        if (!is_dir($fulldir)) {
+        if (!$fulldir || !is_dir($fulldir)) {
             return;
         }