Fix /apps/projectmanager threw SQL error Unknown column 'hash' in 'order clause'

This commit is contained in:
nathangray 2019-12-09 14:11:55 -07:00
parent b0ceaef987
commit 1064759020

View File

@ -486,12 +486,6 @@ class Storage extends Storage\Base
*/
protected function process_search(&$criteria, &$only_keys=True, &$order_by='', &$extra_cols='', &$wildcard='', &$op='AND', &$filter=null, &$join='')
{
// if no CFs are defined OR used and became unavailable (deleted or permissions changed)
if (!$this->customfields && strpos($order_by, self::CF_PREFIX) === false &&
strpos(implode(',', array_keys($filter ? $filter : [])), self::CF_PREFIX) === false)
{
return;
}
if ($only_keys === false)
{
$only_keys = $this->table_name.'.*';
@ -588,6 +582,15 @@ class Storage extends Storage\Base
{
$col = $this->table_name .'.'.array_search($col, $this->db_cols).' AS '.$col;
}
// Check to make sure our order by doesn't have aliases that won't work
else if (stripos($col, 'AS') !== false && $order_by)
{
list($value, $alias) = explode(' AS ', $col);
if(stripos($order_by, $alias) !== FALSE)
{
$order_by = str_replace($alias, $value, $order_by);
}
}
}
}
// check if we order by a custom field --> join cf table for given cf and order by it's value