mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-03 16:51:40 +09:00
Fix error handling issues
This commit is contained in:
parent
936568a8a5
commit
978d3d167a
4 changed files with 37 additions and 12 deletions
|
|
@ -305,7 +305,20 @@ class DB
|
|||
{
|
||||
$this->_last_stmt = $this->_handle->query($query_string);
|
||||
}
|
||||
$result = $this->_fetch($this->_last_stmt, $last_index);
|
||||
|
||||
if ($this->isError())
|
||||
{
|
||||
$output = $this->getError();
|
||||
$output->add('_query', $query_string);
|
||||
$output->add('_elapsed_time', '0.00000');
|
||||
$output->page_navigation = new \PageHandler(0, 0, 0);
|
||||
$this->_total_time += (microtime(true) - $start_time);
|
||||
return $output;
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->_fetch($this->_last_stmt, $last_index);
|
||||
}
|
||||
}
|
||||
catch (Exceptions\DBError $e)
|
||||
{
|
||||
|
|
@ -361,7 +374,15 @@ class DB
|
|||
{
|
||||
$this->_last_stmt = $this->_handle->query($query_string);
|
||||
}
|
||||
$result = $this->_fetch($this->_last_stmt);
|
||||
|
||||
if ($this->isError())
|
||||
{
|
||||
return $this->getError();
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->_fetch($this->_last_stmt);
|
||||
}
|
||||
}
|
||||
catch (Exceptions\DBError $e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ class VariableBase
|
|||
}
|
||||
|
||||
// Check minimum and maximum lengths.
|
||||
$length = iconv_strlen($value, 'UTF-8');
|
||||
$length = is_scalar($value) ? iconv_strlen($value, 'UTF-8') : (is_countable($value) ? count($value) : 1);
|
||||
if (isset($this->minlength) && $this->minlength > 0 && $length < $this->minlength)
|
||||
{
|
||||
throw new \Rhymix\Framework\Exceptions\QueryError('Variable ' . $this->var . ' for column ' . $this->column . ' must contain no less than ' . $this->minlength . ' characters');
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class DBQueryParser extends BaseParser
|
|||
$query->pipe = strtoupper($attribs['pipe']) ?: 'AND';
|
||||
|
||||
// Load tables.
|
||||
foreach ($xml->tables->table as $tag)
|
||||
foreach ($xml->tables->table ?: [] as $tag)
|
||||
{
|
||||
if (trim($tag['query']) === 'true')
|
||||
{
|
||||
|
|
@ -81,7 +81,7 @@ class DBQueryParser extends BaseParser
|
|||
}
|
||||
|
||||
// Load columns.
|
||||
foreach ($xml->columns->column as $tag)
|
||||
foreach ($xml->columns->column ?: [] as $tag)
|
||||
{
|
||||
if ($tag->getName() === 'query')
|
||||
{
|
||||
|
|
@ -146,7 +146,7 @@ class DBQueryParser extends BaseParser
|
|||
if ($xml->navigation)
|
||||
{
|
||||
$query->navigation = new DBQuery\Navigation;
|
||||
foreach ($xml->navigation->index as $tag)
|
||||
foreach ($xml->navigation->index ?: [] as $tag)
|
||||
{
|
||||
$orderby = new DBQuery\OrderBy;
|
||||
$orderby->var = trim($tag['var']) ?: null;
|
||||
|
|
|
|||
|
|
@ -78,12 +78,16 @@ class ModuleInfoParser extends BaseParser
|
|||
}
|
||||
|
||||
// Add information about actions.
|
||||
$action_info = ModuleActionParser::loadXML(strtr($filename, ['info.xml' => 'module.xml']));
|
||||
$info->admin_index_act = $action_info->admin_index_act;
|
||||
$info->default_index_act = $action_info->default_index_act;
|
||||
$info->setup_index_act = $action_info->setup_index_act;
|
||||
$info->simple_setup_index_act = $action_info->simple_setup_index_act;
|
||||
$info->error_handlers = $action_info->error_handlers ?: [];
|
||||
$action_filename = strtr($filename, ['info.xml' => 'module.xml']);
|
||||
if (file_exists($action_filename))
|
||||
{
|
||||
$action_info = ModuleActionParser::loadXML($action_filename);
|
||||
$info->admin_index_act = $action_info->admin_index_act;
|
||||
$info->default_index_act = $action_info->default_index_act;
|
||||
$info->setup_index_act = $action_info->setup_index_act;
|
||||
$info->simple_setup_index_act = $action_info->simple_setup_index_act;
|
||||
$info->error_handlers = $action_info->error_handlers ?: [];
|
||||
}
|
||||
|
||||
// Return the complete result.
|
||||
return $info;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue