Skip to content

Commit 75bbbe8

Browse files
committed
cluster引擎升级核心到3.1.3
1 parent 1248c23 commit 75bbbe8

File tree

6 files changed

+52
-59
lines changed

6 files changed

+52
-59
lines changed

Extend/Engine/Cluster/Common/functions.php

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,10 @@ function halt($error) {
2929
$trace = debug_backtrace();
3030
$e['message'] = $error;
3131
$e['file'] = $trace[0]['file'];
32-
$e['class'] = isset($trace[0]['class'])?$trace[0]['class']:'';
33-
$e['function'] = isset($trace[0]['function'])?$trace[0]['function']:'';
3432
$e['line'] = $trace[0]['line'];
35-
$traceInfo = '';
36-
$time = date('y-m-d H:i:m');
37-
foreach ($trace as $t) {
38-
$traceInfo .= '[' . $time . '] ' . $t['file'] . ' (' . $t['line'] . ') ';
39-
$traceInfo .= $t['class'] . $t['type'] . $t['function'] . '(';
40-
$traceInfo .= implode(', ', $t['args']);
41-
$traceInfo .=')<br/>';
42-
}
43-
$e['trace'] = $traceInfo;
33+
ob_start();
34+
debug_print_backtrace();
35+
$e['trace'] = ob_get_clean();
4436
} else {
4537
$e = $error;
4638
}
@@ -61,6 +53,7 @@ function halt($error) {
6153
exit;
6254
}
6355

