Not a bug Member statistic sort by relation and AbstractCollection pluckNamed method

Affected version
2.1.5a

021

Active member
.if we add the criterion for sorting by relational, we get the same error as in the example:

$sortOrders['Admin.last_login'] = \XF::phrase('blabla_admin_last_login');

Error: ErrorException: [E_USER_WARNING] Accessed unknown getter 'Admin.last_login' on XF:User[1] in src\XF\Mvc\Entity\Entity.php at line 190
Error trace:
Code:
XF::handlePhpError()
trigger_error() in src\XF\Mvc\Entity\Entity.php at line 190
XF\Mvc\Entity\Entity->get() in src\XF\Mvc\Entity\Entity.php at line 101
XF\Mvc\Entity\Entity->__get() in src\XF\Mvc\Entity\AbstractCollection.php at line 171
XF\Mvc\Entity\AbstractCollection->XF\Mvc\Entity\{closure}() in src\XF\Mvc\Entity\AbstractCollection.php at line 134
XF\Mvc\Entity\AbstractCollection->pluck() in src\XF\Mvc\Entity\AbstractCollection.php at line 179
XF\Mvc\Entity\AbstractCollection->pluckNamed() in src\XF\Service\MemberStat\Preparer.php at line 236
XF\Service\MemberStat\Preparer->getResultsData() in src\XF\Service\MemberStat\Preparer.php at line 101
XF\Service\MemberStat\Preparer->getResults() in src\XF\Entity\MemberStat.php at line 105
XF\Entity\MemberStat->getResults() in src\XF\Pub\Controller\Member.php at line 71
XF\Pub\Controller\Member->actionIndex() in src\XF\Mvc\Dispatcher.php at line 350
XF\Mvc\Dispatcher->dispatchClass() in src\XF\Mvc\Dispatcher.php at line 261
XF\Mvc\Dispatcher->dispatchFromMatch() in src\XF\Mvc\Dispatcher.php at line 113
XF\Mvc\Dispatcher->dispatchLoop() in src\XF\Mvc\Dispatcher.php at line 55
XF\Mvc\Dispatcher->run() in src\XF\App.php at line 2184
XF\App->run() in src\XF.php at line 391
XF::runApp() in index.php at line 20
 

Chris D

XenForo developer
Staff member
We just don't have any support for accessing relations in that way.

Surely, ordering the users (presumably specifically admins) by last activity is sufficient?
 

021

Active member
.but sorting itself works :D Why not make it possible to sort by relations, working to the end?
 

Chris D

XenForo developer
Staff member
We assume that the sort order is going to be a valid value that is accessible on the entity. We don't support accessing values on relations in that format.

You can either switch off the show_value option or use a callback to format and display the results.
 
Top