Skip to content

Commit

Permalink
[4.0] Remove quoting from ordering columns (#30312)
Browse files Browse the repository at this point in the history
* Remove quoting from ordering columns

* Remove redundant escaping

* Fix ambiguous column names
  • Loading branch information
SharkyKZ committed Aug 7, 2020
1 parent bc0da36 commit e5db439
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ protected function getListQuery()
$orderCol = 'cl.name';
}

$ordering = $db->quoteName($db->escape($orderCol)) . ' ' . $db->escape($orderDirn);
$ordering = $db->escape($orderCol) . ' ' . $db->escape($orderDirn);
}

$query->order($ordering);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ protected function getListQuery()
}
else
{
$ordering = $db->quoteName($db->escape($orderCol)) . ' ' . $db->escape($orderDirn);
$ordering = $db->escape($orderCol) . ' ' . $db->escape($orderDirn);
}

$query->order($ordering);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ protected function getListQuery()
}
else
{
$ordering = $db->quoteName($db->escape($orderCol)) . ' ' . $db->escape($orderDirn);
$ordering = $db->escape($orderCol) . ' ' . $db->escape($orderDirn);
}

$query->order($ordering);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function getListQuery()
$orderCol = $this->state->get('list.ordering', 't.id');
$orderDirn = strtoupper($this->state->get('list.direction', 'ASC'));

$query->order($db->quoteName($db->escape($orderCol)) . ' ' . $db->escape($orderDirn === 'DESC' ? 'DESC' : 'ASC'));
$query->order($db->escape($orderCol) . ' ' . ($orderDirn === 'DESC' ? 'DESC' : 'ASC'));

return $query;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public function getListQuery()
$orderCol = $this->state->get('list.ordering', 'w.ordering');
$orderDirn = strtoupper($this->state->get('list.direction', 'ASC'));

$query->order($db->quoteName($db->escape($orderCol)) . ' ' . $db->escape($orderDirn === 'DESC' ? 'DESC' : 'ASC'));
$query->order($db->escape($orderCol) . ' ' . ($orderDirn === 'DESC' ? 'DESC' : 'ASC'));

return $query;
}
Expand Down
4 changes: 2 additions & 2 deletions administrator/modules/mod_latest/src/Helper/LatestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public static function getList(Registry &$params, ArticlesModel $model)
switch ($params->get('ordering', 'c_dsc'))
{
case 'm_dsc':
$model->setState('list.ordering', 'modified DESC, created');
$model->setState('list.ordering', 'a.modified DESC, a.created');
$model->setState('list.direction', 'DESC');
break;

case 'c_dsc':
default:
$model->setState('list.ordering', 'created');
$model->setState('list.ordering', 'a.created');
$model->setState('list.direction', 'DESC');
break;
}
Expand Down

0 comments on commit e5db439

Please sign in to comment.