Fixed Finder::whereIds throws unexpected error for an array primaryKey with 1 entry

Xon

Well-known member
Affected version
2.0.2
In most cases, XenForo's entity system treats a string as if it was an array with 1 entry. But the primaryKey appears somewhat special.

This works.
PHP:
$structure->primaryKey = 'monitor_id';
This will cause unexpected errors when you pass an integer to whereId or whereIds function;
Code:
$structure->primaryKey = ['monitor_id'];

ErrorException: [E_WARNING] array_key_exists() expects parameter 2 to be array, integer given in src/XF/Mvc/Entity/Finder.php at line 433
 
For whereId(s) I've made a change so that if the primaryKey value in the structure is an array that contains a single element, that we reset it to a string. That should avoid the problem.
 
Top Bottom