More fixes to improve PHP 8.0 compatibility

This commit is contained in:
Kijin Sung 2020-10-31 00:40:28 +09:00
parent 8c161bc28d
commit 417e4d15b0
9 changed files with 41 additions and 30 deletions

View file

@ -141,7 +141,7 @@ class DisplayHandler extends Handler
ModuleHandler::triggerCall('display', 'after', $output);
// Output the page content and debug data.
$debug = $this->getDebugInfo($output);
$debug = self::getDebugInfo($output);
print $output;
print $debug;
}
@ -151,7 +151,7 @@ class DisplayHandler extends Handler
*
* @return string
*/
public function getDebugInfo(&$output = null)
public static function getDebugInfo(&$output = null)
{
// Check if debugging information has already been printed.

View file

@ -333,6 +333,10 @@ class FileHandler
$start_time = microtime(true);
$response = Requests::request($url, $request_headers, $body ?: $post_data, $method, $request_options);
$elapsed_time = microtime(true) - $start_time;
if (!isset($GLOBALS['__remote_request_elapsed__']))
{
$GLOBALS['__remote_request_elapsed__'] = 0;
}
$GLOBALS['__remote_request_elapsed__'] += $elapsed_time;
$log = array();

View file

@ -99,7 +99,7 @@ class FrontEndFileHandler extends Handler
$isCommon = preg_match(HTMLDisplayHandler::$reservedCSS, $args[0]) || preg_match(HTMLDisplayHandler::$reservedJS, $args[0]);
// Prevent overwriting common scripts.
if(intval($args[3]) > -1500000000)
if(isset($args[3]) && intval($args[3]) > -1500000000)
{
if($isCommon)
{
@ -114,8 +114,8 @@ class FrontEndFileHandler extends Handler
}
}
$file = $this->getFileInfo($args[0], $args[2], $args[1], $args[4], $isCommon);
$file->index = (int)$args[3];
$file = $this->getFileInfo($args[0], $args[2] ?? '', $args[1] ?? 'all', $args[4] ?? [], $isCommon);
$file->index = (int)($args[3] ?? 0);
$availableExtension = array('css' => 1, 'js' => 1, 'less' => 1, 'scss' => 1);
if(!isset($availableExtension[$file->fileExtension]))
@ -132,7 +132,7 @@ class FrontEndFileHandler extends Handler
}
else if($file->fileExtension == 'js')
{
if($args[1] == 'body')
if(isset($args[1]) && $args[1] == 'body')
{
$map = &$this->jsBodyMap;
$mapIndex = &$this->jsBodyMapIndex;
@ -164,12 +164,6 @@ class FrontEndFileHandler extends Handler
*/
protected function getFileInfo($fileName, $targetIe = '', $media = 'all', $vars = array(), $isCommon = false)
{
static $existsInfo = array();
if(isset($existsInfo[$existsKey]))
{
return $existsInfo[$existsKey];
}
$pathInfo = pathinfo($fileName);
$file = new stdClass();

View file

@ -19,6 +19,7 @@ class ModuleHandler extends Handler
var $act = null;
var $mid = null;
var $document_srl = null;
var $entry = null;
var $route = null;
var $error = null;
var $is_mobile = false;

View file

@ -167,6 +167,10 @@ class TemplateHandler
}
// store the ending time for debug information
if (!isset($GLOBALS['__template_elapsed__']))
{
$GLOBALS['__template_elapsed__'] = 0;
}
$GLOBALS['__template_elapsed__'] += microtime(true) - $start;
return $output;

View file

@ -138,6 +138,10 @@ class XeXmlParser
$output = array_shift($this->output);
// Save compile starting time for debugging
if (!isset($GLOBALS['__xmlparse_elapsed__']))
{
$GLOBALS['__xmlparse_elapsed__'] = 0;
}
$GLOBALS['__xmlparse_elapsed__'] += microtime(true) - $start;
return $output;

View file

@ -768,7 +768,7 @@ class Debug
'url' => getCurrentPageUrl(),
'request' => (object)array(
'method' => $_SERVER['REQUEST_METHOD'] . ($_SERVER['REQUEST_METHOD'] !== \Context::getRequestMethod() ? (' (' . \Context::getRequestMethod() . ')') : ''),
'size' => intval($_SERVER['CONTENT_LENGTH']),
'size' => intval($_SERVER['CONTENT_LENGTH'] ?? 0),
),
'response' => (object)array(
'method' => \Context::getResponseMethod(),
@ -776,15 +776,15 @@ class Debug
),
'timing' => (object)array(
'total' => sprintf('%0.4f sec', microtime(true) - \RX_MICROTIME),
'template' => sprintf('%0.4f sec (count: %d)', $GLOBALS['__template_elapsed__'], $GLOBALS['__TemplateHandlerCalled__']),
'xmlparse' => sprintf('%0.4f sec', $GLOBALS['__xmlparse_elapsed__']),
'template' => sprintf('%0.4f sec (count: %d)', $GLOBALS['__template_elapsed__'] ?? 0, $GLOBALS['__TemplateHandlerCalled__'] ?? 0),
'xmlparse' => sprintf('%0.4f sec', $GLOBALS['__xmlparse_elapsed__'] ?? 0),
'db_query' => sprintf('%0.4f sec (count: %d)', self::$_query_time, count(self::$_queries)),
'db_class' => sprintf('%0.4f sec', max(0, $db->getTotalElapsedTime() - self::$_query_time)),
'session' => sprintf('%0.4f sec', self::$_session_time),
'layout' => sprintf('%0.4f sec', $GLOBALS['__layout_compile_elapsed__']),
'widget' => sprintf('%0.4f sec', $GLOBALS['__widget_excute_elapsed__']),
'remote' => sprintf('%0.4f sec', $GLOBALS['__remote_request_elapsed__']),
'trans' => sprintf('%0.4f sec', $GLOBALS['__trans_content_elapsed__']),
'layout' => sprintf('%0.4f sec', $GLOBALS['__layout_compile_elapsed__'] ?? 0),
'widget' => sprintf('%0.4f sec', $GLOBALS['__widget_excute_elapsed__'] ?? 0),
'remote' => sprintf('%0.4f sec', $GLOBALS['__remote_request_elapsed__'] ?? 0),
'trans' => sprintf('%0.4f sec', $GLOBALS['__trans_content_elapsed__'] ?? 0),
),
'entries' => self::$_entries,
'errors' => self::$_errors,

View file

@ -50,8 +50,8 @@ class DBQueryParser extends BaseParser
// Load attributes that only apply to subqueries in the <conditions> block.
$query->operation = $attribs['operation'] ?? null;
$query->column = preg_replace('/[^a-z0-9_\.]/i', '', $attribs['column']) ?: null;
$query->pipe = strtoupper($attribs['pipe']) ?: 'AND';
$query->column = preg_replace('/[^a-z0-9_\.]/i', '', $attribs['column'] ?? null) ?: null;
$query->pipe = strtoupper($attribs['pipe'] ?? null) ?: 'AND';
// Load tables.
foreach ($xml->tables ? $xml->tables->children() : [] as $tag)
@ -108,13 +108,13 @@ class DBQueryParser extends BaseParser
$attribs = self::_getAttributes($tag);
$column = new DBQuery\ColumnWrite;
$column->name = $attribs['name'];
$column->operation = $attribs['operation'] ?: 'equal';
$column->operation = ($attribs['operation'] ?? null) ?: 'equal';
$column->var = $attribs['var'] ?? null;
$column->default = $attribs['default'] ?? null;
$column->not_null = $attribs['notnull'] ? true : false;
$column->not_null = ($attribs['notnull'] ?? false) ? true : false;
$column->filter = $attribs['filter'] ?? null;
$column->minlength = intval($attribs['minlength'], 10);
$column->maxlength = intval($attribs['maxlength'], 10);
$column->minlength = intval($attribs['minlength'] ?? 0, 10);
$column->maxlength = intval($attribs['maxlength'] ?? 0, 10);
$query->columns[] = $column;
}
}
@ -225,18 +225,18 @@ class DBQueryParser extends BaseParser
$cond->var = $attribs['var'] ?? null;
$cond->default = $attribs['default'] ?? null;
}
$cond->not_null = $attribs['notnull'] ? true : false;
$cond->not_null = ($attribs['notnull'] ?? false) ? true : false;
$cond->filter = $attribs['filter'] ?? null;
$cond->minlength = intval($attribs['minlength'], 10);
$cond->maxlength = intval($attribs['maxlength'], 10);
$cond->pipe = strtoupper($attribs['pipe']) ?: 'AND';
$cond->minlength = intval($attribs['minlength'] ?? 0, 10);
$cond->maxlength = intval($attribs['maxlength'] ?? 0, 10);
$cond->pipe = strtoupper($attribs['pipe'] ?? null) ?: 'AND';
$result[] = $cond;
}
elseif ($name === 'group')
{
$group = new DBQuery\ConditionGroup;
$group->conditions = self::_parseConditions($tag);
$group->pipe = strtoupper($attribs['pipe']) ?: 'AND';
$group->pipe = strtoupper($attribs['pipe'] ?? null) ?: 'AND';
$result[] = $group;
}
elseif ($name === 'query')

View file

@ -647,6 +647,10 @@ class widgetController extends widget
// Debug widget creation time information added to the results
$elapsed_time = microtime(true) - $start;
if (!isset($GLOBALS['__widget_excute_elapsed__']))
{
$GLOBALS['__widget_excute_elapsed__'] = 0;
}
$GLOBALS['__widget_excute_elapsed__'] += $elapsed_time;
Rhymix\Framework\Debug::addWidget(array(
'name' => $widget,