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

Affected version


Well-known member
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.
$structure->primaryKey = 'monitor_id';
This will cause unexpected errors when you pass an integer to whereId or whereIds function;
$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

Chris D

XenForo developer
Staff member
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.