Fixed  Scope problem in XenForo_Model_Thread

  • Thread starter Thread starter ragtek
  • Start date Start date
R

ragtek

Guest
Class: XenForo_Model_Thread
Method: rebuildThreadUserPostCounters
Line: 1295

PHP:
	public function rebuildThreadUserPostCounters($threadId, $userId = null)
	{
		if ($userId === 0)
		{
			return;
		}

		$records = $this->_getDb()->fetchPairs('
			SELECT user_id, COUNT(*)
			FROM xf_post
			WHERE thread_id = ?
				AND message_state = \'visible\'
				' . ($userId !== null ? ' AND user_id = ' . $db->quote($userId) : ' AND 1=1') . '
			GROUP BY user_id
		');
There is no $db in the scope.
PHP:
$db = $this->_getDb();
Is missing^^

Also
PHP:
AND message_state = \'visible\'
				' . ($userId !== null ? ' AND user_id = ' . $db->quote($userId) : ' AND 1=1') .
doesn't make sense.
IMHO you don't need the and 1=1.
 
Top Bottom