From 2e2390cc001d30a7eb3e47dc69bed53c71c005f4 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 20 Mar 2016 09:12:52 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E5=99=A8=E7=B1=BB=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=85=AC=E5=85=B1=E7=9B=AE=E5=BD=95=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=20=E4=BF=AE=E6=AD=A3Route=E7=B1=BB=E5=8D=95=E4=B8=80=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=B8=8B=E9=9D=A2GET=E5=8F=98=E9=87=8F=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E9=94=99=E8=AF=AF=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Loader.php | 11 +++++++---- library/think/Route.php | 6 +++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/library/think/Loader.php b/library/think/Loader.php index 88005a55..2232ac57 100644 --- a/library/think/Loader.php +++ b/library/think/Loader.php @@ -371,12 +371,15 @@ class Loader } $class = self::parseClass($module, $layer, $name); if (class_exists($class)) { - $validate = new $class; - $_instance[$name . $layer] = $validate; - return $validate; + $validate = new $class; } else { - throw new Exception('class [ ' . $class . ' ] not exists', 10001); + $class = str_replace('\\' . $module . '\\', '\\' . COMMON_MODULE . '\\', $class); + if (class_exists($class)) { + $validate = new $class; + } } + $_instance[$name . $layer] = $validate; + return $validate; } /** diff --git a/library/think/Route.php b/library/think/Route.php index ffc6dd7f..4e5dc38a 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -553,11 +553,11 @@ class Route if (false !== strpos($url, '?')) { // [模块/控制器/操作?]参数1=值1&参数2=值2... $info = parse_url($url); - $path = explode('/', $info['path'], 4); + $path = explode('/', $info['path'], APP_MULTI_MODULE ? 4 : 3); parse_str($info['query'], $var); } elseif (strpos($url, '/')) { // [模块/控制器/操作] - $path = explode('/', $url, 4); + $path = explode('/', $url, APP_MULTI_MODULE ? 4 : 3); } elseif (false !== strpos($url, '=')) { // 参数1=值1&参数2=值2... parse_str($url, $var); @@ -567,7 +567,7 @@ class Route $route = [null, null, null]; if (isset($path)) { // 解析path额外的参数 - if (!empty($path[3])) { + if (!empty($path[APP_MULTI_MODULE ? 3 : 2])) { preg_replace_callback('/([^\/]+)\/([^\/]+)/', function ($match) use (&$var) { $var[strtolower($match[1])] = strip_tags($match[2]); }, array_pop($path));