DragonByte Tech
Well-known member
- Affected version
- 2.2.1
Based off of
However, this is not actually what happens. Instead, when choosing
I don't think the stack trace is relevant here, because the bug is that
Current code:
Suggested fix:
I have confirmed that this will work if the
XF\Repository\Thread
:: getDefaultThreadListSortOptions
, it should be possible to add custom thread list sorting options by using something like this in the ForumType:
PHP:
public function getThreadListSortOptions(Forum $forum, bool $forAdminConfig = false): array
{
$options = parent::getThreadListSortOptions($forum, $forAdminConfig);
$options['vote_score'] = 'vote_score';
$options['custom_display_name'] = 'vendor_prefix_thread_entity_column';
return $options;
}
However, this is not actually what happens. Instead, when choosing
custom_display_name
in the default forum sort, you will receive the following error message on the forum:InvalidArgumentException: Unknown column custom_display_name on XF:Thread in src/XF/Mvc/Entity/Finder.php at line 1640
I don't think the stack trace is relevant here, because the bug is that
XF\Finder\Thread
does not resolve the default_sort_order
back to the actual entity name.Current code:
PHP:
public function applyForumDefaultOrder(\XF\Entity\Forum $forum)
{
$this->setDefaultOrder($forum->default_sort_order, $forum->default_sort_direction);
return $this;
}
Suggested fix:
PHP:
public function applyForumDefaultOrder(\XF\Entity\Forum $forum)
{
$sortOrders = $forum->TypeHandler->getThreadListSortOptions($forum);
$this->setDefaultOrder($sortOrders[$forum->default_sort_order], $forum->default_sort_direction);
return $this;
}
default_sort_order
value is different from the thread entity column, due to storage size restrictions on the default_sort_order
column.