• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed  Scope problem in XenForo_Model_Thread

R

ragtek

Guest
#1
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.