diff --git a/common/framework/DB.php b/common/framework/DB.php index 731e0117d..c58d727b9 100644 --- a/common/framework/DB.php +++ b/common/framework/DB.php @@ -487,9 +487,9 @@ class DB } // Collect various counts used in the page calculation. - list($is_expression, $list_count) = $query->navigation->list_count->getValue($args); - list($is_expression, $page_count) = $query->navigation->page_count->getValue($args); - list($is_expression, $page) = $query->navigation->page->getValue($args); + $list_count = $query->navigation->list_count->getValue($args)[0]; + $page_count = $query->navigation->page_count->getValue($args)[0]; + $page = $query->navigation->page->getValue($args)[0]; $total_count = intval($count); $total_page = max(1, intval(ceil($total_count / $list_count))); $last_index = $total_count - (($page - 1) * $list_count); diff --git a/common/framework/parsers/dbquery/Query.php b/common/framework/parsers/dbquery/Query.php index 9234a6f00..7c3e7795e 100644 --- a/common/framework/parsers/dbquery/Query.php +++ b/common/framework/parsers/dbquery/Query.php @@ -609,7 +609,7 @@ class Query extends VariableBase { // Get the name of the column or expression to order by. $column_name = ''; - list($is_expression, $column_name) = $orderby->getValue($this->_args); + list($column_name, $is_expression) = $orderby->getValue($this->_args); if (!$column_name) { continue; @@ -649,7 +649,7 @@ class Query extends VariableBase protected function _arrangeLimitOffset(Navigation $navigation): string { // Get the list count. - list($is_expression, $list_count) = $navigation->list_count->getValue($this->_args); + $list_count = $navigation->list_count->getValue($this->_args)[0]; if ($list_count <= 0) { return ''; @@ -660,11 +660,11 @@ class Query extends VariableBase // Get the offset from the page or offset variable. if ($navigation->page) { - list($is_expression, $page) = $navigation->page->getValue($this->_args); + $page = $navigation->page->getValue($this->_args)[0]; } if ($navigation->offset) { - list($is_expression, $offset) = $navigation->offset->getValue($this->_args); + $offset = $navigation->offset->getValue($this->_args)[0]; } // If page is available, set the offset and require pagination for this query. diff --git a/common/framework/parsers/dbquery/VariableBase.php b/common/framework/parsers/dbquery/VariableBase.php index 5c205eecd..5d20ffe00 100644 --- a/common/framework/parsers/dbquery/VariableBase.php +++ b/common/framework/parsers/dbquery/VariableBase.php @@ -281,11 +281,17 @@ class VariableBase /** * Get the current value, falling back to the default value if necessary. * + * Format of return value: [value, is_expression, is_default_value] + * * @param array $args * @return array */ public function getValue(array $args): array { + $value = null; + $is_expression = false; + $is_default_value = false; + if ($this->var && Query::isValidVariable($args[$this->var] ?? null, $this instanceof ColumnWrite)) { if ($args[$this->var] === '') @@ -293,35 +299,32 @@ class VariableBase if ($this instanceof ColumnWrite) { $value = $args[$this->var]; - $is_expression = false; } else { list($is_expression, $value) = $this->getDefaultValue(); + $is_default_value = true; } } else { - $is_expression = false; $value = $args[$this->var]; } } elseif ($this->default !== null) { list($is_expression, $value) = $this->getDefaultValue(); - } - else - { - $is_expression = null; - $value = null; + $is_default_value = true; } - return [$is_expression, $value]; + return [$value, $is_expression, $is_default_value]; } /** * Get the default value of this variable. * + * Format of return value: [is_expression, value] + * * @return array */ public function getDefaultValue(): array