R
ragtek
Guest
method setExtraData checks if the value is an array for DATA_FORUM
BUT that's IMO NOT optimal, because these variable will ALWAYS be a array.
The reason for this is, that you're using XenForo_Model_Forum::getForumByThreadId to get the forum data
and this returns an empty array if non forum was found.
So it will always call XenForo_DataWriter_Discussion_Thread::setForumCacheItem($value);
which will result in an error if $value is a empty array
To sum it up: THE POST DATAWRITER DOESN'T check, if the thread exists
Probably it shouldn't come to this error, because normally the data should be validated (and checked for the existing thread) BEFORE being sent to the post datawriter, but it's still a ugly implemention
PHP:
public function setExtraData($name, $value)
{
if ($name == self::DATA_FORUM)
{
if (!is_array($value))
{
return;
}
XenForo_DataWriter_Discussion_Thread::setForumCacheItem($value);
}
return parent::setExtraData($name, $value);
}
BUT that's IMO NOT optimal, because these variable will ALWAYS be a array.
The reason for this is, that you're using XenForo_Model_Forum::getForumByThreadId to get the forum data
PHP:
public function getForumByThreadId($threadId)
{
if ($forums = $this->getForums(array('thread_id' => $threadId)))
{
return reset($forums);
}
return array();
}
So it will always call XenForo_DataWriter_Discussion_Thread::setForumCacheItem($value);
PHP:
public static function setForumCacheItem(array $forum)
{
self::$forumCache[$forum['node_id']] = $forum;
}
To sum it up: THE POST DATAWRITER DOESN'T check, if the thread exists
Probably it shouldn't come to this error, because normally the data should be validated (and checked for the existing thread) BEFORE being sent to the post datawriter, but it's still a ugly implemention
