From 0eece8222babd9ea87fbb39ea1a594a7ae979b73 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Sat, 30 Apr 2016 01:56:09 -0400 Subject: [PATCH] Fix autoloading of 'html' class and improve autoloader performance --- program/lib/Roundcube/bootstrap.php | 36 +++++++++++++++++------------------- 1 files changed, 17 insertions(+), 19 deletions(-) diff --git a/program/lib/Roundcube/bootstrap.php b/program/lib/Roundcube/bootstrap.php index 94e628b..f9d9b69 100644 --- a/program/lib/Roundcube/bootstrap.php +++ b/program/lib/Roundcube/bootstrap.php @@ -428,27 +428,25 @@ */ function rcube_autoload($classname) { - $filename = preg_replace( - array( - '/Mail_(.+)/', - '/Net_(.+)/', - '/Auth_(.+)/', - '/^html_.+/', - '/^rcube(.*)/' - ), - array( - 'Mail/\\1', - 'Net/\\1', - 'Auth/\\1', - 'Roundcube/html', - 'Roundcube/rcube\\1' - ), - $classname - ); + if (strpos($classname, 'rcube') === 0) { + $classname = 'Roundcube/' . $classname; + } + else if (strpos($classname, 'html_') === 0 || $classname === 'html') { + $classname = 'Roundcube/html'; + } + else if (strpos($classname, 'Mail_') === 0) { + $classname = 'Mail/' . substr($classname, 5); + } + else if (strpos($classname, 'Net_') === 0) { + $classname = 'Net/' . substr($classname, 4); + } + else if (strpos($classname, 'Auth_') === 0) { + $classname = 'Auth/' . substr($classname, 5); + } - if ($fp = @fopen("$filename.php", 'r', true)) { + if ($fp = @fopen("$classname.php", 'r', true)) { fclose($fp); - include_once "$filename.php"; + include_once "$classname.php"; return true; } -- Gitblit v1.9.1