mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-03 16:51:40 +09:00
Merge branch 'editor-dark' into pr/editor-dark-mode
This commit is contained in:
commit
e725455a0e
17 changed files with 212 additions and 87 deletions
|
|
@ -175,7 +175,7 @@ class DisplayHandler extends Handler
|
|||
}
|
||||
|
||||
// Check if debugging is enabled for this request.
|
||||
if (!config('debug.enabled') || !Rhymix\Framework\Debug::isEnabledForCurrentUser())
|
||||
if (!Rhymix\Framework\Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -273,10 +273,12 @@ class HTMLDisplayHandler
|
|||
$oModuleController->replaceDefinedLangCode($output);
|
||||
|
||||
// remove template path comment tag
|
||||
/*
|
||||
if(!Rhymix\Framework\Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
$output = preg_replace('/\n<!-- Template (?:start|end) : .*? -->\r?\n/', "\n", $output);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -344,29 +344,32 @@ class FileHandler
|
|||
$log['status'] = $response ? $response->status_code : 0;
|
||||
$log['elapsed_time'] = $elapsed_time;
|
||||
|
||||
if (config('debug.enabled') && in_array('slow_remote_requests', config('debug.display_content')))
|
||||
if (Rhymix\Framework\Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
$bt = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
foreach($bt as $no => $call)
|
||||
if (in_array('slow_remote_requests', config('debug.display_content')))
|
||||
{
|
||||
if(strncasecmp($call['function'], 'getRemote', 9) === 0)
|
||||
$bt = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
foreach($bt as $no => $call)
|
||||
{
|
||||
$call_no = $no + 1;
|
||||
$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;
|
||||
if(strncasecmp($call['function'], 'getRemote', 9) === 0)
|
||||
{
|
||||
$call_no = $no + 1;
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$log['called_file'] = $log['called_line'] = $log['called_method'] = null;
|
||||
$log['backtrace'] = array();
|
||||
}
|
||||
Rhymix\Framework\Debug::addRemoteRequest($log);
|
||||
}
|
||||
else
|
||||
{
|
||||
$log['called_file'] = $log['called_line'] = $log['called_method'] = null;
|
||||
$log['backtrace'] = array();
|
||||
}
|
||||
Rhymix\Framework\Debug::addRemoteRequest($log);
|
||||
|
||||
foreach($response->cookies as $cookie)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1229,12 +1229,15 @@ class ModuleHandler extends Handler
|
|||
{
|
||||
$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 (Rhymix\Framework\Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
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($output instanceof BaseObject && !$output->toBool())
|
||||
|
|
@ -1280,12 +1283,15 @@ class ModuleHandler extends Handler
|
|||
$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 (Rhymix\Framework\Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
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())
|
||||
|
|
|
|||
|
|
@ -437,6 +437,7 @@ class DB
|
|||
|
||||
// Compose the output object.
|
||||
$output = new \BaseObject;
|
||||
$output->add('_count', $query_string);
|
||||
$output->total_count = $total_count;
|
||||
$output->total_page = $total_page;
|
||||
$output->page = $page;
|
||||
|
|
@ -529,7 +530,11 @@ class DB
|
|||
{
|
||||
$this->setError(-1, $e->getMessage());
|
||||
}
|
||||
Debug::addQuery($this->getQueryLog('START TRANSACTION', 0));
|
||||
|
||||
if (Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
Debug::addQuery($this->getQueryLog('START TRANSACTION', 0));
|
||||
}
|
||||
}
|
||||
$this->_transaction_level++;
|
||||
return $this->_transaction_level;
|
||||
|
|
@ -553,7 +558,11 @@ class DB
|
|||
{
|
||||
$this->setError(-1, $e->getMessage());
|
||||
}
|
||||
Debug::addQuery($this->getQueryLog('ROLLBACK', 0));
|
||||
|
||||
if (Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
Debug::addQuery($this->getQueryLog('ROLLBACK', 0));
|
||||
}
|
||||
}
|
||||
$this->_transaction_level--;
|
||||
return $this->_transaction_level;
|
||||
|
|
@ -577,7 +586,11 @@ class DB
|
|||
{
|
||||
$this->setError(-1, $e->getMessage());
|
||||
}
|
||||
Debug::addQuery($this->getQueryLog('COMMIT', 0));
|
||||
|
||||
if (Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
Debug::addQuery($this->getQueryLog('COMMIT', 0));
|
||||
}
|
||||
}
|
||||
$this->_transaction_level--;
|
||||
return $this->_transaction_level;
|
||||
|
|
@ -1059,12 +1072,7 @@ class DB
|
|||
public function getQueryLog(string $query, float $elapsed_time): array
|
||||
{
|
||||
// Cache the debug status to improve performance.
|
||||
static $debug_enabled = null;
|
||||
static $debug_queries = null;
|
||||
if ($debug_enabled === null)
|
||||
{
|
||||
$debug_enabled = Config::get('debug.enabled');
|
||||
}
|
||||
if ($debug_queries === null)
|
||||
{
|
||||
$debug_queries = in_array('queries', Config::get('debug.display_content') ?: []);
|
||||
|
|
@ -1086,7 +1094,7 @@ class DB
|
|||
);
|
||||
|
||||
// Add debug information if enabled.
|
||||
if ($debug_enabled && ($this->_errno || $debug_queries))
|
||||
if ($this->_errno || $debug_queries)
|
||||
{
|
||||
$backtrace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
foreach ($backtrace as $no => $call)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ class Debug
|
|||
/**
|
||||
* Store log entries here.
|
||||
*/
|
||||
protected static $_enabled = true;
|
||||
protected static $_enabled = null;
|
||||
protected static $_config = array();
|
||||
protected static $_aliases = array();
|
||||
protected static $_entries = array();
|
||||
protected static $_errors = array();
|
||||
|
|
@ -286,7 +287,7 @@ class Debug
|
|||
self::$_entries[] = $entry;
|
||||
|
||||
// Add the entry to the error log.
|
||||
if (config('debug.write_error_log') === 'all' && self::isEnabledForCurrentUser())
|
||||
if (self::$_config['write_error_log'] === 'all')
|
||||
{
|
||||
$log_entry = str_replace("\0", '', sprintf('Rhymix Debug: %s in %s on line %d',
|
||||
var_export($message, true), $entry->file, $entry->line));
|
||||
|
|
@ -341,7 +342,7 @@ class Debug
|
|||
);
|
||||
|
||||
// Add the entry to the error log.
|
||||
if (config('debug.write_error_log') === 'all')
|
||||
if (self::$_config['write_error_log'] === 'all')
|
||||
{
|
||||
$log_entry = strtr(sprintf('PHP %s: %s in %s on line %d', $errinfo->type, $errstr, $errfile, intval($errline)), "\0\r\n\t\v\e\f", ' ');
|
||||
error_log($log_entry . \PHP_EOL . self::formatBacktrace($backtrace));
|
||||
|
|
@ -394,7 +395,7 @@ class Debug
|
|||
|
||||
self::$_errors[] = $error_object;
|
||||
|
||||
if (config('debug.write_error_log') === 'all')
|
||||
if (self::$_config['write_error_log'] === 'all')
|
||||
{
|
||||
$log_entry = strtr(sprintf('Query Error: %s in %s on line %d', $error_object->message, $error_object->file, intval($error_object->line)), "\0\r\n\t\v\e\f", ' ');
|
||||
error_log($log_entry . \PHP_EOL . self::formatBacktrace($error_object->backtrace));
|
||||
|
|
@ -402,7 +403,7 @@ class Debug
|
|||
}
|
||||
|
||||
// Add the entry to the slow query log.
|
||||
if ($query_object->query_time && $query_object->query_time >= config('debug.log_slow_queries'))
|
||||
if ($query_object->query_time && $query_object->query_time >= self::$_config['log_slow_queries'])
|
||||
{
|
||||
self::$_slow_queries[] = $query_object;
|
||||
}
|
||||
|
|
@ -436,7 +437,7 @@ class Debug
|
|||
);
|
||||
|
||||
self::$_triggers[] = $trigger_object;
|
||||
if ($trigger_object->trigger_time && $trigger_object->trigger_time >= config('debug.log_slow_triggers'))
|
||||
if ($trigger_object->trigger_time && $trigger_object->trigger_time >= self::$_config['log_slow_triggers'])
|
||||
{
|
||||
self::$_slow_triggers[] = $trigger_object;
|
||||
}
|
||||
|
|
@ -468,7 +469,7 @@ class Debug
|
|||
);
|
||||
|
||||
self::$_widgets[] = $widget_object;
|
||||
if ($widget_object->widget_time && $widget_object->widget_time >= config('debug.log_slow_widgets'))
|
||||
if ($widget_object->widget_time && $widget_object->widget_time >= self::$_config['log_slow_widgets'])
|
||||
{
|
||||
self::$_slow_widgets[] = $widget_object;
|
||||
}
|
||||
|
|
@ -502,7 +503,7 @@ class Debug
|
|||
);
|
||||
|
||||
self::$_remote_requests[] = $request_object;
|
||||
if ($request_object->elapsed_time && $request_object->elapsed_time >= config('debug.log_slow_remote_requests'))
|
||||
if ($request_object->elapsed_time && $request_object->elapsed_time >= self::$_config['log_slow_remote_requests'])
|
||||
{
|
||||
self::$_slow_remote_requests[] = $request_object;
|
||||
}
|
||||
|
|
@ -549,7 +550,7 @@ class Debug
|
|||
$log_entry = str_replace("\0", '', sprintf('%s #%d "%s" in %s on line %d',
|
||||
get_class($e), $e->getCode(), $e->getMessage(), $errfile, $e->getLine()));
|
||||
}
|
||||
if (config('debug.write_error_log') !== 'none')
|
||||
if (self::$_config['write_error_log'] !== 'none')
|
||||
{
|
||||
error_log('PHP Exception: ' . $log_entry . \PHP_EOL . self::formatBacktrace($e->getTrace()));
|
||||
}
|
||||
|
|
@ -579,7 +580,7 @@ class Debug
|
|||
// Add the entry to the error log.
|
||||
$message = sprintf('%s in %s on line %d', $errinfo['message'], $errinfo['file'], intval($errinfo['line']));
|
||||
$log_entry = str_replace("\0", '', 'PHP ' . self::getErrorType($errinfo['type']) . ': ' . $message);
|
||||
if (config('debug.write_error_log') !== 'none')
|
||||
if (self::$_config['write_error_log'] !== 'none')
|
||||
{
|
||||
error_log($log_entry);
|
||||
}
|
||||
|
|
@ -633,6 +634,7 @@ class Debug
|
|||
*/
|
||||
public static function registerErrorHandlers($error_types)
|
||||
{
|
||||
self::$_config = config('debug');
|
||||
set_error_handler('\\Rhymix\\Framework\\Debug::addError', $error_types);
|
||||
set_exception_handler('\\Rhymix\\Framework\\Debug::exceptionHandler');
|
||||
register_shutdown_function('\\Rhymix\\Framework\\Debug::shutdownHandler');
|
||||
|
|
@ -712,45 +714,43 @@ class Debug
|
|||
*/
|
||||
public static function isEnabledForCurrentUser()
|
||||
{
|
||||
static $cache = null;
|
||||
if ($cache !== null)
|
||||
if (self::$_enabled !== null)
|
||||
{
|
||||
return $cache;
|
||||
return self::$_enabled;
|
||||
}
|
||||
if (!Config::get('debug.enabled'))
|
||||
if (!self::$_config['enabled'])
|
||||
{
|
||||
return $cache = false;
|
||||
return self::$_enabled = false;
|
||||
}
|
||||
|
||||
$display_to = Config::get('debug.display_to');
|
||||
switch ($display_to)
|
||||
switch (self::$_config['display_to'])
|
||||
{
|
||||
case 'everyone':
|
||||
return $cache = true;
|
||||
return self::$_enabled = true;
|
||||
|
||||
case 'ip':
|
||||
if (Filters\IpFilter::inRanges(\RX_CLIENT_IP, Config::get('debug.allow')))
|
||||
if (Filters\IpFilter::inRanges(\RX_CLIENT_IP, self::$_config['allow']))
|
||||
{
|
||||
return $cache = true;
|
||||
return self::$_enabled = true;
|
||||
}
|
||||
if (\RX_CLIENT_IP === '127.0.0.1' || \RX_CLIENT_IP === '::1')
|
||||
{
|
||||
return $cache = true;
|
||||
return self::$_enabled = true;
|
||||
}
|
||||
if (\RX_CLIENT_IP === $_SERVER['SERVER_ADDR'] || \RX_CLIENT_IP === $_SERVER['LOCAL_ADDR'])
|
||||
{
|
||||
return $cache = true;
|
||||
return self::$_enabled = true;
|
||||
}
|
||||
return $cache = false;
|
||||
return self::$_enabled = false;
|
||||
|
||||
case 'admin':
|
||||
default:
|
||||
$logged_info = \Context::get('logged_info');
|
||||
if ($logged_info && $logged_info->is_admin === 'Y')
|
||||
{
|
||||
return $cache = true;
|
||||
return self::$_enabled = true;
|
||||
}
|
||||
return $cache = false;
|
||||
return self::$_enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,10 @@ class DBHelper extends \PDO
|
|||
$elapsed_time = microtime(true) - $start_time;
|
||||
$db_class->addElapsedTime($elapsed_time);
|
||||
$db_class->setError(-1, $e->getMessage());
|
||||
Debug::addQuery($db_class->getQueryLog($statement, $elapsed_time));
|
||||
if (Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
Debug::addQuery($db_class->getQueryLog($statement, $elapsed_time));
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a new feature in Rhymix 2.0 so we don't have to mess
|
||||
|
|
@ -110,7 +113,10 @@ class DBHelper extends \PDO
|
|||
{
|
||||
$elapsed_time = microtime(true) - $start_time;
|
||||
$db_class->addElapsedTime($elapsed_time);
|
||||
Debug::addQuery($db_class->getQueryLog($statement, $elapsed_time));
|
||||
if (Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
Debug::addQuery($db_class->getQueryLog($statement, $elapsed_time));
|
||||
}
|
||||
}
|
||||
|
||||
return $stmt;
|
||||
|
|
@ -140,7 +146,10 @@ class DBHelper extends \PDO
|
|||
{
|
||||
$elapsed_time = microtime(true) - $start_time;
|
||||
$db_class->addElapsedTime($elapsed_time);
|
||||
Debug::addQuery($db_class->getQueryLog($query, $elapsed_time));
|
||||
if (Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
Debug::addQuery($db_class->getQueryLog($query, $elapsed_time));
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,10 @@ class DBStmtHelper extends \PDOStatement
|
|||
{
|
||||
$elapsed_time = microtime(true) - $start_time;
|
||||
$db_class->addElapsedTime($elapsed_time);
|
||||
Debug::addQuery($db_class->getQueryLog($this->queryString, $elapsed_time));
|
||||
if (Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
Debug::addQuery($db_class->getQueryLog($this->queryString, $elapsed_time));
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
|
|||
|
|
@ -116,26 +116,18 @@ class Query extends VariableBase
|
|||
protected function _getSelectQueryString(bool $count_only = false): string
|
||||
{
|
||||
// Initialize the query string.
|
||||
$result = 'SELECT ';
|
||||
if ($this->select_distinct)
|
||||
{
|
||||
$result .= 'DISTINCT ';
|
||||
}
|
||||
$result = 'SELECT';
|
||||
|
||||
// Compose the column list.
|
||||
$columns = array();
|
||||
if ($count_only)
|
||||
if ($this->_column_list)
|
||||
{
|
||||
$result .= 'COUNT(*) AS `count`';
|
||||
}
|
||||
elseif ($this->_column_list)
|
||||
{
|
||||
$result .= implode(', ', array_map(function($str) {
|
||||
$column_list = implode(', ', array_map(function($str) {
|
||||
return self::quoteName($str);
|
||||
}, $this->_column_list));
|
||||
}
|
||||
else
|
||||
{
|
||||
$columns = array();
|
||||
foreach ($this->columns as $column)
|
||||
{
|
||||
if ($column instanceof self)
|
||||
|
|
@ -156,7 +148,33 @@ class Query extends VariableBase
|
|||
$columns[] = self::quoteName($column->name) . ($column->alias ? (' AS ' . self::quoteName($column->alias)) : '');
|
||||
}
|
||||
}
|
||||
$result .= implode(', ', $columns);
|
||||
$column_list = implode(', ', $columns);
|
||||
}
|
||||
|
||||
// Replace the column list if this is a count-only query.
|
||||
if ($count_only)
|
||||
{
|
||||
$count_wrap = ($this->groupby || $this->select_distinct || preg_match('/\bDISTINCT\b/i', $column_list));
|
||||
if ($count_wrap)
|
||||
{
|
||||
if ($column_list === '*' || preg_match('/\\.\\*/', $column_list))
|
||||
{
|
||||
$result .= ' 1';
|
||||
}
|
||||
else
|
||||
{
|
||||
$result .= ($this->select_distinct ? ' DISTINCT ' : ' ') . $column_list;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result .= ' COUNT(*) AS `count`';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$count_wrap = false;
|
||||
$result .= ($this->select_distinct ? ' DISTINCT ' : ' ') . $column_list;
|
||||
}
|
||||
|
||||
// Compose the FROM clause.
|
||||
|
|
@ -225,6 +243,12 @@ class Query extends VariableBase
|
|||
$result .= ' LIMIT ' . $this->_arrangeLimitOffset($this->navigation);
|
||||
}
|
||||
|
||||
// Wrap in a subquery if necesary.
|
||||
if ($count_wrap)
|
||||
{
|
||||
$result = 'SELECT COUNT(*) AS `count` FROM (' . $result . ') AS `subquery`';
|
||||
}
|
||||
|
||||
// Return the final query string.
|
||||
return $result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ class addonController extends addon
|
|||
$buff[] = 'if ($run && file_exists($addon_file)):';
|
||||
$buff[] = ' include($addon_file);';
|
||||
$buff[] = ' $after_time = microtime(true);';
|
||||
$buff[] = ' if (class_exists("Rhymix\\\\Framework\\\\Debug")):';
|
||||
$buff[] = ' if (class_exists("Rhymix\\\\Framework\\\\Debug") && Rhymix\\Framework\\Debug::isEnabledForCurrentUser()):';
|
||||
$buff[] = ' Rhymix\\Framework\\Debug::addTrigger(array(';
|
||||
$buff[] = ' "name" => "addon." . $called_position,';
|
||||
$buff[] = ' "target" => "' . $addon . '",';
|
||||
|
|
|
|||
|
|
@ -32,6 +32,27 @@
|
|||
margin: 0 0 @content_paragraph_spacing 0;
|
||||
}
|
||||
|
||||
/* if editor_auto_dark_mode == 'Y' load darkmode style */
|
||||
.auto_dark(@cs, @adm) when (@adm = Y) and not (@cs = moono-dark) {
|
||||
html {
|
||||
body.cke_editable {
|
||||
.light_dark(moono-dark);
|
||||
}
|
||||
}
|
||||
.cke_reset {
|
||||
span {
|
||||
&.cke_top {
|
||||
.light_dark_top(moono-dark);
|
||||
}
|
||||
}
|
||||
}
|
||||
.cke_button_icon, .cke_combo_button, .cke_button_arrow, .cke_button_label {
|
||||
filter: invert(1);
|
||||
}
|
||||
}
|
||||
.auto_dark(@cs, @adm) when not (@adm = Y) or (@cs = moono-dark) {
|
||||
}
|
||||
|
||||
.light_dark(@cs) when (@cs = moono-dark) {
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
{@ $css_var->content_line_height = $content_line_height ? $content_line_height: 'none';}
|
||||
{@ $css_var->content_word_break = $content_word_break ? $content_word_break : 'none';}
|
||||
{@ $css_var->content_paragraph_spacing = $content_paragraph_spacing ? $content_paragraph_spacing : 'none';}
|
||||
{@ $css_var->auto_dark_mode = ($editor_auto_dark_mode)? 'Y':'N' }
|
||||
|
||||
{@ Context::set('css_var',$css_var);}
|
||||
<load target="css/default.less" vars="$css_var" />
|
||||
|
|
|
|||
|
|
@ -652,11 +652,14 @@ class widgetController extends widget
|
|||
$GLOBALS['__widget_excute_elapsed__'] = 0;
|
||||
}
|
||||
$GLOBALS['__widget_excute_elapsed__'] += $elapsed_time;
|
||||
Rhymix\Framework\Debug::addWidget(array(
|
||||
'name' => $widget,
|
||||
'elapsed_time' => $elapsed_time,
|
||||
));
|
||||
|
||||
if (Rhymix\Framework\Debug::isEnabledForCurrentUser())
|
||||
{
|
||||
Rhymix\Framework\Debug::addWidget(array(
|
||||
'name' => $widget,
|
||||
'elapsed_time' => $elapsed_time,
|
||||
));
|
||||
}
|
||||
|
||||
// Return result
|
||||
return $output;
|
||||
}
|
||||
|
|
|
|||
19
tests/_data/dbquery/selectCountTest1.xml
Normal file
19
tests/_data/dbquery/selectCountTest1.xml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<query id="selectCountTest1" action="select">
|
||||
<tables>
|
||||
<table name="documents" />
|
||||
<table name="member" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="member.*" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="documents.member_srl" default="member.member_srl" />
|
||||
<condition operation="in" column="documents.document_srl" var="document_srl_list" pipe="and" />
|
||||
</conditions>
|
||||
<groups>
|
||||
<group column="member.member_srl" />
|
||||
<having>
|
||||
<condition operation="notequal" column="member.member_srl" var="exclude_member_srl" notnull="notnull" />
|
||||
</having>
|
||||
</groups>
|
||||
</query>
|
||||
11
tests/_data/dbquery/selectCountTest2.xml
Normal file
11
tests/_data/dbquery/selectCountTest2.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<query id="selectCountTest2" action="select">
|
||||
<tables>
|
||||
<table name="documents" />
|
||||
</tables>
|
||||
<columns distinct="true">
|
||||
<column name="module_srl" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="in" column="document_srl" var="document_srl_list" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
@ -6,6 +6,7 @@ class DebugTest extends \Codeception\TestCase\Test
|
|||
|
||||
public function _before()
|
||||
{
|
||||
Rhymix\Framework\Debug::enable();
|
||||
$this->error_log = ini_get('error_log');
|
||||
ini_set('error_log', '/dev/null');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -259,6 +259,20 @@ class DBQueryParserTest extends \Codeception\TestCase\Test
|
|||
$this->assertEquals(['Y'], $params);
|
||||
}
|
||||
|
||||
public function testCountQuery()
|
||||
{
|
||||
$query = Rhymix\Framework\Parsers\DBQueryParser::loadXML(\RX_BASEDIR . 'tests/_data/dbquery/selectCountTest1.xml');
|
||||
$sql = $query->getQueryString('rx_', ['exclude_member_srl' => 4], [], true);
|
||||
$this->assertEquals('SELECT COUNT(*) AS `count` FROM (SELECT 1 FROM `rx_documents` AS `documents`, `rx_member` AS `member` ' .
|
||||
'WHERE `documents`.`member_srl` = `member`.`member_srl` GROUP BY `member`.`member_srl` HAVING `member`.`member_srl` != ?) ' .
|
||||
'AS `subquery`', $sql);
|
||||
|
||||
$query = Rhymix\Framework\Parsers\DBQueryParser::loadXML(\RX_BASEDIR . 'tests/_data/dbquery/selectCountTest2.xml');
|
||||
$sql = $query->getQueryString('rx_', ['document_srl_list' => [100, 110, 120]], [], true);
|
||||
$this->assertEquals('SELECT COUNT(*) AS `count` FROM (SELECT DISTINCT `module_srl` FROM `rx_documents` AS `documents` ' .
|
||||
'WHERE `document_srl` IN (?, ?, ?)) AS `subquery`', $sql);
|
||||
}
|
||||
|
||||
public function testInsertQuery()
|
||||
{
|
||||
$query = Rhymix\Framework\Parsers\DBQueryParser::loadXML(\RX_BASEDIR . 'tests/_data/dbquery/insertTest.xml');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue