1、安装文件更新
2、内核更新
This commit is contained in:
@@ -280,7 +280,10 @@ class App
|
||||
if ($bind) {
|
||||
// 绑定模块
|
||||
list($bindModule) = explode('/', $bind);
|
||||
if ($module == $bindModule) {
|
||||
if (empty($result[0])) {
|
||||
$module = $bindModule;
|
||||
$available = true;
|
||||
} elseif ($module == $bindModule) {
|
||||
$available = true;
|
||||
}
|
||||
} elseif (!in_array($module, $config['deny_module_list']) && is_dir(APP_PATH . $module)) {
|
||||
@@ -363,7 +366,7 @@ class App
|
||||
self::$debug = Config::get('app_debug');
|
||||
if (!self::$debug) {
|
||||
ini_set('display_errors', 'Off');
|
||||
} else {
|
||||
} elseif (!IS_CLI) {
|
||||
//重新申请一块比较大的buffer
|
||||
if (ob_get_level() > 0) {
|
||||
$output = ob_get_clean();
|
||||
|
||||
@@ -115,14 +115,13 @@ class Cache
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function inc($name, $step = 1, $expire = null)
|
||||
public static function inc($name, $step = 1)
|
||||
{
|
||||
self::init();
|
||||
self::$writeTimes++;
|
||||
return self::$handler->inc($name, $step, $expire);
|
||||
return self::$handler->inc($name, $step);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,14 +129,13 @@ class Cache
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function dec($name, $step = 1, $expire = null)
|
||||
public static function dec($name, $step = 1)
|
||||
{
|
||||
self::init();
|
||||
self::$writeTimes++;
|
||||
return self::$handler->dec($name, $step, $expire);
|
||||
return self::$handler->dec($name, $step);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,7 @@ class Config
|
||||
* @param string $type 配置解析类型
|
||||
* @param string $name 配置名(如设置即表示二级配置)
|
||||
* @param string $range 作用域
|
||||
* @return mixed
|
||||
*/
|
||||
public static function parse($config, $type = '', $name = '', $range = '')
|
||||
{
|
||||
@@ -41,7 +42,7 @@ class Config
|
||||
$type = pathinfo($config, PATHINFO_EXTENSION);
|
||||
}
|
||||
$class = false !== strpos($type, '\\') ? $type : '\\think\\config\\driver\\' . ucwords($type);
|
||||
self::set((new $class())->parse($config), $name, $range);
|
||||
return self::set((new $class())->parse($config), $name, $range);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +123,7 @@ class Config
|
||||
} else {
|
||||
// 二维数组设置和获取支持
|
||||
$name = explode('.', $name);
|
||||
$result = getenv(ENV_PREFIX . strtoupper($name[0] . '_' . $name[1]));
|
||||
$result = getenv(ENV_PREFIX . strtoupper($name[0] . '_' . $name[1]));
|
||||
// 判断环境变量
|
||||
if (false !== $result) {
|
||||
return $result;
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace think;
|
||||
use think\App;
|
||||
use think\Collection;
|
||||
use think\db\Query;
|
||||
use think\paginator\Collection as PaginatorCollection;
|
||||
|
||||
/**
|
||||
* Class Db
|
||||
|
||||
@@ -236,7 +236,7 @@ class Request
|
||||
$options['server'] = $server;
|
||||
$options['url'] = $server['REQUEST_URI'];
|
||||
$options['baseUrl'] = $info['path'];
|
||||
$options['pathinfo'] = ltrim($info['path'], '/');
|
||||
$options['pathinfo'] = '/' == $info['path'] ? '/' : ltrim($info['path'], '/');
|
||||
$options['method'] = $server['REQUEST_METHOD'];
|
||||
$options['domain'] = $server['HTTP_HOST'];
|
||||
$options['content'] = $content;
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace think;
|
||||
|
||||
use think\App;
|
||||
use think\Config;
|
||||
use think\exception\HttpException;
|
||||
use think\Hook;
|
||||
use think\Log;
|
||||
use think\Request;
|
||||
@@ -63,6 +64,8 @@ class Route
|
||||
private static $group = [];
|
||||
// 路由命名标识(用于快速URL生成)
|
||||
private static $name = [];
|
||||
// 当前子域名绑定
|
||||
private static $domain;
|
||||
|
||||
/**
|
||||
* 注册变量规则
|
||||
@@ -85,14 +88,18 @@ class Route
|
||||
* @access public
|
||||
* @param string|array $domain 子域名
|
||||
* @param mixed $rule 路由规则
|
||||
* @param array $option 路由参数
|
||||
* @param array $pattern 变量规则
|
||||
* @return void
|
||||
*/
|
||||
public static function domain($domain = null, $rule = '')
|
||||
public static function domain($domain, $rule = '', $option = [], $pattern = [])
|
||||
{
|
||||
if (is_array($domain)) {
|
||||
self::$rules['domain'] = array_merge(self::$rules['domain'], $domain);
|
||||
foreach ($domain as $key => $item) {
|
||||
self::$rules['domain'][$key] = [$item, $option, $pattern];
|
||||
}
|
||||
} else {
|
||||
self::$rules['domain'][$domain] = $rule;
|
||||
self::$rules['domain'][$domain] = [$rule, $option, $pattern];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +107,7 @@ class Route
|
||||
* 设置路由绑定
|
||||
* @access public
|
||||
* @param mixed $bind 绑定信息
|
||||
* @param string $type 绑定类型 默认为module
|
||||
* @param string $type 绑定类型 默认为module 支持 namespace class
|
||||
* @return mixed
|
||||
*/
|
||||
public static function bind($bind, $type = 'module')
|
||||
@@ -167,8 +174,13 @@ class Route
|
||||
unset($rule['__rest__']);
|
||||
}
|
||||
|
||||
$type = strtoupper($type);
|
||||
foreach ($rule as $key => $val) {
|
||||
self::registerRules($rule, strtoupper($type));
|
||||
}
|
||||
|
||||
// 批量注册路由
|
||||
protected static function registerRules($rules, $type = '*')
|
||||
{
|
||||
foreach ($rules as $key => $val) {
|
||||
if (is_numeric($key)) {
|
||||
$key = array_shift($val);
|
||||
}
|
||||
@@ -358,7 +370,7 @@ class Route
|
||||
foreach (['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'] as $method) {
|
||||
if (!isset(self::$rules[$method][$name])) {
|
||||
self::$rules[$method][$name] = true;
|
||||
} else {
|
||||
} elseif (is_array(self::$rules[$method][$name])) {
|
||||
self::$rules[$method][$name] = array_merge(self::$rules['*'][$name], self::$rules[$method][$name]);
|
||||
}
|
||||
}
|
||||
@@ -587,6 +599,17 @@ class Route
|
||||
self::rule('__miss__', $route, $method, $option, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册一个自动解析的URL路由
|
||||
* @access public
|
||||
* @param string $route 路由地址
|
||||
* @return void
|
||||
*/
|
||||
public static function auto($route)
|
||||
{
|
||||
self::rule('__auto__', $route, '*', [], []);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取或者批量设置路由定义
|
||||
* @access public
|
||||
@@ -610,9 +633,10 @@ class Route
|
||||
* 检测子域名部署
|
||||
* @access public
|
||||
* @param Request $request Request请求对象
|
||||
* @param string $method 请求类型
|
||||
* @return void
|
||||
*/
|
||||
public static function checkDomain($request)
|
||||
public static function checkDomain($request, $method = 'GET')
|
||||
{
|
||||
// 域名规则
|
||||
$rules = self::$rules['domain'];
|
||||
@@ -621,7 +645,7 @@ class Route
|
||||
$host = $request->host();
|
||||
if (isset($rules[$host])) {
|
||||
// 完整域名或者IP配置
|
||||
$rule = $rules[$host];
|
||||
$item = $rules[$host];
|
||||
} else {
|
||||
$rootDomain = Config::get('url_domain_root');
|
||||
if ($rootDomain) {
|
||||
@@ -642,27 +666,42 @@ class Route
|
||||
}
|
||||
if ($subDomain && isset($rules[$subDomain])) {
|
||||
// 子域名配置
|
||||
$rule = $rules[$subDomain];
|
||||
$item = $rules[$subDomain];
|
||||
} elseif (isset($rules['*.' . $domain2]) && !empty($domain3)) {
|
||||
// 泛三级域名
|
||||
$rule = $rules['*.' . $domain2];
|
||||
$item = $rules['*.' . $domain2];
|
||||
$panDomain = $domain3;
|
||||
} elseif (isset($rules['*']) && !empty($domain2)) {
|
||||
// 泛二级域名
|
||||
if ('www' != $domain2) {
|
||||
$rule = $rules['*'];
|
||||
$item = $rules['*'];
|
||||
$panDomain = $domain2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($rule)) {
|
||||
// 子域名部署规则
|
||||
if (!empty($item)) {
|
||||
self::$domain = true;
|
||||
// 解析子域名部署规则
|
||||
list($rule, $option, $pattern) = $item;
|
||||
if (!empty($option['https']) && !$request->isSsl()) {
|
||||
// https检测
|
||||
throw new HttpException(404, 'must use https request:' . $host);
|
||||
}
|
||||
if ($rule instanceof \Closure) {
|
||||
// 执行闭包
|
||||
$reflect = new \ReflectionFunction($rule);
|
||||
self::$bind = $reflect->invokeArgs([]);
|
||||
return;
|
||||
} elseif (is_array($rule)) {
|
||||
// 清空当前路由规则
|
||||
self::$rules[$method] = [];
|
||||
self::$rules['*'] = [];
|
||||
self::group('', function () use ($rule) {
|
||||
// 动态注册域名的路由规则
|
||||
self::registerRules($rule);
|
||||
}, $option, $pattern);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strpos($rule, '?')) {
|
||||
@@ -684,16 +723,13 @@ class Route
|
||||
|
||||
if (0 === strpos($result, '\\')) {
|
||||
// 绑定到命名空间 例如 \app\index\behavior
|
||||
self::$bind = ['type' => 'namespace', 'namespace' => $result, 'domain' => true];
|
||||
self::$bind = ['type' => 'namespace', 'namespace' => $result];
|
||||
} elseif (0 === strpos($result, '@')) {
|
||||
// 绑定到类 例如 @app\index\controller\User
|
||||
self::$bind = ['type' => 'class', 'class' => substr($result, 1), 'domain' => true];
|
||||
} elseif (0 === strpos($result, '[')) {
|
||||
// 绑定到分组 例如 [user]
|
||||
self::$bind = ['type' => 'group', 'group' => substr($result, 1, -1), 'domain' => true];
|
||||
self::$bind = ['type' => 'class', 'class' => substr($result, 1)];
|
||||
} else {
|
||||
// 绑定到模块/控制器 例如 index/user
|
||||
self::$bind = ['type' => 'module', 'module' => $result, 'domain' => true];
|
||||
self::$bind = ['type' => 'module', 'module' => $result];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -722,13 +758,13 @@ class Route
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
$method = $request->method();
|
||||
// 检测域名部署
|
||||
if ($checkDomain) {
|
||||
self::checkDomain($request);
|
||||
self::checkDomain($request, $method);
|
||||
}
|
||||
// 获取当前请求类型的路由规则
|
||||
$rules = self::$rules[$request->method()];
|
||||
$rules = self::$rules[$method];
|
||||
|
||||
// 检测URL绑定
|
||||
$return = self::checkUrlBind($url, $rules, $depr);
|
||||
@@ -751,7 +787,7 @@ class Route
|
||||
|
||||
// 路由规则检测
|
||||
if (!empty($rules)) {
|
||||
return self::checkRoute($request, $rules, $url);
|
||||
return self::checkRoute($request, $rules, $url, $depr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -762,10 +798,11 @@ class Route
|
||||
* @param Request $request
|
||||
* @param array $rules 路由规则
|
||||
* @param string $url URL地址
|
||||
* @param string $depr URL分割符
|
||||
* @param string $group 路由分组名
|
||||
* @return mixed
|
||||
*/
|
||||
private static function checkRoute($request, $rules, $url, $group = '')
|
||||
private static function checkRoute($request, $rules, $url, $depr = '/', $group = '')
|
||||
{
|
||||
foreach ($rules as $key => $item) {
|
||||
if (true === $item) {
|
||||
@@ -796,14 +833,15 @@ class Route
|
||||
continue;
|
||||
}
|
||||
|
||||
$result = self::checkRoute($request, $rule, $url, $key);
|
||||
$result = self::checkRoute($request, $rule, $url, $depr, $key);
|
||||
if (false !== $result) {
|
||||
return $result;
|
||||
}
|
||||
} elseif ($route) {
|
||||
if ('__miss__' == $rule) {
|
||||
// 指定MISS路由
|
||||
$miss = $item;
|
||||
if ('__miss__' == $rule || '__auto__' == $rule) {
|
||||
// 指定特殊路由
|
||||
$var = trim($rule, '__');
|
||||
${$var} = $item;
|
||||
continue;
|
||||
}
|
||||
if ($group) {
|
||||
@@ -815,7 +853,10 @@ class Route
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($miss)) {
|
||||
if (isset($auto)) {
|
||||
// 自动解析URL地址
|
||||
return self::parseUrl($auto['route'] . '/' . $url, $depr);
|
||||
} elseif (isset($miss)) {
|
||||
// 未匹配所有路由的路由规则处理
|
||||
return self::parseRule('', $miss['route'], $url, $miss['option']);
|
||||
}
|
||||
@@ -866,32 +907,23 @@ class Route
|
||||
*/
|
||||
private static function checkUrlBind(&$url, &$rules, $depr = '/')
|
||||
{
|
||||
if (!empty(self::$bind['type'])) {
|
||||
if (!empty(self::$bind)) {
|
||||
$type = self::$bind['type'];
|
||||
$bind = self::$bind[$type];
|
||||
// 记录绑定信息
|
||||
App::$debug && Log::record('[ BIND ] ' . var_export(self::$bind, true), 'info');
|
||||
App::$debug && Log::record('[ BIND ] ' . var_export($bind, true), 'info');
|
||||
// 如果有URL绑定 则进行绑定检测
|
||||
switch (self::$bind['type']) {
|
||||
switch ($type) {
|
||||
case 'class':
|
||||
// 绑定到类
|
||||
return self::bindToClass($url, self::$bind['class'], $depr);
|
||||
return self::bindToClass($url, $bind, $depr);
|
||||
case 'namespace':
|
||||
// 绑定到命名空间
|
||||
return self::bindToNamespace($url, self::$bind['namespace'], $depr);
|
||||
return self::bindToNamespace($url, $bind, $depr);
|
||||
case 'module':
|
||||
// 如果有模块/控制器绑定 针对路由到 模块/控制器 有效
|
||||
$url = (empty(self::$bind['domain']) ? self::$bind['module'] . '/' : '') . ltrim($url, '/');
|
||||
$url = (empty(self::$domain) ? $bind . '/' : '') . ltrim($url, '/');
|
||||
break;
|
||||
case 'group':
|
||||
// 绑定到路由分组
|
||||
$key = self::$bind['group'];
|
||||
if (array_key_exists($key, $rules)) {
|
||||
$item = $rules[self::$bind['group']];
|
||||
if (!empty(self::$bind['domain']) && true === $item) {
|
||||
$rules = [self::$rules['*'][$key]];
|
||||
} else {
|
||||
$rules = [$key => $item];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -1049,7 +1081,7 @@ class Route
|
||||
{
|
||||
if (isset(self::$bind['module'])) {
|
||||
// 如果有模块/控制器绑定
|
||||
$url = self::$bind['module'] . '/' . $url;
|
||||
$url = self::$bind['module'] . '/' . ltrim($url, '/');
|
||||
}
|
||||
|
||||
list($path, $var) = self::parseUrlPath($url, $depr);
|
||||
|
||||
32
core/library/think/cache/driver/File.php
vendored
32
core/library/think/cache/driver/File.php
vendored
@@ -69,19 +69,17 @@ class File
|
||||
$name = md5($name);
|
||||
if ($this->options['cache_subdir']) {
|
||||
// 使用子目录
|
||||
$dir = '';
|
||||
$len = $this->options['path_level'];
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$dir .= $name{$i} . DS;
|
||||
}
|
||||
if (!is_dir($this->options['path'] . $dir)) {
|
||||
mkdir($this->options['path'] . $dir, 0755, true);
|
||||
}
|
||||
$filename = $dir . $this->options['prefix'] . $name . '.php';
|
||||
} else {
|
||||
$filename = $this->options['prefix'] . $name . '.php';
|
||||
$name = substr($md5, 0, 2) . DS . substr($md5, 2);
|
||||
}
|
||||
return $this->options['path'] . $filename;
|
||||
if ($this->options['prefix']) {
|
||||
$name = $this->options['prefix'] . DS . $name;
|
||||
}
|
||||
$filename = $this->options['path'] . $name . '.php';
|
||||
$dir = dirname($filename);
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0755, true);
|
||||
}
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,17 +161,16 @@ class File
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function inc($name, $step = 1, $expire = null)
|
||||
public function inc($name, $step = 1)
|
||||
{
|
||||
if ($this->has($name)) {
|
||||
$value = $this->get($name) + $step;
|
||||
} else {
|
||||
$value = $step;
|
||||
}
|
||||
return $this->set($name, $value, $expire) ? $value : false;
|
||||
return $this->set($name, $value, 0) ? $value : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,17 +178,16 @@ class File
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function dec($name, $step = 1, $expire = null)
|
||||
public function dec($name, $step = 1)
|
||||
{
|
||||
if ($this->has($name)) {
|
||||
$value = $this->get($name) - $step;
|
||||
} else {
|
||||
$value = $step;
|
||||
}
|
||||
return $this->set($name, $value, $expire) ? $value : false;
|
||||
return $this->set($name, $value, 0) ? $value : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
10
core/library/think/cache/driver/Lite.php
vendored
10
core/library/think/cache/driver/Lite.php
vendored
@@ -118,17 +118,16 @@ class Lite
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function inc($name, $step = 1, $expire = null)
|
||||
public function inc($name, $step = 1)
|
||||
{
|
||||
if ($this->has($name)) {
|
||||
$value = $this->get($name) + $step;
|
||||
} else {
|
||||
$value = $step;
|
||||
}
|
||||
return $this->set($name, $value, $expire) ? $value : false;
|
||||
return $this->set($name, $value, 0) ? $value : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,17 +135,16 @@ class Lite
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function dec($name, $step = 1, $expire = null)
|
||||
public function dec($name, $step = 1)
|
||||
{
|
||||
if ($this->has($name)) {
|
||||
$value = $this->get($name) - $step;
|
||||
} else {
|
||||
$value = $step;
|
||||
}
|
||||
return $this->set($name, $value, $expire) ? $value : false;
|
||||
return $this->set($name, $value, 0) ? $value : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
6
core/library/think/cache/driver/Memcache.php
vendored
6
core/library/think/cache/driver/Memcache.php
vendored
@@ -105,10 +105,9 @@ class Memcache
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function inc($name, $step = 1, $expire = null)
|
||||
public function inc($name, $step = 1)
|
||||
{
|
||||
return $this->handler->increment($name, $step);
|
||||
}
|
||||
@@ -118,10 +117,9 @@ class Memcache
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function dec($name, $step = 1, $expire = null)
|
||||
public function dec($name, $step = 1)
|
||||
{
|
||||
return $this->handler->decrement($name, $step);
|
||||
}
|
||||
|
||||
@@ -111,10 +111,9 @@ class Memcached
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function inc($name, $step = 1, $expire = null)
|
||||
public function inc($name, $step = 1)
|
||||
{
|
||||
return $this->handler->increment($name, $step);
|
||||
}
|
||||
@@ -124,10 +123,9 @@ class Memcached
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function dec($name, $step = 1, $expire = null)
|
||||
public function dec($name, $step = 1)
|
||||
{
|
||||
return $this->handler->decrement($name, $step);
|
||||
}
|
||||
|
||||
6
core/library/think/cache/driver/Redis.php
vendored
6
core/library/think/cache/driver/Redis.php
vendored
@@ -111,10 +111,9 @@ class Redis
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function inc($name, $step = 1, $expire = null)
|
||||
public function inc($name, $step = 1)
|
||||
{
|
||||
return $this->handler->incrby($name, $step);
|
||||
}
|
||||
@@ -124,10 +123,9 @@ class Redis
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function dec($name, $step = 1, $expire = null)
|
||||
public function dec($name, $step = 1)
|
||||
{
|
||||
return $this->handler->decrby($name, $step);
|
||||
}
|
||||
|
||||
10
core/library/think/cache/driver/Sqlite.php
vendored
10
core/library/think/cache/driver/Sqlite.php
vendored
@@ -115,17 +115,16 @@ class Sqlite
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function inc($name, $step = 1, $expire = null)
|
||||
public function inc($name, $step = 1)
|
||||
{
|
||||
if ($this->has($name)) {
|
||||
$value = $this->get($name) + $step;
|
||||
} else {
|
||||
$value = $step;
|
||||
}
|
||||
return $this->set($name, $value, $expire) ? $value : false;
|
||||
return $this->set($name, $value, 0) ? $value : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,17 +132,16 @@ class Sqlite
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function dec($name, $step = 1, $expire = null)
|
||||
public function dec($name, $step = 1)
|
||||
{
|
||||
if ($this->has($name)) {
|
||||
$value = $this->get($name) - $step;
|
||||
} else {
|
||||
$value = $step;
|
||||
}
|
||||
return $this->set($name, $value, $expire) ? $value : false;
|
||||
return $this->set($name, $value, 0) ? $value : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
10
core/library/think/cache/driver/Wincache.php
vendored
10
core/library/think/cache/driver/Wincache.php
vendored
@@ -90,12 +90,11 @@ class Wincache
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function inc($name, $step = 1, $expire = null)
|
||||
public function inc($name, $step = 1)
|
||||
{
|
||||
return wincache_ucache_inc($name, $step, $expire);
|
||||
return wincache_ucache_inc($name, $step);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,12 +102,11 @@ class Wincache
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function dec($name, $step = 1, $expire = null)
|
||||
public function dec($name, $step = 1)
|
||||
{
|
||||
return wincache_ucache_dec($name, $step, $expire);
|
||||
return wincache_ucache_dec($name, $step);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
10
core/library/think/cache/driver/Xcache.php
vendored
10
core/library/think/cache/driver/Xcache.php
vendored
@@ -90,12 +90,11 @@ class Xcache
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function inc($name, $step = 1, $expire = null)
|
||||
public function inc($name, $step = 1)
|
||||
{
|
||||
return xcache_inc($name, $step, $expire);
|
||||
return xcache_inc($name, $step);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,12 +102,11 @@ class Xcache
|
||||
* @access public
|
||||
* @param string $name 缓存变量名
|
||||
* @param int $step 步长
|
||||
* @param int $expire 有效时间 0为永久
|
||||
* @return false|int
|
||||
*/
|
||||
public function dec($name, $step = 1, $expire = null)
|
||||
public function dec($name, $step = 1)
|
||||
{
|
||||
return xcache_dec($name, $step, $expire);
|
||||
return xcache_dec($name, $step);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,13 @@ use think\Exception;
|
||||
use think\exception\PDOException;
|
||||
use think\Log;
|
||||
|
||||
/**
|
||||
* Class Connection
|
||||
* @package think
|
||||
* @method Query table(string $table) 指定数据表(含前缀)
|
||||
* @method Query name(string $name) 指定数据表(不含前缀)
|
||||
*
|
||||
*/
|
||||
abstract class Connection
|
||||
{
|
||||
|
||||
|
||||
@@ -39,9 +39,10 @@ class File
|
||||
public function save(array $log = [])
|
||||
{
|
||||
$now = date($this->config['time_format']);
|
||||
$destination = $this->config['path'] . date('y_m_d') . '.log';
|
||||
$destination = $this->config['path'] . date('Ym') . DS . date('d') . '.log';
|
||||
|
||||
!is_dir($this->config['path']) && mkdir($this->config['path'], 0755, true);
|
||||
$path = dirname($destination);
|
||||
!is_dir($path) && mkdir($path, 0755, true);
|
||||
|
||||
//检测日志文件大小,超过配置大小则备份日志文件重新生成
|
||||
if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) {
|
||||
|
||||
Reference in New Issue
Block a user