Finder::setDefaultOrder vs Finder::order() differences in multi-column ordering

Affected version
2.2.5

Xon

Well-known member
Suppose a new multi-column sort order is added by extending in \XF\Repository with;
PHP:
public function getDefaultThreadListSortOptions($forAdminConfig): array
{
    $options = parent::getDefaultThreadListSortOptions($forAdminConfig);

    $options['MyNewColumnAlias'] = [
        ['MyNewColumn'],
        ['last_post_date'],
    ];

    return $options;
}

When set as an explicit forum filter, this results in the following code;
PHP:
$finder->setOrder([
 ['MyNewColumn'],
 ['last_post_date'],
], 'desc');
The resulting SQL contains; order by MyNewColumn desc, last_post_date desc

When set as the forum default without an explicit filter;
PHP:
$finder->setDefaultOrder([
 ['MyNewColumn'],
 ['last_post_date'],
], 'desc');
The resulting SQL contains; order by MyNewColumn asc, last_post_date asc.

The problem is setDefaultOrder() calls standardizeOrderingValue() while order() does not, and standardizeOrderingValue() is inconsistent with order() in how a default direction applied to the sorting order.
 
Top