56+
6457
/**
6558
* 自定义异常处理
6659
* @param string $msg 异常消息
@@ -70,7 +63,7 @@ function halt($error) {
7063
*/
7164
function throw_exception($msg, $type='ThinkException', $code=0) {
7265
if (class_exists($type, false))
73-
throw new $type($msg, $code, true);
66+
throw new $type($msg, $code);
7467
else
7568
halt($msg); // 异常类型不存在则输出错误信息字串
7669
}
@@ -295,11 +288,13 @@ function U($url='',$vars='',$suffix=true,$redirect=false,$domain=false) {
295288
* @param string $name Widget名称
296289
* @param array $data 传人的参数
297290
* @param boolean $return 是否返回内容
291+
* @param string $path Widget所在路径
298292
* @return void
299293
*/
300-
function W($name, $data=array(), $return=false) {
294+
function W($name, $data=array(), $return=false,$path='') {
301295
$class = $name . 'Widget';
302-
require_cache(BASE_LIB_PATH . 'Widget/' . $class . '.class.php');
296+
$path = empty($path) ? BASE_LIB_PATH : $path;
297+
require_cache($path . 'Widget/' . $class . '.class.php');
303298
if (!class_exists($class))
304299
throw_exception(L('_CLASS_NOT_EXIST_') . ':' . $class);
305300
$widget = Think::instance($class);
@@ -390,7 +385,11 @@ function S($name,$value='',$options=null) {
390385
}elseif(is_null($value)) { // 删除缓存
391386
return $cache->rm($name);
392387
}else { // 缓存数据
393-
$expire = is_numeric($options)?$options:NULL;
388+
if(is_array($options)) {
389+
$expire = isset($options['expire'])?$options['expire']:NULL;
390+
}else{
391+
$expire = is_numeric($options)?$options:NULL;
392+
}
394393
return $cache->set($name, $value, $expire);
395394
}
396395
}

Extend/Engine/Cluster/Common/runtime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
if(version_compare(PHP_VERSION,'5.2.0','<')) die('require PHP > 5.2.0 !');
2020

2121
// 版本信息
22-
define('THINK_VERSION', '3.1.2');
22+
define('THINK_VERSION', '3.1.3');
2323

2424
// 系统信息
2525
if(version_compare(PHP_VERSION,'5.4.0','<')) {

Extend/Engine/Cluster/Lib/Core/Action.class.php

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ abstract class Action {
3232
*/
3333
private $name = '';
3434

35-
/**
36-
* 模板变量
37-
* @var tVar
38-
* @access protected
39-
*/
40-
protected $tVar = array();
41-
4235
/**
4336
* 控制器参数
4437
* @var config
@@ -52,6 +45,8 @@ abstract class Action {
5245
*/
5346
public function __construct() {
5447
tag('action_begin',$this->config);
48+
//实例化视图类
49+
$this->view = Think::instance('View');
5550
//控制器初始化
5651
if(method_exists($this,'_initialize'))
5752
$this->_initialize();
@@ -97,7 +92,6 @@ protected function isAjax() {
9792
* @return void
9893
*/
9994
protected function display($templateFile='',$charset='',$contentType='',$content='',$prefix='') {
100-
$this->initView();
10195
$this->view->display($templateFile,$charset,$contentType,$content,$prefix);
10296
}
10397

@@ -111,7 +105,6 @@ protected function display($templateFile='',$charset='',$contentType='',$content
111105
* @return mixed
112106
*/
113107
protected function show($content,$charset='',$contentType='',$prefix='') {
114-
$this->initView();
115108
$this->view->display('',$charset,$contentType,$content,$prefix);
116109
}
117110

@@ -126,22 +119,9 @@ protected function show($content,$charset='',$contentType='',$prefix='') {
126119
* @return string
127120
*/
128121
protected function fetch($templateFile='',$content='',$prefix='') {
129-
$this->initView();
130122
return $this->view->fetch($templateFile,$content,$prefix);
131123
}
132124

133-
/**
134-
* 初始化视图
135-
* @access private
136-
* @return void
137-
*/
138-
private function initView(){
139-
//实例化视图类
140-
if(!$this->view) $this->view = Think::instance('View');
141-
// 模板变量传值
142-
if($this->tVar) $this->view->assign($this->tVar);
143-
}
144-
145125
/**
146126
* 创建静态页面
147127
* @access protected
@@ -171,11 +151,8 @@ protected function buildHtml($htmlfile='',$htmlpath='',$templateFile='') {
171151
* @return void
172152
*/
173153
protected function assign($name,$value='') {
174-
if(is_array($name)) {
175-
$this->tVar = array_merge($this->tVar,$name);
176-
}else {
177-
$this->tVar[$name] = $value;
178-
}
154+
$this->view->assign($name,$value);
155+
return $this;
179156
}
180157

181158
public function __set($name,$value) {
@@ -189,10 +166,7 @@ public function __set($name,$value) {
189166
* @return mixed
190167
*/
191168
public function get($name='') {
192-
if('' === $name) {
193-
return $this->tVar;
194-
}
195-
return isset($this->tVar[$name])?$this->tVar[$name]:false;
169+
return $this->view->get($name);
196170
}
197171

198172
public function __get($name) {
@@ -206,7 +180,7 @@ public function __get($name) {
206180
* @return boolean
207181
*/
208182
public function __isset($name) {
209-
return isset($this->tVar[$name]);
183+
return $this->get($name);
210184
}
211185

212186
/**
@@ -254,9 +228,8 @@ public function __call($method,$args) {
254228
default:
255229
$input = $_GET;
256230
}
257-
if(C('VAR_URL_PARAMS')){
258-
$params = $_GET[C('VAR_URL_PARAMS')];
259-
$input = array_merge($input,$params);
231+
if(C('VAR_URL_PARAMS') && isset($_GET[C('VAR_URL_PARAMS')])){
232+
$input = array_merge($input,$_GET[C('VAR_URL_PARAMS')]);
260233
}
261234
break;
262235
case '_request' : $input =& $_REQUEST; break;
@@ -283,6 +256,7 @@ public function __call($method,$args) {
283256
}else{ // 变量默认值
284257
$data = isset($args[2])?$args[2]:NULL;
285258
}
259+
Log::record('建议使用I方法替代'.$method,Log::NOTICE);
286260
return $data;
287261
}
288262
}
@@ -295,7 +269,7 @@ public function __call($method,$args) {
295269
* @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间
296270
* @return void
297271
*/
298-
protected function error($message,$jumpUrl='',$ajax=false) {
272+
protected function error($message='',$jumpUrl='',$ajax=false) {
299273
$this->dispatchJump($message,0,$jumpUrl,$ajax);
300274
}
301275

@@ -307,7 +281,7 @@ protected function error($message,$jumpUrl='',$ajax=false) {
307281
* @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间
308282
* @return void
309283
*/
310-
protected function success($message,$jumpUrl='',$ajax=false) {
284+
protected function success($message='',$jumpUrl='',$ajax=false) {
311285
$this->dispatchJump($message,1,$jumpUrl,$ajax);
312286
}
313287

@@ -420,8 +394,6 @@ private function dispatchJump($message,$status=1,$jumpUrl='',$ajax=false) {
420394
* @access public
421395
*/
422396
public function __destruct() {
423-
// 保存日志
424-
if(C('LOG_RECORD')) Log::save();
425397
// 执行后续操作
426398
tag('action_end');
427399
}

Extend/Engine/Cluster/Lib/Core/Think.class.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,18 @@ static public function instance($class,$method='') {
254254
* @param mixed $e 异常对象
255255
*/
256256
static public function appException($e) {
257-
halt($e->__toString());
257+
$error = array();
258+
$error['message'] = $e->getMessage();
259+
$trace = $e->getTrace();
260+
if('throw_exception'==$trace[0]['function']) {
261+
$error['file'] = $trace[0]['file'];
262+
$error['line'] = $trace[0]['line'];
263+
}else{
264+
$error['file'] = $e->getFile();
265+
$error['line'] = $e->getLine();
266+
}
267+
Log::record($error['message'],Log::ERR);
268+
halt($error);
258269
}
259270

260271
/**
@@ -295,8 +306,19 @@ function_exists('halt')?halt($errorStr):exit('ERROR:'.$errorStr);
295306

296307
// 致命错误捕获
297308
static public function fatalError() {
309+
// 保存日志记录
310+
if(C('LOG_RECORD')) Log::save();
298311
if ($e = error_get_last()) {
299-
Think::appError($e['type'],$e['message'],$e['file'],$e['line']);
312+
switch($e['type']){
313+
case E_ERROR:
314+
case E_PARSE:
315+
case E_CORE_ERROR:
316+
case E_COMPILE_ERROR:
317+
case E_USER_ERROR:
318+
ob_end_clean();
319+
function_exists('halt')?halt($e):exit('ERROR:'.$e['message']);
320+
break;
321+
}
300322
}
301323
}
302324

Extend/Engine/Cluster/Lib/Template/ThinkTemplate.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ public function parseVar($varStr){
503503
$name = "$".$var;
504504
preg_match('/(.+?)\[(.+?)\]/is',$var,$match);
505505
$var = $match[1];
506-
}elseif(false !==strpos($var,':') && false ===strpos($var,'::') && false ===strpos($var,'?')){
506+
}elseif(false !==strpos($var,':') && false ===strpos($var,'(') && false ===strpos($var,'::') && false ===strpos($var,'?')){
507507
//支持 {$var:property} 方式输出对象的属性
508508
$vars = explode(':',$var);
509509
$var = str_replace(':','->',$var);

Extend/Engine/cluster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// ThinkPHP 入口文件
1313

1414
//[cluster] 定义路径常量
15+
defined('RUNTIME_PATH') or define('RUNTIME_PATH',APP_PATH.'Runtime/');
1516
defined('CLUSTER_PATH') or define('CLUSTER_PATH',ENGINE_PATH.'Cluster/');
1617
//[cluster] 提前系统目录定义
1718
defined('IO_NAME') or define('IO_NAME','auto');
@@ -24,7 +25,6 @@
2425
//[cluster] 定义加载IO配置
2526
defined('IO_TRUE_NAME') or define('IO_TRUE_NAME',IO_NAME);
2627
require CLUSTER_PATH.'Lib/Core/ThinkFS.class.php';
27-
defined('RUNTIME_PATH') or define('RUNTIME_PATH',APP_PATH.'Runtime/');
2828
defined('APP_DEBUG') or define('APP_DEBUG',false); // 是否调试模式
2929
$runtime = defined('MODE_NAME')?'~'.strtolower(MODE_NAME).'_runtime.php':'~runtime.php';
3030
defined('RUNTIME_FILE') or define('RUNTIME_FILE',RUNTIME_PATH.$runtime);

0 commit comments

Comments
 (0)