From 367242113dd43c99bd724f6f29ed2892ee6bb205 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 21 Oct 2016 12:02:29 +0800 Subject: [PATCH 01/46] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=99=A8=E8=87=AA=E5=8A=A8=E6=90=9C=E7=B4=A2=E5=90=8E=E7=9A=84?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=99=A8=E5=90=8D=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/library/think/Route.php b/library/think/Route.php index 660b8d32..d045ec95 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -1176,15 +1176,22 @@ class Route $dir = APP_PATH . ($module ? $module . DS : '') . Config::get('url_controller_layer'); $suffix = App::$suffix || Config::get('controller_suffix') ? ucfirst(Config::get('url_controller_layer')) : ''; $item = []; + $find = false; foreach ($path as $val) { - $item[] = array_shift($path); - if (is_file($dir . DS . $val . $suffix . EXT)) { + $item[] = $val; + if (is_file($dir . DS . str_replace('.', DS, $val) . $suffix . EXT)) { + $find = true; break; } else { $dir .= DS . $val; } } - $controller = implode('.', $item); + if ($find) { + $controller = implode('.', $item); + $path = array_slice($path, count($item)); + } else { + $controller = array_shift($path); + } } else { // 解析控制器 $controller = !empty($path) ? array_shift($path) : null; From afa1376941d8692c8c0a0b191b4055392b353f47 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 21 Oct 2016 17:21:09 +0800 Subject: [PATCH 02/46] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E9=AA=8C=E8=AF=81=E8=A7=84=E5=88=99=E7=9A=84=E4=BD=BF?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Validate.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/library/think/Validate.php b/library/think/Validate.php index ed12083c..d40a0f63 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -348,16 +348,21 @@ class Validate $result = call_user_func_array($rule, [$value, $data]); } else { // 判断验证类型 - if (is_numeric($key) && strpos($rule, ':')) { - list($type, $rule) = explode(':', $rule, 2); - if (isset($this->alias[$type])) { - // 判断别名 - $type = $this->alias[$type]; + if (is_numeric($key)) { + if (strpos($rule, ':')) { + list($type, $rule) = explode(':', $rule, 2); + if (isset($this->alias[$type])) { + // 判断别名 + $type = $this->alias[$type]; + } + $info = $type; + } elseif (method_exists($this, $rule)) { + $type = $rule; + $info = $rule; + } else { + $type = 'is'; + $info = $rule; } - $info = $type; - } elseif (is_numeric($key)) { - $type = 'is'; - $info = $rule; } else { $info = $type = $key; } From 5a417480a142dd6068147d3b8bdb9153b52e9775 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 21 Oct 2016 17:36:09 +0800 Subject: [PATCH 03/46] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=B1=BB=E7=9A=84activeUrl=E6=96=B9=E6=B3=95=20=E6=94=B9?= =?UTF-8?q?=E8=BF=9BQuery=E7=B1=BB=E5=88=86=E9=A1=B5=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E7=9A=84=E5=8F=82=E6=95=B0=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Validate.php | 3 +++ library/think/db/Query.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/library/think/Validate.php b/library/think/Validate.php index d40a0f63..f16fee1b 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -612,6 +612,9 @@ class Validate */ protected function activeUrl($value, $rule) { + if (!in_array($rule, ['A', 'MX', 'NS', 'SOA', 'PTR', 'CNAME', 'AAAA', 'A6', 'SRV', 'NAPTR', 'TXT', 'ANY'])) { + $rule = 'MX'; + } return checkdnsrr($value, $rule); } diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 52b0d18c..8a8617ff 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -989,8 +989,8 @@ class Query if (!isset($total) && !$simple) { $options = $this->getOptions(); - $total = $this->count(); $bind = $this->bind; + $total = $this->count(); $results = $this->options($options)->bind($bind)->page($page, $listRows)->select(); } elseif ($simple) { $results = $this->limit(($page - 1) * $listRows, $listRows + 1)->select(); From 294a49b8b1f65ab865a20d10cd54e6f3e72e587b Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 21 Oct 2016 17:51:19 +0800 Subject: [PATCH 04/46] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=B1=BB=E7=9A=84image=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Validate.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/library/think/Validate.php b/library/think/Validate.php index f16fee1b..0986c836 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -723,19 +723,24 @@ class Validate if (!($file instanceof File)) { return false; } - $rule = explode(',', $rule); - list($width, $height, $type) = getimagesize($file->getRealPath()); - if (isset($rule[2])) { - $imageType = strtolower($rule[2]); - if ('jpeg' == $imageType) { - $imageType = 'jpg'; - } - if (image_type_to_extension($type, false) != $imageType) { - return false; + if ($rule) { + $rule = explode(',', $rule); + list($width, $height, $type) = getimagesize($file->getRealPath()); + if (isset($rule[2])) { + $imageType = strtolower($rule[2]); + if ('jpeg' == $imageType) { + $imageType = 'jpg'; + } + if (image_type_to_extension($type, false) != $imageType) { + return false; + } } + + list($w, $h) = $rule; + return $w == $width && $h == $height; + } else { + return in_array($this->getImageType($file->getRealPath()), [1, 2, 3, 6]); } - list($w, $h) = $rule; - return $w == $width && $h == $height; } /** From d33ed07d00a520c7780e9ef58383129dd2022687 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 21 Oct 2016 18:03:47 +0800 Subject: [PATCH 05/46] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=B1=BB=E4=B8=80=E5=A4=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Validate.php | 1 + 1 file changed, 1 insertion(+) diff --git a/library/think/Validate.php b/library/think/Validate.php index 0986c836..fc38d89a 100644 --- a/library/think/Validate.php +++ b/library/think/Validate.php @@ -359,6 +359,7 @@ class Validate } elseif (method_exists($this, $rule)) { $type = $rule; $info = $rule; + $rule = ''; } else { $type = 'is'; $info = $rule; From a83af519032dec4ef83c5f44beb799111f2091e2 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 21 Oct 2016 23:05:33 +0800 Subject: [PATCH 06/46] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BB=E7=9A=84?= =?UTF-8?q?view=E6=96=B9=E6=B3=95=E5=92=8Cjoin=E6=96=B9=E6=B3=95=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BD=BF=E7=94=A8=E4=B8=8D=E5=B8=A6=E5=89=8D?= =?UTF-8?q?=E7=BC=80=E7=9A=84=E8=A1=A8=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 8a8617ff..e5c9b978 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -669,7 +669,11 @@ class Query $table = array_shift($join); } } else { - $table = trim($join); + $prefix = $this->prefix; + $table = trim($join); + if ($prefix && false === strpos($table, '(') && false === strpos($table, '.') && 0 !== strpos($table, $prefix) && 0 !== strpos($table, '__')) { + $table = $this->getTable($table); + } if (strpos($table, ' ') && !strpos($table, ')')) { list($table, $alias) = explode(' ', $table); $table = [$table => $alias]; @@ -763,13 +767,17 @@ class Query } } else { $fields = []; + $prefix = $this->prefix; if (is_array($join)) { // 支持数据表别名 - list($join, $alias, $table) = array_pad($join, 3, ''); + list($table, $alias) = ecch($join); + } elseif ($prefix && 0 !== strpos($join, $prefix) && 0 !== strpos($join, '__')) { + $table = $this->getTable($join); + $alias = $join; } else { $alias = $join; } - $table = !empty($table) ? $table : $this->getTable($join); + $table = isset($table) ? [$table => $alias] : $alias; if (true === $field) { $fields = $alias . '.*'; } else { @@ -793,9 +801,9 @@ class Query } $this->field($fields); if ($on) { - $this->join($table . ' ' . $alias, $on, $type); + $this->join($table, $on, $type); } else { - $this->table($table . ' ' . $alias); + $this->table($table); } } return $this; From 2c15118f6075bf0d27c65fb5b444c09ffb6292ff Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 21 Oct 2016 23:18:29 +0800 Subject: [PATCH 07/46] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BB=E7=9A=84?= =?UTF-8?q?join=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index e5c9b978..57a1fc50 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -670,14 +670,17 @@ class Query } } else { $prefix = $this->prefix; - $table = trim($join); - if ($prefix && false === strpos($table, '(') && false === strpos($table, '.') && 0 !== strpos($table, $prefix) && 0 !== strpos($table, '__')) { - $table = $this->getTable($table); - } - if (strpos($table, ' ') && !strpos($table, ')')) { - list($table, $alias) = explode(' ', $table); + $join = trim($join); + if ($prefix && false === strpos($join, '(') && false === strpos($join, '.') && 0 !== strpos($join, $prefix) && 0 !== strpos($join, '__')) { + $table = $this->getTable($join); + $table = [$table => $join]; + $this->alias($table); + } elseif (strpos($join, ' ') && !strpos($join, ')')) { + list($table, $alias) = explode(' ', $join); $table = [$table => $alias]; $this->alias($table); + } else { + $table = $join; } } $this->options['join'][] = [$table, strtoupper($type), $condition]; From 463dda9d0166a5aa498175e7b1cc9f181f0671bc Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 22 Oct 2016 12:58:05 +0800 Subject: [PATCH 08/46] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E5=9F=9F=E5=90=8D=E7=BB=91=E5=AE=9A=E5=90=8E=E7=9A=84url?= =?UTF-8?q?=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 2 +- library/think/Url.php | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/library/think/Route.php b/library/think/Route.php index d045ec95..315d6667 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -1203,7 +1203,7 @@ class Route // 封装路由 $route = [$module, $controller, $action]; if (isset(self::$rules['name'][implode($depr, $route)])) { - throw new HttpException(404, 'invalid request:' . $url); + throw new HttpException(404, 'invalid request:' . str_replace('|', $depr, $url)); } } return ['type' => 'module', 'module' => $route]; diff --git a/library/think/Url.php b/library/think/Url.php index 24087fc4..18b42c46 100644 --- a/library/think/Url.php +++ b/library/think/Url.php @@ -157,7 +157,7 @@ class Url } // 直接解析URL地址 - protected static function parseUrl($url, $domain) + protected static function parseUrl($url, &$domain) { $request = Request::instance(); if (0 === strpos($url, '/')) { @@ -171,16 +171,25 @@ class Url $url = substr($url, 1); } else { // 解析到 模块/控制器/操作 - $module = $request->module(); - $domains = Route::rules('domain'); - if (isset($domains[$domain]['[bind]'][0])) { - $bindModule = $domains[$domain]['[bind]'][0]; - if ($bindModule && !in_array($bindModule[0], ['\\', '@'])) { - $module = ''; + $module = $request->module(); + if (true === $domain) { + $domains = Route::rules('domain'); + foreach ($domains as $key => $item) { + if (isset($item['[bind]']) && 0 === strpos($url, $item['[bind]'][0])) { + $url = substr($url, strlen($item['[bind]'][0]) + 1); + $domain = $key; + $module = ''; + } + } + } elseif ($domain) { + if (isset($domains[$domain]['[bind]'][0])) { + $bindModule = $domains[$domain]['[bind]'][0]; + if ($bindModule && !in_array($bindModule[0], ['\\', '@'])) { + $module = ''; + } } - } else { - $module = $module ? $module . '/' : ''; } + $module = $module ? $module . '/' : ''; $controller = Loader::parseName($request->controller()); if ('' == $url) { From 04149e3ccede2c17236cacbe7a06682222d03905 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 22 Oct 2016 13:15:14 +0800 Subject: [PATCH 09/46] =?UTF-8?q?=E6=94=B9=E8=BF=9Bsession=E5=8A=A9?= =?UTF-8?q?=E6=89=8B=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper.php b/helper.php index 6ab2cb34..bcb52ea3 100644 --- a/helper.php +++ b/helper.php @@ -298,7 +298,7 @@ if (!function_exists('session')) { Session::init($name); } elseif (is_null($name)) { // 清除 - Session::clear($value); + Session::clear('' === $value ? null : $value); } elseif ('' === $value) { // 判断或获取 return 0 === strpos($name, '?') ? Session::has(substr($name, 1), $prefix) : Session::get($name, $prefix); From eb103a63a5c44e4268922897f0ff144bac9dfb2b Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 22 Oct 2016 13:21:49 +0800 Subject: [PATCH 10/46] =?UTF-8?q?=E6=94=B9=E8=BF=9BRequest=E7=B1=BBip?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Request.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/think/Request.php b/library/think/Request.php index bc43eb2f..c6f1198a 100644 --- a/library/think/Request.php +++ b/library/think/Request.php @@ -1241,8 +1241,7 @@ class Request if (false !== $pos) { unset($arr[$pos]); } - - $ip = trim($arr[0]); + $ip = trim(current($arr)); } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (isset($_SERVER['REMOTE_ADDR'])) { From 11f750071c6c339125fb7969ab1dbc70a1d230bb Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 22 Oct 2016 13:25:31 +0800 Subject: [PATCH 11/46] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Query=E7=B1=BB=E4=B8=80?= =?UTF-8?q?=E5=A4=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 57a1fc50..cf580b20 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -773,7 +773,7 @@ class Query $prefix = $this->prefix; if (is_array($join)) { // 支持数据表别名 - list($table, $alias) = ecch($join); + list($table, $alias) = each($join); } elseif ($prefix && 0 !== strpos($join, $prefix) && 0 !== strpos($join, '__')) { $table = $this->getTable($join); $alias = $join; From a6f72f9ce2eff95ea85a1fb6da400d608d3e8a0e Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 22 Oct 2016 15:02:10 +0800 Subject: [PATCH 12/46] =?UTF-8?q?=E6=94=B9=E8=BF=9BApp=E7=B1=BB=E7=9A=84?= =?UTF-8?q?=E5=8F=8D=E5=B0=84=E5=BC=82=E5=B8=B8=E6=97=A0=E6=B3=95=E6=8D=95?= =?UTF-8?q?=E8=8E=B7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/App.php | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/library/think/App.php b/library/think/App.php index 98a58d71..ce7fd37a 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -369,33 +369,28 @@ class App // 监听module_init Hook::listen('module_init', $request); - try { - $instance = Loader::controller($controller, $config['url_controller_layer'], $config['controller_suffix'], $config['empty_controller']); - if (is_null($instance)) { - throw new HttpException(404, 'controller not exists:' . Loader::parseName($controller, 1)); - } - // 获取当前操作名 - $action = $actionName . $config['action_suffix']; - if (!preg_match('/^[A-Za-z](\w)*$/', $action)) { - // 非法操作 - throw new \ReflectionException('illegal action name:' . $actionName); - } + $instance = Loader::controller($controller, $config['url_controller_layer'], $config['controller_suffix'], $config['empty_controller']); + if (is_null($instance)) { + throw new HttpException(404, 'controller not exists:' . Loader::parseName($controller, 1)); + } + // 获取当前操作名 + $action = $actionName . $config['action_suffix']; + if (is_callable([$instance, $action])) { // 执行操作方法 $call = [$instance, $action]; - Hook::listen('action_begin', $call); - - $data = self::invokeMethod($call); - } catch (\ReflectionException $e) { + } elseif (is_callable([$instance, '_empty'])) { + // 空操作 + $call = [$instance, '_empty']; + } else { // 操作不存在 - if (method_exists($instance, '_empty')) { - $reflect = new \ReflectionMethod($instance, '_empty'); - $data = $reflect->invokeArgs($instance, [$action]); - self::$debug && Log::record('[ RUN ] ' . $reflect->__toString(), 'info'); - } else { - throw new HttpException(404, 'method not exists:' . (new \ReflectionClass($instance))->getName() . '->' . $action); - } + throw new HttpException(404, 'method not exists:' . get_class($instance) . '->' . $action . '()'); } + + Hook::listen('action_begin', $call); + + $data = self::invokeMethod($call); + return $data; } From 9c57100d676e4617a160a38d599646e0f8d0874a Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 22 Oct 2016 19:42:55 +0800 Subject: [PATCH 13/46] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E6=A0=87=E8=AF=86?= =?UTF-8?q?=E4=B8=8D=E5=8C=BA=E5=88=86=E5=A4=A7=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/think/Route.php b/library/think/Route.php index 315d6667..5553a0fb 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -306,7 +306,7 @@ class Route $vars = self::parseVar($rule); if (isset($name)) { $key = $group ? $group . '/' . $rule : $rule; - self::name($name, [$key, $vars, self::$domain]); + self::name(strtolower($name), [$key, $vars, self::$domain]); } if ($group) { if ('*' != $type) { @@ -1202,7 +1202,7 @@ class Route self::parseUrlParams(empty($path) ? '' : implode('|', $path)); // 封装路由 $route = [$module, $controller, $action]; - if (isset(self::$rules['name'][implode($depr, $route)])) { + if (isset(self::$rules['name'][strtolower(implode($depr, $route))])) { throw new HttpException(404, 'invalid request:' . str_replace('|', $depr, $url)); } } From 79d640f3a9280e9f23f108c21790348d473b2628 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 22 Oct 2016 19:53:48 +0800 Subject: [PATCH 14/46] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Route=E7=B1=BBname?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 1 + 1 file changed, 1 insertion(+) diff --git a/library/think/Route.php b/library/think/Route.php index 5553a0fb..29116167 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -150,6 +150,7 @@ class Route } elseif (!is_null($value)) { self::$rules['name'][$name][] = $value; } else { + $name = strtolower($name); return isset(self::$rules['name'][$name]) ? self::$rules['name'][$name] : null; } } From d961dd976542c52c3b7b0bd56cd81c5efba0f8e0 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 22 Oct 2016 20:05:51 +0800 Subject: [PATCH 15/46] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E7=B1=BB=E7=9A=84parseUrl=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/think/Route.php b/library/think/Route.php index 29116167..df1b62b9 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -1203,7 +1203,7 @@ class Route self::parseUrlParams(empty($path) ? '' : implode('|', $path)); // 封装路由 $route = [$module, $controller, $action]; - if (isset(self::$rules['name'][strtolower(implode($depr, $route))])) { + if (isset(self::$rules['name'][strtolower($module . '/' . Loader::parseName($controller, 1) . '/' . $action)])) { throw new HttpException(404, 'invalid request:' . str_replace('|', $depr, $url)); } } From b5b5390832e7c509c8af2aa81c0fdfec3a0f5c33 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 22 Oct 2016 20:24:55 +0800 Subject: [PATCH 16/46] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=83=85=E5=86=B5=E4=B8=8B=20=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E6=A0=87=E8=AF=86=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/think/Route.php b/library/think/Route.php index df1b62b9..c07bf5e5 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -1203,7 +1203,14 @@ class Route self::parseUrlParams(empty($path) ? '' : implode('|', $path)); // 封装路由 $route = [$module, $controller, $action]; - if (isset(self::$rules['name'][strtolower($module . '/' . Loader::parseName($controller, 1) . '/' . $action)])) { + // 检查地址是否被定义过路由 + $name = strtolower($module . '/' . Loader::parseName($controller, 1) . '/' . $action); + $name2 = ''; + if (isset(self::$bind['module']) && $module == self::$bind['module']) { + $name2 = strtolower(Loader::parseName($controller, 1) . '/' . $action); + } + + if (isset(self::$rules['name'][$name]) || isset(self::$rules['name'][$name2])) { throw new HttpException(404, 'invalid request:' . str_replace('|', $depr, $url)); } } From 70e534f2fb1f0400555a180a339b58e71575ea5a Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 22 Oct 2016 21:02:04 +0800 Subject: [PATCH 17/46] =?UTF-8?q?=E6=94=B9=E8=BF=9BRoute=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/think/Route.php b/library/think/Route.php index c07bf5e5..24549d1a 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -1206,7 +1206,7 @@ class Route // 检查地址是否被定义过路由 $name = strtolower($module . '/' . Loader::parseName($controller, 1) . '/' . $action); $name2 = ''; - if (isset(self::$bind['module']) && $module == self::$bind['module']) { + if (empty($module) || isset(self::$bind['module']) && $module == self::$bind['module']) { $name2 = strtolower(Loader::parseName($controller, 1) . '/' . $action); } From ae7a9a08a7c7882b756148e0bb55715d25dcaede Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 23 Oct 2016 13:22:40 +0800 Subject: [PATCH 18/46] =?UTF-8?q?=E6=94=B9=E8=BF=9BRoute=E7=B1=BBrules?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/think/Route.php b/library/think/Route.php index 24549d1a..406c088e 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -683,7 +683,7 @@ class Route if (is_array($rules)) { self::$rules = $rules; } elseif ($rules) { - return true === $rules ? self::$rules : self::$rules[$rules]; + return true === $rules ? self::$rules : self::$rules[strtolower($rules)]; } else { $rules = self::$rules; unset($rules['pattern'], $rules['alias'], $rules['domain'], $rules['name']); From 747b7fe7fa59c504660005f0448868cedf71158f Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 23 Oct 2016 21:53:10 +0800 Subject: [PATCH 19/46] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=BB=91=E5=AE=9A=E5=88=B0=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=99=A8=E5=88=86=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/think/Route.php b/library/think/Route.php index 406c088e..be24c7c4 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -1163,8 +1163,9 @@ class Route { if (isset(self::$bind['module'])) { + $bind = str_replace('/', $depr, self::$bind['module']); // 如果有模块/控制器绑定 - $url = self::$bind['module'] . '/' . ltrim($url, '/'); + $url = $bind . ('.' != substr($bind, -1) ? $depr : '') . ltrim($url, $depr); } $url = str_replace($depr, '|', $url); list($path, $var) = self::parseUrlPath($url); From 4865355dfc3ec4aa9c217ee36bb45489d1cb7a4e Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 23 Oct 2016 22:10:53 +0800 Subject: [PATCH 20/46] =?UTF-8?q?=E6=94=B9=E8=BF=9BRoute=E7=B1=BBparseUrl?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/think/Route.php b/library/think/Route.php index be24c7c4..f3da8139 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -1207,7 +1207,7 @@ class Route // 检查地址是否被定义过路由 $name = strtolower($module . '/' . Loader::parseName($controller, 1) . '/' . $action); $name2 = ''; - if (empty($module) || isset(self::$bind['module']) && $module == self::$bind['module']) { + if (empty($module) || isset($bind) && $module == $bind) { $name2 = strtolower(Loader::parseName($controller, 1) . '/' . $action); } From 8f6cee67eda98af26e553ab447f3a0346d37dcf7 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 23 Oct 2016 22:29:11 +0800 Subject: [PATCH 21/46] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E6=94=B9=E4=B8=BA=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 53 +++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/library/think/Route.php b/library/think/Route.php index f3da8139..ca98d88f 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -24,13 +24,13 @@ class Route { // 路由规则 private static $rules = [ - 'GET' => [], - 'POST' => [], - 'PUT' => [], - 'DELETE' => [], - 'PATCH' => [], - 'HEAD' => [], - 'OPTIONS' => [], + 'get' => [], + 'post' => [], + 'put' => [], + 'delete' => [], + 'patch' => [], + 'head' => [], + 'options' => [], '*' => [], 'alias' => [], 'domain' => [], @@ -40,21 +40,22 @@ class Route // REST路由操作方法定义 private static $rest = [ - 'index' => ['GET', '', 'index'], - 'create' => ['GET', '/create', 'create'], - 'edit' => ['GET', '/:id/edit', 'edit'], - 'read' => ['GET', '/:id', 'read'], - 'save' => ['POST', '', 'save'], - 'update' => ['PUT', '/:id', 'update'], - 'delete' => ['DELETE', '/:id', 'delete'], + 'index' => ['get', '', 'index'], + 'create' => ['get', '/create', 'create'], + 'edit' => ['get', '/:id/edit', 'edit'], + 'read' => ['get', '/:id', 'read'], + 'save' => ['post', '', 'save'], + 'update' => ['put', '/:id', 'update'], + 'delete' => ['delete', '/:id', 'delete'], ]; // 不同请求类型的方法前缀 private static $methodPrefix = [ - 'GET' => 'get', - 'POST' => 'post', - 'PUT' => 'put', - 'DELETE' => 'delete', + 'get' => 'get', + 'post' => 'post', + 'put' => 'put', + 'delete' => 'delete', + 'patch' => 'patch', ]; // 子域名 @@ -199,7 +200,7 @@ class Route unset($rule['__rest__']); } - self::registerRules($rule, strtoupper($type)); + self::registerRules($rule, strtolower($type)); } // 批量注册路由 @@ -242,7 +243,7 @@ class Route $pattern = array_merge(self::getGroup('pattern'), $pattern); } - $type = strtoupper($type); + $type = strtolower($type); if (strpos($type, '|')) { $option['method'] = $type; @@ -329,7 +330,7 @@ class Route } if ('*' == $type) { // 注册路由快捷方式 - foreach (['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'] as $method) { + foreach (['get', 'post', 'put', 'delete', 'patch', 'head', 'options'] as $method) { if (self::$domain) { self::$rules['domain'][self::$domain][$method][$rule] = true; } else { @@ -432,7 +433,7 @@ class Route self::$rules['*'][$name] = ['rule' => $item, 'route' => '', 'var' => [], 'option' => $option, 'pattern' => $pattern]; } - foreach (['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'] as $method) { + foreach (['get', 'post', 'put', 'delete', 'patch', 'head', 'options'] as $method) { if (!isset(self::$rules[$method][$name])) { self::$rules[$method][$name] = true; } elseif (is_array(self::$rules[$method][$name])) { @@ -626,9 +627,9 @@ class Route public static function setMethodPrefix($method, $prefix = '') { if (is_array($method)) { - self::$methodPrefix = array_merge(self::$methodPrefix, array_change_key_case($method, CASE_UPPER)); + self::$methodPrefix = array_merge(self::$methodPrefix, array_change_key_case($method)); } else { - self::$methodPrefix[strtoupper($method)] = $prefix; + self::$methodPrefix[strtolower($method)] = $prefix; } } @@ -699,7 +700,7 @@ class Route * @param string $method 请求类型 * @return void */ - public static function checkDomain($request, &$currentRules, $method = 'GET') + public static function checkDomain($request, &$currentRules, $method = 'get') { // 域名规则 $rules = self::$rules['domain']; @@ -809,7 +810,7 @@ class Route return $result; } } - $method = $request->method(); + $method = strtolower($request->method()); // 获取当前请求类型的路由规则 $rules = self::$rules[$method]; // 检测域名部署 From aca32d1da34ddef7ad3c423c3dc46c77115e7157 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 23 Oct 2016 23:40:36 +0800 Subject: [PATCH 22/46] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0ajax=E5=92=8Cpjax?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base.php | 2 +- library/think/Route.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/base.php b/base.php index 1184dc51..b668120e 100644 --- a/base.php +++ b/base.php @@ -9,7 +9,7 @@ // | Author: liu21st // +---------------------------------------------------------------------- -define('THINK_VERSION', '5.0.2dev'); +define('THINK_VERSION', '5.0.2'); define('THINK_START_TIME', microtime(true)); define('THINK_START_MEM', memory_get_usage()); define('EXT', '.php'); diff --git a/library/think/Route.php b/library/think/Route.php index ca98d88f..2db507ed 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -1093,7 +1093,9 @@ class Route { // 请求类型检测 if ((isset($option['method']) && is_string($option['method']) && false === stripos($option['method'], $request->method())) - || (isset($option['ext']) && false === stripos($option['ext'], $request->ext())) // 伪静态后缀检测 + || (!empty($option['ajax']) && !$request->isAjax()) // Ajax检测 + || (!empty($option['pjax']) && !$request->isPjax()) // Pjax检测 + || (isset($option['ext']) && false === stripos($option['ext'], $request->ext())) // 伪静态后缀检测 || (isset($option['deny_ext']) && false !== stripos($option['deny_ext'], $request->ext())) || (isset($option['domain']) && !in_array($option['domain'], [$_SERVER['HTTP_HOST'], self::$subDomain])) // 域名检测 || (!empty($option['https']) && !$request->isSsl()) // https检测 From fa2bc7343d9dc012c7554ba05e702a88dcfea4a6 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 24 Oct 2016 07:11:16 +0800 Subject: [PATCH 23/46] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- convention.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/convention.php b/convention.php index 206603b1..2ef29dcd 100644 --- a/convention.php +++ b/convention.php @@ -85,6 +85,8 @@ return [ 'url_route_on' => true, // 路由配置文件(支持配置多个) 'route_config_file' => ['route'], + // 路由使用完整匹配 + 'route_complete_match' => false, // 是否强制使用路由 'url_route_must' => false, // 域名部署 From 4e8467b83030cb82fee7dd3f442efd9f80c4e5ab Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 24 Oct 2016 11:12:02 +0800 Subject: [PATCH 24/46] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E6=96=B0=E7=9A=84Ro?= =?UTF-8?q?uteNotFoundException=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/App.php | 3 ++- .../exception/RouteNotFoundException.php | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 library/think/exception/RouteNotFoundException.php diff --git a/library/think/App.php b/library/think/App.php index ce7fd37a..ddb147f3 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -16,6 +16,7 @@ use think\Env; use think\Exception; use think\exception\HttpException; use think\exception\HttpResponseException; +use think\exception\RouteNotFoundException; use think\Hook; use think\Lang; use think\Loader; @@ -547,7 +548,7 @@ class App $must = !is_null(self::$routeMust) ? self::$routeMust : $config['url_route_must']; if ($must && false === $result) { // 路由无效 - throw new HttpException(404, 'Route Not Found'); + throw new RouteNotFoundException(); } } if (false === $result) { diff --git a/library/think/exception/RouteNotFoundException.php b/library/think/exception/RouteNotFoundException.php new file mode 100644 index 00000000..6ee2f7b6 --- /dev/null +++ b/library/think/exception/RouteNotFoundException.php @@ -0,0 +1,24 @@ + +// +---------------------------------------------------------------------- + +namespace think\exception; + +use think\exception\HttpException; + +class RouteNotFoundException extends HttpException +{ + + public function __construct() + { + parent::__construct(404); + } + +} From 0674c774981517e48911eafc0f1102a8fe56a022 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 24 Oct 2016 14:15:09 +0800 Subject: [PATCH 25/46] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BB=E7=9A=84?= =?UTF-8?q?view=E5=92=8Cjoin=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index cf580b20..c78b17c1 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -671,7 +671,7 @@ class Query } else { $prefix = $this->prefix; $join = trim($join); - if ($prefix && false === strpos($join, '(') && false === strpos($join, '.') && 0 !== strpos($join, $prefix) && 0 !== strpos($join, '__')) { + if ($prefix && false === strpos($join, ' ') && false === strpos($join, '(') && false === strpos($join, '.') && 0 !== strpos($join, $prefix) && 0 !== strpos($join, '__')) { $table = $this->getTable($join); $table = [$table => $join]; $this->alias($table); @@ -774,9 +774,11 @@ class Query if (is_array($join)) { // 支持数据表别名 list($table, $alias) = each($join); - } elseif ($prefix && 0 !== strpos($join, $prefix) && 0 !== strpos($join, '__')) { + } elseif ($prefix && false === strpos($join, ' ') && 0 !== strpos($join, $prefix) && 0 !== strpos($join, '__')) { $table = $this->getTable($join); $alias = $join; + } elseif (strpos($join, ' ')) { + list($table, $alias) = explode(' ', $join); } else { $alias = $join; } From 6e5d83d513dbfd9044a3dc7ca4cc9e3cf3c11e0f Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 24 Oct 2016 18:13:35 +0800 Subject: [PATCH 26/46] =?UTF-8?q?=E8=B5=84=E6=BA=90=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B3=A8=E5=86=8C=E7=9A=84=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E8=A7=84=E5=88=99=20=E8=AE=B0=E5=BD=95=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=20=E8=B5=84=E6=BA=90=E6=A0=87?= =?UTF-8?q?=E8=AF=86=20=E4=BD=BF=E7=94=A8=20=E8=B7=AF=E7=94=B1=E5=8F=82?= =?UTF-8?q?=E6=95=B0=20=20rest=20=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/think/Route.php b/library/think/Route.php index 2db507ed..c353c721 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -578,7 +578,8 @@ class Route } elseif (strpos($val[1], ':id') && isset($option['var'][$rule])) { $val[1] = str_replace(':id', ':' . $option['var'][$rule], $val[1]); } - $item = ltrim($rule . $val[1], '/'); + $item = ltrim($rule . $val[1], '/'); + $option['rest'] = $key; self::rule($item . '$', $route . '/' . $val[2], $val[0], $option, $pattern); } } @@ -637,7 +638,7 @@ class Route * rest方法定义和修改 * @access public * @param string $name 方法名称 - * @param array $resourece 资源 + * @param array $resource 资源 * @return void */ public static function rest($name, $resource = []) From 2477345218b0d69ff1dd0bb6b913909c7feeb13f Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 25 Oct 2016 14:46:02 +0800 Subject: [PATCH 27/46] =?UTF-8?q?=E4=BC=98=E5=8C=96Connection=E7=B1=BB?= =?UTF-8?q?=E7=9A=84getRealSql=E6=96=B9=E6=B3=95=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=9A=84sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/App.php | 4 +--- library/think/db/Connection.php | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/library/think/App.php b/library/think/App.php index ddb147f3..40c726c8 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -390,9 +390,7 @@ class App Hook::listen('action_begin', $call); - $data = self::invokeMethod($call); - - return $data; + return self::invokeMethod($call); } /** diff --git a/library/think/db/Connection.php b/library/think/db/Connection.php index f39ca341..9806b827 100644 --- a/library/think/db/Connection.php +++ b/library/think/db/Connection.php @@ -433,7 +433,7 @@ abstract class Connection $sql . ' '); } } - return $sql; + return rtrim($sql); } /** From 535e17b1a03085ed73fdc1e57f555e1abee08fd1 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 25 Oct 2016 20:42:21 +0800 Subject: [PATCH 28/46] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=BD=AF=E5=88=A0?= =?UTF-8?q?=E9=99=A4withTrashed=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/traits/model/SoftDelete.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/traits/model/SoftDelete.php b/library/traits/model/SoftDelete.php index 4bb072dc..e110ff25 100644 --- a/library/traits/model/SoftDelete.php +++ b/library/traits/model/SoftDelete.php @@ -27,7 +27,7 @@ trait SoftDelete public static function withTrashed() { $model = new static(); - return $model->db(); + return $model->db(false); } /** @@ -39,7 +39,7 @@ trait SoftDelete { $model = new static(); $field = $model->getDeleteTimeField(); - return $model->db()->where($field, 'exp', 'is not null'); + return $model->db(false)->where($field, 'exp', 'is not null'); } /** From a3f80621b556995789870b03df3e7fd8d8017c2c Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 25 Oct 2016 22:54:40 +0800 Subject: [PATCH 29/46] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BB=E7=9A=84?= =?UTF-8?q?paginate=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index c78b17c1..796dd769 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -1002,6 +1002,9 @@ class Query if (!isset($total) && !$simple) { $options = $this->getOptions(); + if (isset($options['order'])) { + unset($this->options['order']); + } $bind = $this->bind; $total = $this->count(); $results = $this->options($options)->bind($bind)->page($page, $listRows)->select(); From d8c25a7970f74bb13e14223c5ae117d12d7094c1 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 25 Oct 2016 23:15:41 +0800 Subject: [PATCH 30/46] =?UTF-8?q?cache=E5=8A=A9=E6=89=8B=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=94=AF=E6=8C=81=20remember=E6=96=B9=E6=B3=95=20=EF=BC=8C?= =?UTF-8?q?=E7=94=A8=E6=B3=95=E4=B8=BA=EF=BC=9A=20cache('=3Fname',function?= =?UTF-8?q?(){=20=20=20=20return=20'value';=20});=20=E6=88=96=E8=80=85=20c?= =?UTF-8?q?ache('=3Fname','value);?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/helper.php b/helper.php index bcb52ea3..e0cc719e 100644 --- a/helper.php +++ b/helper.php @@ -365,6 +365,9 @@ if (!function_exists('cache')) { } elseif (is_null($value)) { // 删除缓存 return Cache::rm($name); + } elseif (0 === strpos($name, '?') && '' !== $value) { + $expire = is_numeric($options) ? $options : null; + return Cache::remember(substr($name, 1), $value, $expire); } else { // 缓存数据 if (is_array($options)) { From d96a037e490b4fb8221263dc30fb0f25071b1d4b Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 25 Oct 2016 23:56:17 +0800 Subject: [PATCH 31/46] =?UTF-8?q?=E8=A7=86=E5=9B=BE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E6=94=AF=E6=8C=81=E9=9B=86=E4=B8=AD=E5=BC=8F?= =?UTF-8?q?=E5=AD=98=E6=94=BE=20=E4=B8=8D=E6=94=BE=E5=85=A5=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/view/driver/Think.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/library/think/view/driver/Think.php b/library/think/view/driver/Think.php index 33729b44..db1d9816 100644 --- a/library/think/view/driver/Think.php +++ b/library/think/view/driver/Think.php @@ -24,6 +24,8 @@ class Think private $template; // 模板引擎参数 protected $config = [ + // 视图基础目录(集中式) + 'view_base' => '', // 模板起始路径 'view_path' => '', // 模板文件后缀 @@ -103,18 +105,21 @@ class Think */ private function parseTemplate($template) { + // 分析模板文件规则 + $request = Request::instance(); // 获取视图根目录 if (strpos($template, '@')) { // 跨模块调用 list($module, $template) = explode('@', $template); - $path = APP_PATH . $module . DS . 'view' . DS; + } + if ($this->config['view_base']) { + // 基础视图目录 + $module = isset($module) ? $module : $request->module(); + $path = $this->config['view_base'] . ($module ? $module . DS : ''); } else { - // 当前视图目录 - $path = $this->config['view_path']; + $path = isset($module) ? APP_PATH . $module . DS . 'view' . DS : $this->config['view_path']; } - // 分析模板文件规则 - $request = Request::instance(); $controller = Loader::parseName($request->controller()); if ($controller && 0 !== strpos($template, '/')) { $depr = $this->config['view_depr']; From 97fbbbc0e392933dc4c6564c8a7e58a4c6f2738d Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 26 Oct 2016 08:29:25 +0800 Subject: [PATCH 32/46] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Url=E7=B1=BB=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E9=83=A8=E7=BD=B2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Url.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/think/Url.php b/library/think/Url.php index 18b42c46..663c5de6 100644 --- a/library/think/Url.php +++ b/library/think/Url.php @@ -29,7 +29,7 @@ class Url * @param boolean|string $domain 是否显示域名 或者直接传入域名 * @return string */ - public static function build($url = '', $vars = '', $suffix = true, $domain = false) + public static function build($url = '', $vars = '', $suffix = true, $domain = null) { if (false === $domain && Config::get('url_domain_deploy')) { $domain = true; @@ -172,13 +172,14 @@ class Url } else { // 解析到 模块/控制器/操作 $module = $request->module(); - if (true === $domain) { + if (true === $domain && 2 == substr_count($url, '/')) { $domains = Route::rules('domain'); foreach ($domains as $key => $item) { if (isset($item['[bind]']) && 0 === strpos($url, $item['[bind]'][0])) { $url = substr($url, strlen($item['[bind]'][0]) + 1); $domain = $key; $module = ''; + break; } } } elseif ($domain) { From 31aae17f55b4f69580696a881f6e783e44e4c636 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 26 Oct 2016 08:45:25 +0800 Subject: [PATCH 33/46] =?UTF-8?q?=E6=94=B9=E8=BF=9BApp=E7=B1=BB=E7=9A=84?= =?UTF-8?q?=E7=A9=BA=E6=93=8D=E4=BD=9C=E6=96=B9=E6=B3=95=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/App.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/think/App.php b/library/think/App.php index 40c726c8..7feff2fe 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -377,12 +377,14 @@ class App // 获取当前操作名 $action = $actionName . $config['action_suffix']; + $vars = []; if (is_callable([$instance, $action])) { // 执行操作方法 $call = [$instance, $action]; } elseif (is_callable([$instance, '_empty'])) { // 空操作 $call = [$instance, '_empty']; + $vars = [$action]; } else { // 操作不存在 throw new HttpException(404, 'method not exists:' . get_class($instance) . '->' . $action . '()'); @@ -390,7 +392,7 @@ class App Hook::listen('action_begin', $call); - return self::invokeMethod($call); + return self::invokeMethod($call, $vars); } /** From 39cbbc0a38ce3fc7d5319f1fa9e571ca84f20ef4 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 26 Oct 2016 11:09:49 +0800 Subject: [PATCH 34/46] =?UTF-8?q?=E6=94=B9=E8=BF=9BUrl=E7=B1=BB=20?= =?UTF-8?q?=E5=9F=9F=E5=90=8D=E9=83=A8=E7=BD=B2url=E7=94=9F=E6=88=90=20URL?= =?UTF-8?q?=E7=94=9F=E6=88=90=E4=B8=8D=E4=BE=9D=E8=B5=96=20url=5Fdomain=5F?= =?UTF-8?q?deploy=20=E9=85=8D=E7=BD=AE=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper.php | 2 +- library/think/Url.php | 67 ++++++++++++++++++++++++++----------------- 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/helper.php b/helper.php index e0cc719e..007c76cd 100644 --- a/helper.php +++ b/helper.php @@ -277,7 +277,7 @@ if (!function_exists('url')) { * @param bool|string $domain 域名 * @return string */ - function url($url = '', $vars = '', $suffix = true, $domain = false) + function url($url = '', $vars = '', $suffix = true, $domain = true) { return Url::build($url, $vars, $suffix, $domain); } diff --git a/library/think/Url.php b/library/think/Url.php index 663c5de6..87a79ed0 100644 --- a/library/think/Url.php +++ b/library/think/Url.php @@ -20,6 +20,7 @@ class Url { // 生成URL地址的root protected static $root; + protected static $bindCheck; /** * URL生成 支持路由反射 @@ -29,11 +30,8 @@ class Url * @param boolean|string $domain 是否显示域名 或者直接传入域名 * @return string */ - public static function build($url = '', $vars = '', $suffix = true, $domain = null) + public static function build($url = '', $vars = '', $suffix = true, $domain = true) { - if (false === $domain && Config::get('url_domain_deploy')) { - $domain = true; - } // 解析URL if (0 === strpos($url, '[') && $pos = strpos($url, ']')) { // [name] 表示使用路由命名标识生成URL @@ -112,11 +110,13 @@ class Url } // 检测URL绑定 - $type = Route::getBind('type'); - if ($type) { - $bind = Route::getBind($type); - if (0 === strpos($url, $bind)) { - $url = substr($url, strlen($bind) + 1); + if (!self::$bindCheck) { + $type = Route::getBind('type'); + if ($type) { + $bind = Route::getBind($type); + if (0 === strpos($url, $bind)) { + $url = substr($url, strlen($bind) + 1); + } } } // 还原URL分隔符 @@ -173,15 +173,28 @@ class Url // 解析到 模块/控制器/操作 $module = $request->module(); if (true === $domain && 2 == substr_count($url, '/')) { + $current = $request->host(); $domains = Route::rules('domain'); + $match = []; + $pos = []; foreach ($domains as $key => $item) { if (isset($item['[bind]']) && 0 === strpos($url, $item['[bind]'][0])) { - $url = substr($url, strlen($item['[bind]'][0]) + 1); - $domain = $key; - $module = ''; - break; + $pos[$key] = strlen($item['[bind]'][0]) + 1; + $match[] = $key; + $module = ''; } } + if ($match) { + $domain = current($match); + foreach ($match as $item) { + if (0 === strpos($current, $item)) { + $domain = $item; + } + } + self::$bindCheck = true; + $url = substr($url, $pos[$domain]); + } + } elseif ($domain) { if (isset($domains[$domain]['[bind]'][0])) { $bindModule = $domains[$domain]['[bind]'][0]; @@ -213,15 +226,15 @@ class Url if (!$domain) { return ''; } - $request = Request::instance(); + $request = Request::instance(); + $rootDomain = Config::get('url_domain_root'); if (true === $domain) { // 自动判断域名 $domain = $request->host(); - if (Config::get('url_domain_deploy')) { - // 根域名 - $urlDomainRoot = Config::get('url_domain_root'); - $domains = Route::rules('domain'); - $route_domain = array_keys($domains); + + $domains = Route::rules('domain'); + if ($domains) { + $route_domain = array_keys($domains); foreach ($route_domain as $domain_prefix) { if (0 === strpos($domain_prefix, '*.') && strpos($domain, ltrim($domain_prefix, '*.')) !== false) { foreach ($domains as $key => $rule) { @@ -230,13 +243,13 @@ class Url $url = ltrim($url, $rule); $domain = $key; // 生成对应子域名 - if (!empty($urlDomainRoot)) { - $domain .= $urlDomainRoot; + if (!empty($rootDomain)) { + $domain .= $rootDomain; } break; } else if (false !== strpos($key, '*')) { - if (!empty($urlDomainRoot)) { - $domain .= $urlDomainRoot; + if (!empty($rootDomain)) { + $domain .= $rootDomain; } break; } @@ -244,13 +257,15 @@ class Url } } } - } elseif (!strpos($domain, '.')) { - $rootDomain = Config::get('url_domain_root'); + + } else { if (empty($rootDomain)) { $host = $request->host(); $rootDomain = substr_count($host, '.') > 1 ? substr(strstr($host, '.'), 1) : $host; } - $domain .= '.' . $rootDomain; + if (!strpos($domain, $rootDomain)) { + $domain .= '.' . $rootDomain; + } } return ($request->isSsl() ? 'https://' : 'http://') . $domain; } From 087e968b806846a985e66ccc57624ea8328f5a51 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 26 Oct 2016 11:34:36 +0800 Subject: [PATCH 35/46] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BBwhere?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 796dd769..0c9d8ef7 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -906,13 +906,9 @@ class Query if (is_array($field)) { // 数组批量查询 $where = $field; - } elseif ($field) { + } elseif ($field && is_string($field)) { // 字符串查询 - if (is_numeric($field)) { - $where[] = ['exp', $field]; - } else { - $where[$field] = ['null', '']; - } + $where[$field] = ['null', '']; } } elseif (is_array($op)) { $where[$field] = $param; From 82b94b555f36805faf7dffcfb2d00ca1945cff9a Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 26 Oct 2016 12:10:35 +0800 Subject: [PATCH 36/46] =?UTF-8?q?=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper.php | 2 +- library/think/Url.php | 6 ++++-- tests/thinkphp/library/think/urlTest.php | 14 +++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/helper.php b/helper.php index 007c76cd..e0cc719e 100644 --- a/helper.php +++ b/helper.php @@ -277,7 +277,7 @@ if (!function_exists('url')) { * @param bool|string $domain 域名 * @return string */ - function url($url = '', $vars = '', $suffix = true, $domain = true) + function url($url = '', $vars = '', $suffix = true, $domain = false) { return Url::build($url, $vars, $suffix, $domain); } diff --git a/library/think/Url.php b/library/think/Url.php index 87a79ed0..b4ae0aac 100644 --- a/library/think/Url.php +++ b/library/think/Url.php @@ -30,8 +30,11 @@ class Url * @param boolean|string $domain 是否显示域名 或者直接传入域名 * @return string */ - public static function build($url = '', $vars = '', $suffix = true, $domain = true) + public static function build($url = '', $vars = '', $suffix = true, $domain = false) { + if (false === $domain && Route::rules('domain')) { + $domain = true; + } // 解析URL if (0 === strpos($url, '[') && $pos = strpos($url, ']')) { // [name] 表示使用路由命名标识生成URL @@ -194,7 +197,6 @@ class Url self::$bindCheck = true; $url = substr($url, $pos[$domain]); } - } elseif ($domain) { if (isset($domains[$domain]['[bind]'][0])) { $bindModule = $domains[$domain]['[bind]'][0]; diff --git a/tests/thinkphp/library/think/urlTest.php b/tests/thinkphp/library/think/urlTest.php index ced519d7..acb43365 100644 --- a/tests/thinkphp/library/think/urlTest.php +++ b/tests/thinkphp/library/think/urlTest.php @@ -25,13 +25,13 @@ class urlTest extends \PHPUnit_Framework_TestCase public function setUp() { - Route::rules(['GET' => [], - 'POST' => [], - 'PUT' => [], - 'DELETE' => [], - 'PATCH' => [], - 'HEAD' => [], - 'OPTIONS' => [], + Route::rules(['get' => [], + 'post' => [], + 'put' => [], + 'delete' => [], + 'patch' => [], + 'head' => [], + 'options' => [], '*' => [], 'alias' => [], 'domain' => [], From 9062808a0540158cd5651087abffbf7f04339d42 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 26 Oct 2016 17:44:15 +0800 Subject: [PATCH 37/46] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=88=86=E7=BB=84?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E7=9A=84url=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/think/Route.php b/library/think/Route.php index c353c721..1d4e0e7b 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -307,7 +307,8 @@ class Route } $vars = self::parseVar($rule); if (isset($name)) { - $key = $group ? $group . '/' . $rule : $rule; + $rule = ltrim($rule, '/'); + $key = $group ? $group . ($rule ? '/' . $rule : '') : $rule; self::name(strtolower($name), [$key, $vars, self::$domain]); } if ($group) { @@ -428,7 +429,8 @@ class Route $vars = self::parseVar($key); $item[] = ['rule' => $key, 'route' => $route, 'var' => $vars, 'option' => $options, 'pattern' => $patterns]; // 设置路由标识 - self::name($route, [$name . '/' . $key, $vars, self::$domain]); + $key = ltrim($key, '/'); + self::name($route, [$name . ($key ? '/' . $key : ''), $vars, self::$domain]); } self::$rules['*'][$name] = ['rule' => $item, 'route' => '', 'var' => [], 'option' => $option, 'pattern' => $pattern]; } From c977af79210ce566ba43cca09d7396a929a9e63e Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 26 Oct 2016 18:11:38 +0800 Subject: [PATCH 38/46] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E5=88=86=E7=BB=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/library/think/Route.php b/library/think/Route.php index 1d4e0e7b..83442cba 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -302,13 +302,12 @@ class Route $rule = substr($rule, 0, -1); } - if ('/' != $rule) { + if ('/' != $rule || $group) { $rule = trim($rule, '/'); } $vars = self::parseVar($rule); if (isset($name)) { - $rule = ltrim($rule, '/'); - $key = $group ? $group . ($rule ? '/' . $rule : '') : $rule; + $key = $group ? $group . ($rule ? '/' . $rule : '') : $rule; self::name(strtolower($name), [$key, $vars, self::$domain]); } if ($group) { @@ -426,10 +425,10 @@ class Route $options['complete_match'] = true; $key = substr($key, 0, -1); } + $key = trim($key, '/'); $vars = self::parseVar($key); $item[] = ['rule' => $key, 'route' => $route, 'var' => $vars, 'option' => $options, 'pattern' => $patterns]; // 设置路由标识 - $key = ltrim($key, '/'); self::name($route, [$name . ($key ? '/' . $key : ''), $vars, self::$domain]); } self::$rules['*'][$name] = ['rule' => $item, 'route' => '', 'var' => [], 'option' => $option, 'pattern' => $pattern]; From 4ca0e81d31a4cad93aab2898c835a82cda6f80a9 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 26 Oct 2016 20:05:04 +0800 Subject: [PATCH 39/46] =?UTF-8?q?File=E7=B1=BB=20=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E6=80=A7=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/File.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/think/File.php b/library/think/File.php index 43f38575..60a16417 100644 --- a/library/think/File.php +++ b/library/think/File.php @@ -39,7 +39,7 @@ class File extends SplFileObject public function __construct($filename, $mode = 'r') { parent::__construct($filename, $mode); - $this->filename = $this->getRealPath(); + $this->filename = $this->getRealPath() ?: $this->getPathname(); } /** From 741ef90a3d6a769a283c173c150dac16508d5877 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 27 Oct 2016 10:38:43 +0800 Subject: [PATCH 40/46] =?UTF-8?q?=E6=94=B9=E8=BF=9BUrl=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Url.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/think/Url.php b/library/think/Url.php index b4ae0aac..cc68e720 100644 --- a/library/think/Url.php +++ b/library/think/Url.php @@ -174,10 +174,10 @@ class Url $url = substr($url, 1); } else { // 解析到 模块/控制器/操作 - $module = $request->module(); + $module = $request->module(); + $domains = Route::rules('domain'); if (true === $domain && 2 == substr_count($url, '/')) { $current = $request->host(); - $domains = Route::rules('domain'); $match = []; $pos = []; foreach ($domains as $key => $item) { From b2e2d440ed306f24f355d8237b96131e7fcd987c Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 27 Oct 2016 10:42:50 +0800 Subject: [PATCH 41/46] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Url=E5=A4=9A=E6=AC=A1?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Url.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/think/Url.php b/library/think/Url.php index cc68e720..642e48f1 100644 --- a/library/think/Url.php +++ b/library/think/Url.php @@ -155,7 +155,8 @@ class Url // 检测域名 $domain = self::parseDomain($url, $domain); // URL组装 - $url = $domain . (self::$root ?: Request::instance()->root()) . '/' . ltrim($url, '/'); + $url = $domain . (self::$root ?: Request::instance()->root()) . '/' . ltrim($url, '/'); + self::$bindCheck = false; return $url; } From 40dd37e37417029166c3be71b2838d8a9171deb1 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 27 Oct 2016 14:10:25 +0800 Subject: [PATCH 42/46] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=B8=BA5.0.3beta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base.php b/base.php index b668120e..4d0b703c 100644 --- a/base.php +++ b/base.php @@ -9,7 +9,7 @@ // | Author: liu21st // +---------------------------------------------------------------------- -define('THINK_VERSION', '5.0.2'); +define('THINK_VERSION', '5.0.3beta'); define('THINK_START_TIME', microtime(true)); define('THINK_START_MEM', memory_get_usage()); define('EXT', '.php'); From eed8bfb12dc9ab1163c2708faa972d64807a83ad Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 27 Oct 2016 14:18:44 +0800 Subject: [PATCH 43/46] =?UTF-8?q?=E6=94=B9=E8=BF=9BConfig=E7=B1=BBload?= =?UTF-8?q?=E6=96=B9=E6=B3=95=20=E4=B8=80=E7=BA=A7=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=BC=BA=E5=88=B6=E8=BD=AC=E4=B8=BA=E5=B0=8F?= =?UTF-8?q?=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/library/think/Config.php b/library/think/Config.php index d7c3dc56..fb5340d8 100644 --- a/library/think/Config.php +++ b/library/think/Config.php @@ -59,6 +59,7 @@ class Config self::$config[$range] = []; } if (is_file($file)) { + $name = strtolower($name); $type = pathinfo($file, PATHINFO_EXTENSION); if ('php' == $type) { return self::set(include $file, $name, $range); From 756992ef2ee6faa740debb985069186c3c52bce0 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 27 Oct 2016 14:39:26 +0800 Subject: [PATCH 44/46] =?UTF-8?q?cache=E5=8A=A9=E6=89=8B=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=B8=85=E7=A9=BA=E6=93=8D=E4=BD=9C=20cache(?= =?UTF-8?q?null)=20=E6=88=96=E8=80=85=20cache(null,'tagName');?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helper.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/helper.php b/helper.php index e0cc719e..ba9f46ad 100644 --- a/helper.php +++ b/helper.php @@ -359,7 +359,9 @@ if (!function_exists('cache')) { // 缓存初始化 return Cache::connect($name); } - if ('' === $value) { + if (is_null($name)) { + return Cache::clear($value); + } elseif ('' === $value) { // 获取缓存 return 0 === strpos($name, '?') ? Cache::has(substr($name, 1)) : Cache::get($name); } elseif (is_null($value)) { From 796921a4b06b921e3564cbfc422f10437f361d1c Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 28 Oct 2016 10:46:44 +0800 Subject: [PATCH 45/46] =?UTF-8?q?Route=E7=B1=BB=E5=A2=9E=E5=8A=A0setOption?= =?UTF-8?q?=E5=92=8CgetOption=E6=96=B9=E6=B3=95=20=E7=94=A8=E4=BA=8E?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=BD=93=E5=89=8D=E8=B7=AF=E7=94=B1=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E8=BF=87=E7=A8=8B=E4=B8=AD=E7=9A=84=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/library/think/Route.php b/library/think/Route.php index 83442cba..b22f91ef 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -69,6 +69,8 @@ class Route private static $domainRule; // 当前域名 private static $domain; + // 当前路由执行过程中的参数 + private static $option = []; /** * 注册变量规则 @@ -341,6 +343,27 @@ class Route } } + /** + * 设置当前执行的参数信息 + * @access public + * @param array $options 参数信息 + * @return mixed + */ + protected static function setOption($options = []) + { + self::$option[] = $options; + } + + /** + * 获取当前执行的所有参数信息 + * @access public + * @return array + */ + public static function getOption() + { + return self::$option; + } + /** * 获取当前的分组信息 * @access public @@ -898,7 +921,7 @@ class Route if (is_string($str) && $str && 0 !== strpos(str_replace('|', '/', $url), $str)) { continue; } - + self::setOption($option); $result = self::checkRoute($request, $rule, $url, $depr, $key, $option); if (false !== $result) { return $result; @@ -913,6 +936,8 @@ class Route if ($group) { $rule = $group . ($rule ? '/' . ltrim($rule, '/') : ''); } + + self::setOption($option); if (isset($options['bind_model']) && isset($option['bind_model'])) { $option['bind_model'] = array_merge($options['bind_model'], $option['bind_model']); } From e2de014dd1a2bbc581619900d091e2c4230ac65a Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 28 Oct 2016 11:19:44 +0800 Subject: [PATCH 46/46] =?UTF-8?q?=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Route.php | 1 + 1 file changed, 1 insertion(+) diff --git a/library/think/Route.php b/library/think/Route.php index b22f91ef..395b07cc 100644 --- a/library/think/Route.php +++ b/library/think/Route.php @@ -858,6 +858,7 @@ class Route $rule = self::getRouteExpress($item); } if (!empty($rule['route']) && self::checkOption($rule['option'], $request)) { + self::setOption($rule['option']); return self::parseRule($item, $rule['route'], $url, $rule['option']); } }