Merge pull request #268 from kijin/pr/debugger

편리한 디버그 기능 추가
This commit is contained in:
Kijin Sung 2016-02-16 14:33:44 +09:00
commit e1341584d3
42 changed files with 1693 additions and 730 deletions

View file

@ -331,9 +331,9 @@ class Context
{
ob_start();
$this->setCacheControl(-1, true);
register_shutdown_function(array($this, 'checkSessionStatus'));
$_SESSION = array();
}
register_shutdown_function('Context::close');
// set authentication information in Context and session
if(self::isInstalled())
@ -411,7 +411,7 @@ class Context
{
if(self::getSessionStatus())
{
return;
return true;
}
if($force_start || (count($_SESSION) && !headers_sent()))
{
@ -419,7 +419,9 @@ class Context
unset($_SESSION);
session_start();
$_SESSION = $tempSession;
return true;
}
return false;
}
/**
@ -429,7 +431,11 @@ class Context
*/
public static function close()
{
session_write_close();
// Check session status and close it if open.
if (self::checkSessionStatus())
{
session_write_close();
}
}
/**
@ -1468,18 +1474,39 @@ class Context
}
else
{
self::setBrowserTitle(self::getSiteTitle());
$oMessageObject = getView('message');
$oMessageObject->setHttpStatusCode(503);
$oMessageObject->setError(-1);
$oMessageObject->setMessage(_XE_SITELOCK_TITLE_);
$oMessageObject->dispMessage();
$oModuleHandler = new ModuleHandler;
$oModuleHandler->displayContent($oMessageObject);
self::displayErrorPage(_XE_SITELOCK_TITLE_, _XE_SITELOCK_MESSAGE_, 503);
}
exit;
}
/**
* Display a generic error page and exit.
*
* @param string $title
* @param string $message
* @return void
*/
public static function displayErrorPage($title = 'Error', $message = '', $status = 500)
{
// Change current directory to the Rhymix installation path.
chdir(\RX_BASEDIR);
// Set the title.
self::setBrowserTitle(self::getSiteTitle());
self::addBrowserTitle($title);
// Set the message.
$oMessageObject = getView('message');
$oMessageObject->setError(-1);
$oMessageObject->setHttpStatusCode($status);
$oMessageObject->setMessage($title);
$oMessageObject->dispMessage($message);
// Display the message.
$oModuleHandler = new ModuleHandler;
$oModuleHandler->displayContent($oMessageObject);
}
/**
* Return request method
* @return string Request method type. (Optional - GET|POST|XMLRPC|JSON)

View file

@ -364,55 +364,47 @@ class DB
$log['module'] = $site_module_info->module;
$log['act'] = Context::get('act');
$log['time'] = date('Y-m-d H:i:s');
$log['backtrace'] = array();
$bt = version_compare(PHP_VERSION, '5.3.6', '>=') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace();
foreach($bt as $no => $call)
if (config('debug.enabled') && config('debug.log_queries'))
{
if($call['function'] == 'executeQuery' || $call['function'] == 'executeQueryArray')
$bt = defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace();
foreach($bt as $no => $call)
{
$call_no = $no;
$call_no++;
$log['called_file'] = $bt[$call_no]['file'].':'.$bt[$call_no]['line'];
$log['called_file'] = str_replace(_XE_PATH_ , '', $log['called_file']);
$call_no++;
$log['called_method'] = $bt[$call_no]['class'].$bt[$call_no]['type'].$bt[$call_no]['function'];
break;
}
}
// leave error log if an error occured (if __DEBUG_DB_OUTPUT__ is defined)
if($this->isError())
{
$log['result'] = 'Failed';
$log['errno'] = $this->errno;
$log['errstr'] = $this->errstr;
if(__DEBUG_DB_OUTPUT__ == 1)
{
$debug_file = _XE_PATH_ . "files/_debug_db_query.php";
$buff = array();
if(!file_exists($debug_file))
if($call['function'] == 'executeQuery' || $call['function'] == 'executeQueryArray')
{
$buff[] = '<?php exit(); ?' . '>';
$call_no = $no;
$call_no++;
$log['called_file'] = $bt[$call_no]['file'];
$log['called_line'] = $bt[$call_no]['line'];
$call_no++;
$log['called_method'] = $bt[$call_no]['class'].$bt[$call_no]['type'].$bt[$call_no]['function'];
$log['backtrace'] = array_slice($bt, $call_no, 1);
break;
}
$buff[] = print_r($log, TRUE);
@file_put_contents($log_file, implode("\n", $buff) . "\n\n", FILE_APPEND|LOCK_EX);
}
}
else
{
$log['result'] = 'Success';
$log['called_file'] = $log['called_line'] = $log['called_method'] = null;
$log['backtrace'] = array();
}
// leave error log if an error occured
if($this->isError())
{
$log['result'] = 'error';
$log['errno'] = $this->errno;
$log['errstr'] = $this->errstr;
}
else
{
$log['result'] = 'success';
$log['errno'] = null;
$log['errstr'] = null;
}
$this->setQueryLog($log);
$log_args = new stdClass;
$log_args->query = $this->query;
$log_args->query_id = $this->query_id;
$log_args->caller = $log['called_method'] . '() in ' . $log['called_file'];
$log_args->connection = $log['connection'];
writeSlowlog('query', $elapsed_time, $log_args);
}
/**
@ -422,7 +414,7 @@ class DB
*/
public function setQueryLog($log)
{
$GLOBALS['__db_queries__'][] = $log;
Rhymix\Framework\Debug::addQuery($log);
}
/**
@ -868,7 +860,7 @@ class DB
{
$this->_connect($type);
}
$this->connection = 'Master ' . $this->master_db['host'];
$this->connection = 'master (' . $this->master_db['host'] . ')';
return $this->master_db["resource"];
}
@ -883,7 +875,7 @@ class DB
{
$this->_connect($type);
}
$this->connection = 'Master ' . $this->master_db['host'];
$this->connection = 'master (' . $this->master_db['host'] . ')';
return $this->master_db["resource"];
}
@ -891,7 +883,7 @@ class DB
{
$this->_connect($type, $indx);
}
$this->connection = 'Slave ' . $this->slave_db[$indx]['host'];
$this->connection = 'slave (' . $this->slave_db[$indx]['host'] . ')';
return $this->slave_db[$indx]["resource"];
}
@ -1148,7 +1140,7 @@ class DB
$connection["is_connected"] = TRUE;
// Save connection info for db logs
$this->connection = ucfirst($type) . ' ' . $connection['host'];
$this->connection = $type . ' (' . $connection['host'] . ')';
// regist $this->close callback
register_shutdown_function(array($this, "close"));

View file

@ -971,8 +971,6 @@ class DBCubrid extends DB
return;
}
$query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
$result = $this->_query($query);
if($result && !$this->transaction_started)
{
@ -1002,8 +1000,6 @@ class DBCubrid extends DB
return;
}
$query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
$result = $this->_query($query);
if($result && !$this->transaction_started)
@ -1034,8 +1030,6 @@ class DBCubrid extends DB
return;
}
$query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
$result = $this->_query($query);
if($result && !$this->transaction_started)
@ -1077,7 +1071,6 @@ class DBCubrid extends DB
return;
}
$query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
$result = $this->_query($query, $connection);
if($this->isError())
@ -1147,7 +1140,6 @@ class DBCubrid extends DB
$count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
}
$count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : '';
$result = $this->_query($count_query, $connection);
$count_output = $this->_fetch($result);
$total_count = (int) (isset($count_output->count) ? $count_output->count : NULL);
@ -1195,7 +1187,6 @@ class DBCubrid extends DB
$start_count = ($page - 1) * $list_count;
$query = $this->getSelectPageSql($queryObject, $with_values, $start_count, $list_count);
$query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
$result = $this->_query($query, $connection);
if($this->isError())
{

View file

@ -943,8 +943,6 @@ class DBMssql extends DB
// TODO Decide if we continue to pass parameters like this
$this->param = $queryObject->getArguments();
$query .= (__DEBUG_QUERY__ & 1 && $output->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
$result = $this->_query($query, $connection);
if($this->isError())
@ -1024,7 +1022,6 @@ class DBMssql extends DB
$count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
}
$count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
$this->param = $queryObject->getArguments();
$result_count = $this->_query($count_query, $connection);
$count_output = $this->_fetch($result_count);

View file

@ -689,7 +689,6 @@ class DBMysql extends DB
function _executeInsertAct($queryObject, $with_values = true)
{
$query = $this->getInsertSql($queryObject, $with_values, true);
$query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
if(is_a($query, 'Object'))
{
return;
@ -711,10 +710,6 @@ class DBMysql extends DB
if(!$query->toBool()) return $query;
else return;
}
$query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
return $this->_query($query);
}
@ -727,7 +722,6 @@ class DBMysql extends DB
function _executeDeleteAct($queryObject, $with_values = true)
{
$query = $this->getDeleteSql($queryObject, $with_values, true);
$query .= (__DEBUG_QUERY__ & 1 && $this->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
if(is_a($query, 'Object'))
{
return;
@ -759,7 +753,6 @@ class DBMysql extends DB
{
return;
}
$query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : '';
$result = $this->_query($query, $connection);
if($this->isError())
@ -880,7 +873,6 @@ class DBMysql extends DB
$count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query);
}
$count_query .= (__DEBUG_QUERY__ & 1 && $queryObject->queryID) ? sprintf(' ' . $this->comment_syntax, $queryObject->queryID) : '';
$result_count = $this->_query($count_query, $connection);
$count_output = $this->_fetch($result_count);
$total_count = (int) (isset($count_output->count) ? $count_output->count : NULL);
@ -927,7 +919,6 @@ class DBMysql extends DB
$query = $this->getSelectPageSql($queryObject, $with_values, $start_count, $list_count);
$query .= (__DEBUG_QUERY__ & 1 && $queryObject->query_id) ? sprintf(' ' . $this->comment_syntax, $this->query_id) : '';
$result = $this->_query($query, $connection);
if($this->isError())
{

View file

@ -11,7 +11,7 @@
*/
class DisplayHandler extends Handler
{
public static $response_size = 0;
var $content_size = 0; // /< The size of displaying contents
var $gz_enabled = FALSE; // / <a flog variable whether to call contents after compressing by gzip
var $handler = NULL;
@ -78,10 +78,9 @@ class DisplayHandler extends Handler
}
// Start the session if $_SESSION was touched
Context::getInstance()->checkSessionStatus();
Context::checkSessionStatus();
// header output
$httpStatusCode = $oModule->getHttpStatusCode();
if($httpStatusCode && $httpStatusCode != 200)
{
@ -119,201 +118,118 @@ class DisplayHandler extends Handler
ini_set('zlib.output_compression', true);
}
// results directly output
print $output;
// debugOutput output
$this->content_size = strlen($output);
print $this->_debugOutput();
// call a trigger after display
self::$response_size = $this->content_size = strlen($output);
ModuleHandler::triggerCall('display', 'after', $output);
flushSlowlog();
// Output the page content and debug data.
$debug = $this->getDebugInfo($output);
print $output;
print $debug;
}
/**
* Print debugging message to designated output source depending on the value set to __DEBUG_OUTPUT_. \n
* This method only functions when __DEBUG__ variable is set to 1.
* __DEBUG_OUTPUT__ == 0, messages are written in ./files/_debug_message.php
* @return void
* Get debug information.
*
* @return string
*/
public function _debugOutput()
public function getDebugInfo(&$output)
{
if(!__DEBUG__)
// Check if debugging is enabled for this request.
if (!config('debug.enabled') || !Rhymix\Framework\Debug::isEnabledForCurrentUser())
{
return;
}
$end = microtime(true);
// Firebug console output
if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1)
// Print debug information.
switch ($display_type = config('debug.display_type'))
{
static $firephp;
if(!isset($firephp))
{
$firephp = FirePHP::getInstance(true);
}
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
{
$firephp->fb('Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php', 'The IP address is not allowed.');
return;
}
// display total execution time and Request/Response info
if(__DEBUG__ & 2)
{
$firephp->fb(
array(
'Request / Response info >>> ' . $_SERVER['REQUEST_METHOD'] . ' / ' . Context::getResponseMethod(),
array(
array('Request URI', 'Request method', 'Response method', 'Response contents size', 'Memory peak usage'),
array(
sprintf("%s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']),
$_SERVER['REQUEST_METHOD'],
Context::getResponseMethod(),
$this->content_size . ' byte',
FileHandler::filesize(memory_get_peak_usage())
)
)
),
'TABLE'
);
$firephp->fb(
array(
'Elapsed time >>> Total : ' . sprintf('%0.5f sec', $end - RX_MICROTIME),
array(array('DB queries', 'class file load', 'Template compile', 'XmlParse compile', 'PHP', 'Widgets', 'Trans Content'),
array(
sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']),
sprintf('%0.5f sec', $GLOBALS['__elapsed_class_load__']),
sprintf('%0.5f sec (%d called)', $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']),
sprintf('%0.5f sec', $GLOBALS['__xmlparse_elapsed__']),
sprintf('%0.5f sec', $end - RX_MICROTIME - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']),
sprintf('%0.5f sec', $GLOBALS['__widget_excute_elapsed__']),
sprintf('%0.5f sec', $GLOBALS['__trans_content_elapsed__'])
)
)
),
'TABLE'
);
}
// display DB query history
if((__DEBUG__ & 4) && $GLOBALS['__db_queries__'])
{
$queries_output = array(array('Result/'.PHP_EOL.'Elapsed time', 'Query ID', 'Query'));
foreach($GLOBALS['__db_queries__'] as $query)
case 'panel':
$data = Rhymix\Framework\Debug::getDebugData();
if ($data->entries)
{
$queries_output[] = array($query['result'] . PHP_EOL . sprintf('%0.5f', $query['elapsed_time']), str_replace(_XE_PATH_, '', $query['called_file']) . PHP_EOL . $query['called_method'] . '()' . PHP_EOL . $query['query_id'], $query['query']);
}
$firephp->fb(
array(
'DB Queries >>> ' . count($GLOBALS['__db_queries__']) . ' Queries, ' . sprintf('%0.5f sec', $GLOBALS['__db_elapsed_time__']),
$queries_output
),
'TABLE'
);
}
// dislpay the file and HTML comments
}
else
{
$buff = array();
// display total execution time and Request/Response info
if(__DEBUG__ & 2)
{
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
{
return;
}
// Request/Response information
$buff[] = "\n- Request/ Response info";
$buff[] = sprintf("\tRequest URI \t\t\t: %s:%s%s%s%s", $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'] ? '?' : '', $_SERVER['QUERY_STRING']);
$buff[] = sprintf("\tRequest method \t\t\t: %s", $_SERVER['REQUEST_METHOD']);
$buff[] = sprintf("\tResponse method \t\t: %s", Context::getResponseMethod());
$buff[] = sprintf("\tResponse contents size\t: %d byte", $this->content_size);
// total execution time
$buff[] = sprintf("\n- Total elapsed time : %0.5f sec", $end - RX_MICROTIME);
$buff[] = sprintf("\tclass file load elapsed time \t: %0.5f sec", $GLOBALS['__elapsed_class_load__']);
$buff[] = sprintf("\tTemplate compile elapsed time\t: %0.5f sec (%d called)", $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']);
$buff[] = sprintf("\tXmlParse compile elapsed time\t: %0.5f sec", $GLOBALS['__xmlparse_elapsed__']);
$buff[] = sprintf("\tPHP elapsed time \t\t\t\t: %0.5f sec", $end - RX_MICROTIME - $GLOBALS['__template_elapsed__'] - $GLOBALS['__xmlparse_elapsed__'] - $GLOBALS['__db_elapsed_time__'] - $GLOBALS['__elapsed_class_load__']);
$buff[] = sprintf("\tDB class elapsed time \t\t\t: %0.5f sec", $GLOBALS['__dbclass_elapsed_time__'] - $GLOBALS['__db_elapsed_time__']);
// widget execution time
$buff[] = sprintf("\tWidgets elapsed time \t\t\t: %0.5f sec", $GLOBALS['__widget_excute_elapsed__']);
// layout execution time
$buff[] = sprintf("\tLayout compile elapsed time \t: %0.5f sec", $GLOBALS['__layout_compile_elapsed__']);
// Widgets, the editor component replacement time
$buff[] = sprintf("\tTrans Content \t\t\t\t\t: %0.5f sec", $GLOBALS['__trans_content_elapsed__']);
}
// DB Logging
if(__DEBUG__ & 4)
{
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
{
return;
}
if($GLOBALS['__db_queries__'])
{
$buff[] = sprintf("\n- DB Queries : %d Queries. %0.5f sec", count($GLOBALS['__db_queries__']), $GLOBALS['__db_elapsed_time__']);
$num = 0;
foreach($GLOBALS['__db_queries__'] as $query)
foreach ($data->entries as &$entry)
{
if($query['result'] == 'Success')
if (is_scalar($entry->message))
{
$query_result = "Query Success";
$entry->message = var_export($entry->message, true);
}
else
{
$query_result = sprintf("Query $s : %d\n\t\t\t %s", $query['result'], $query['errno'], $query['errstr']);
$entry->message = trim(print_r($entry->message, true));
}
$buff[] = sprintf("\t%02d. %s\n\t\t%0.6f sec. %s.", ++$num, $query['query'], $query['elapsed_time'], $query_result);
$buff[] = sprintf("\t\tConnection: %s.", $query['connection']);
$buff[] = sprintf("\t\tQuery ID: %s", $query['query_id']);
$buff[] = sprintf("\t\tCalled: %s. %s()", str_replace(_XE_PATH_, '', $query['called_file']), $query['called_method']);
}
}
}
// Output in HTML comments
if($buff && __DEBUG_OUTPUT__ == 1 && Context::getResponseMethod() == 'HTML')
{
$buff = implode("\r\n", $buff);
$buff = sprintf("[%s %s:%d]\r\n%s", date('Y-m-d H:i:s'), $file_name, $line_num, print_r($buff, true));
if(__DEBUG_PROTECT__ == 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
switch (Context::getResponseMethod())
{
$buff = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php';
case 'HTML':
$json_options = defined('JSON_PRETTY_PRINT') ? (JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) : 0;
$panel_script = sprintf('<script src="%s%s?%s"></script>', RX_BASEURL, 'common/js/debug.js', filemtime(RX_BASEDIR . 'common/js/debug.js'));
if (isset($_SESSION['_rx_debug_previous']))
{
$panel_script .= "\n<script>\nvar rhymix_debug_previous = " . json_encode($_SESSION['_rx_debug_previous'], $json_options) . ";\n</script>";
unset($_SESSION['_rx_debug_previous']);
}
$panel_script .= "\n<script>\nvar rhymix_debug_content = " . json_encode($data, $json_options) . ";\n</script>";
$body_end_position = strrpos($output, '</body>') ?: strlen($output);
$output = substr($output, 0, $body_end_position) . "\n$panel_script\n" . substr($output, $body_end_position);
return;
case 'JSON':
if (RX_POST && preg_match('/^proc/', Context::get('act')))
{
$data->ajax_module = Context::get('module');
$data->ajax_act = Context::get('act');
$_SESSION['_rx_debug_previous'] = $data;
}
else
{
unset($_SESSION['_rx_debug_previous']);
}
if (preg_match('/^(.+)\}$/', $output, $matches))
{
$output = $matches[1] . ',"_rx_debug":' . json_encode($data) . '}';
}
return;
default:
return;
}
return "<!--\r\n" . $buff . "\r\n-->";
}
// Output to a file
if($buff && __DEBUG_OUTPUT__ == 0)
{
$debug_file = _XE_PATH_ . 'files/_debug_message.php';
$buff = implode(PHP_EOL, $buff);
$buff = sprintf("[%s]\n%s", date('Y-m-d H:i:s'), print_r($buff, true));
$buff = str_repeat('=', 80) . "\n" . $buff . "\n" . str_repeat('-', 80);
$buff = "\n<?php\n/*" . $buff . "*/\n?>\n";
if (!@file_put_contents($debug_file, $buff, FILE_APPEND|LOCK_EX))
case 'comment':
case 'file':
default:
if ($display_type === 'comment' && Context::getResponseMethod() !== 'HTML')
{
return;
}
}
ob_start();
$data = Rhymix\Framework\Debug::getDebugData();
include RX_BASEDIR . 'common/tpl/debug_comment.html';
$content = ob_get_clean();
if ($display_type === 'file')
{
$log_filename = config('debug.log_filename') ?: 'files/debug/YYYYMMDD.php';
$log_filename = str_replace(array('YYYY', 'YY', 'MM', 'DD'), array(
getInternalDateTime(RX_TIME, 'Y'),
getInternalDateTime(RX_TIME, 'y'),
getInternalDateTime(RX_TIME, 'm'),
getInternalDateTime(RX_TIME, 'd'),
), $log_filename);
$log_filename = RX_BASEDIR . $log_filename;
if (!file_exists($log_filename) || !filesize($log_filename))
{
$phpheader = '<?php exit; ?>' . "\n";
}
else
{
$phpheader = '';
}
FileHandler::writeFile($log_filename, $phpheader . $content, 'a');
return '';
}
else
{
return '<!--' . PHP_EOL . $content . PHP_EOL . '-->';
}
}
}

View file

@ -86,10 +86,7 @@ class HTMLDisplayHandler
if(Context::get('layout') != 'none')
{
if(__DEBUG__ == 3)
{
$start = microtime(true);
}
$start = microtime(true);
Context::set('content', $output, false);
@ -142,10 +139,7 @@ class HTMLDisplayHandler
$pathInfo = pathinfo($layout_file);
$onlyLayoutFile = $pathInfo['filename'];
if(__DEBUG__ == 3)
{
$GLOBALS['__layout_compile_elapsed__'] = microtime(true) - $start;
}
$GLOBALS['__layout_compile_elapsed__'] = microtime(true) - $start;
if(stripos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE && (Context::get('_use_ssl') == 'optional' || Context::get('_use_ssl') == 'always'))
{
@ -168,10 +162,7 @@ class HTMLDisplayHandler
return;
}
if(__DEBUG__ == 3)
{
$start = microtime(true);
}
$start = microtime(true);
// move <style ..></style> in body to the header
$output = preg_replace_callback('!<style(.*?)>(.*?)<\/style>!is', array($this, '_moveStyleToHeader'), $output);
@ -218,10 +209,7 @@ class HTMLDisplayHandler
$output = preg_replace_callback('@<textarea[^>]*\sname="' . $keys . '".+</textarea>@isU', array(&$this, '_preserveTextAreaValue'), $output);
}
if(__DEBUG__ == 3)
{
$GLOBALS['__trans_content_elapsed__'] = microtime(true) - $start;
}
$GLOBALS['__trans_content_elapsed__'] = microtime(true) - $start;
// Remove unnecessary information
$output = preg_replace('/member\_\-([0-9]+)/s', 'member_0', $output);

View file

@ -750,7 +750,6 @@ class ModuleHandler extends Handler
$message = $oModule->getMessage();
$messageType = $oModule->getMessageType();
$redirectUrl = $oModule->getRedirectUrl();
if($messageType == 'error') debugPrint($message, 'ERROR');
if(!$procResult)
{
@ -885,10 +884,6 @@ class ModuleHandler extends Handler
if($_SESSION['XE_VALIDATOR_RETURN_URL'])
{
$display_handler = new DisplayHandler();
$display_handler->_debugOutput();
Context::getInstance()->checkSessionStatus();
header('location:' . $_SESSION['XE_VALIDATOR_RETURN_URL']);
return;
}
@ -1066,12 +1061,6 @@ class ModuleHandler extends Handler
* */
public static function getModuleInstance($module, $type = 'view', $kind = '')
{
if(__DEBUG__ == 3)
{
$start_time = microtime(true);
}
$parent_module = $module;
$kind = strtolower($kind);
$type = strtolower($type);
@ -1135,11 +1124,6 @@ class ModuleHandler extends Handler
$GLOBALS['_loaded_module'][$module][$type][$kind] = $oModule;
}
if(__DEBUG__ == 3)
{
$GLOBALS['__elapsed_class_load__'] += microtime(true) - $start_time;
}
// return the instance
return $GLOBALS['_loaded_module'][$module][$type][$kind];
}
@ -1199,11 +1183,7 @@ class ModuleHandler extends Handler
}
//store before trigger call time
$before_trigger_time = NULL;
if(__LOG_SLOW_TRIGGER__> 0)
{
$before_trigger_time = microtime(true);
}
$before_trigger_time = microtime(true);
foreach($triggers as $item)
{
@ -1219,17 +1199,20 @@ class ModuleHandler extends Handler
}
$before_each_trigger_time = microtime(true);
$output = $oModule->{$called_method}($obj);
$after_each_trigger_time = microtime(true);
$elapsed_time_trigger = $after_each_trigger_time - $before_each_trigger_time;
$slowlog = new stdClass;
$slowlog->caller = $trigger_name . '.' . $called_position;
$slowlog->called = $module . '.' . $called_method;
$slowlog->called_extension = $module;
if($trigger_name != 'XE.writeSlowlog') writeSlowlog('trigger', $elapsed_time_trigger, $slowlog);
if ($trigger_name !== 'common.flushDebugInfo')
{
$trigger_target = $module . ($type === 'class' ? '' : $type) . '.' . $called_method;
Rhymix\Framework\Debug::addTrigger(array(
'name' => $trigger_name . '.' . $called_position,
'target' => $trigger_target,
'target_plugin' => $module,
'elapsed_time' => $after_each_trigger_time - $before_each_trigger_time,
));
}
if(is_object($output) && method_exists($output, 'toBool') && !$output->toBool())
{
@ -1241,7 +1224,39 @@ class ModuleHandler extends Handler
$trigger_functions = $oModuleModel->getTriggerFunctions($trigger_name, $called_position);
foreach($trigger_functions as $item)
{
$before_each_trigger_time = microtime(true);
$item($obj);
$after_each_trigger_time = microtime(true);
if ($trigger_name !== 'common.writeSlowlog')
{
if (is_string($item))
{
$trigger_target = $item;
}
elseif (is_array($item) && count($item))
{
if (is_object($item[0]))
{
$trigger_target = get_class($item[0]) . '.' . strval($item[1]);
}
else
{
$trigger_target = implode('.', $item);
}
}
else
{
$trigger_target = 'closure';
}
Rhymix\Framework\Debug::addTrigger(array(
'name' => $trigger_name . '.' . $called_position,
'target' => $trigger_target,
'target_plugin' => null,
'elapsed_time' => $after_each_trigger_time - $before_each_trigger_time,
));
}
if(is_object($output) && method_exists($output, 'toBool') && !$output->toBool())
{

View file

@ -384,7 +384,6 @@ class ModuleObject extends Object
// pass if stop_proc is true
if($this->stop_proc)
{
debugPrint($this->message, 'ERROR');
return FALSE;
}

View file

@ -42,16 +42,13 @@ class TemplateHandler
{
static $oTemplate = NULL;
if(__DEBUG__ == 3)
if(!isset($GLOBALS['__TemplateHandlerCalled__']))
{
if(!isset($GLOBALS['__TemplateHandlerCalled__']))
{
$GLOBALS['__TemplateHandlerCalled__'] = 1;
}
else
{
$GLOBALS['__TemplateHandlerCalled__']++;
}
$GLOBALS['__TemplateHandlerCalled__'] = 1;
}
else
{
$GLOBALS['__TemplateHandlerCalled__']++;
}
if(!$oTemplate)
@ -118,10 +115,7 @@ class TemplateHandler
public function compile($tpl_path, $tpl_filename, $tpl_file = '')
{
// store the starting time for debug information
if(__DEBUG__ == 3)
{
$start = microtime(true);
}
$start = microtime(true);
// initiation
$this->init($tpl_path, $tpl_filename, $tpl_file);
@ -155,10 +149,7 @@ class TemplateHandler
}
// store the ending time for debug information
if(__DEBUG__ == 3)
{
$GLOBALS['__template_elapsed__'] += microtime(true) - $start;
}
$GLOBALS['__template_elapsed__'] += microtime(true) - $start;
return $output;
}

View file

@ -89,10 +89,7 @@ class XmlParser
function parse($input = '', $arg1 = NULL, $arg2 = NULL)
{
// Save the compile starting time for debugging
if(__DEBUG__ == 3)
{
$start = microtime(true);
}
$start = microtime(true);
$this->lang = Context::getLangType();
@ -141,10 +138,7 @@ class XmlParser
$output = array_shift($this->output);
// Save compile starting time for debugging
if(__DEBUG__ == 3)
{
$GLOBALS['__xmlparse_elapsed__'] += microtime(true) - $start;
}
$GLOBALS['__xmlparse_elapsed__'] += microtime(true) - $start;
return $output;
}