Jonathan M
Member
- Affected version
- 2.2.5
XF\Mvc\Entity\FinderCollection
extends XF\Mvc\Entity\AbstractCollection
which implements ArrayAccess
. This means FinderCollection
should throw an exception when attempting to access non-existent keys but it just returns null
instead. Since it's implementing ArrayAccess
, it should behave the same way an array does when you attempt to access a key that doesn't exist.XF\Entity\Thread::getUserReadDate()
depends on this null
return for the way it checks a user's read dates.
PHP:
public function getUserReadDate(\XF\Entity\User $user)
{
$threadRead = $this->Read[$user->user_id];
$forumRead = $this->Forum ? $this->Forum->Read[$user->user_id] : null;
$dates = [\XF::$time - $this->app()->options()->readMarkingDataLifetime * 86400];
if ($threadRead)
{
$dates[] = $threadRead->thread_read_date;
}
if ($forumRead)
{
$dates[] = $forumRead->forum_read_date;
}
return max($dates);
}
$threadRead
will be null
if the user hasn't read the thread. The same also applies to $forumRead
. Once FinderCollection
correctly throws an exception when attempting to access non-existent keys, this function will break.
Last edited: