更新tp5内核

This commit is contained in:
2018-01-02 23:03:31 +08:00
parent 590696a06b
commit 3818619504
99 changed files with 3362 additions and 2006 deletions
+15 -9
View File
@@ -2,7 +2,7 @@
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
@@ -255,9 +255,11 @@ class Route
$option1 = array_merge($option, $val[1]);
$pattern1 = array_merge($pattern, isset($val[2]) ? $val[2] : []);
} else {
$route = $val;
$option1 = null;
$pattern1 = null;
$route = $val;
}
self::setRule($key, $route, $type, isset($option1) ? $option1 : $option, isset($pattern1) ? $pattern1 : $pattern, $group);
self::setRule($key, $route, $type, !is_null($option1) ? $option1 : $option, !is_null($pattern1) ? $pattern1 : $pattern, $group);
}
} else {
self::setRule($rule, $route, $type, $option, $pattern, $group);
@@ -333,9 +335,9 @@ class Route
if ('*' == $type) {
// 注册路由快捷方式
foreach (['get', 'post', 'put', 'delete', 'patch', 'head', 'options'] as $method) {
if (self::$domain) {
if (self::$domain && !isset(self::$rules['domain'][self::$domain][$method][$rule])) {
self::$rules['domain'][self::$domain][$method][$rule] = true;
} else {
} elseif (!self::$domain && !isset(self::$rules[$method][$rule])) {
self::$rules[$method][$rule] = true;
}
}
@@ -428,7 +430,8 @@ class Route
self::$rules['*'][$name]['pattern'] = $pattern;
}
} else {
$item = [];
$item = [];
$completeMatch = Config::get('route_complete_match');
foreach ($routes as $key => $val) {
if (is_numeric($key)) {
$key = array_shift($val);
@@ -447,6 +450,8 @@ class Route
// 是否完整匹配
$options['complete_match'] = true;
$key = substr($key, 0, -1);
} elseif ($completeMatch) {
$options['complete_match'] = true;
}
$key = trim($key, '/');
$vars = self::parseVar($key);
@@ -1507,12 +1512,13 @@ class Route
if ($request->isGet() && isset($option['cache'])) {
$cache = $option['cache'];
if (is_array($cache)) {
list($key, $expire) = $cache;
list($key, $expire, $tag) = array_pad($cache, 3, null);
} else {
$key = str_replace('|', '/', $pathinfo);
$expire = $cache;
$tag = null;
}
$request->cache($key, $expire);
$request->cache($key, $expire, $tag);
}
return $result;
}
@@ -1543,7 +1549,7 @@ class Route
/**
* 解析URL地址中的参数Request对象
* @access private
* @param string $rule 路由规则
* @param string $url 路由规则
* @param array $var 变量
* @return void
*/