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

Discussion in 'Resolved Bug Reports' started by ragtek, Dec 21, 2010.

  1. ragtek

    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.
     
    Vincent likes this.
  2. Mike

    Mike XenForo Developer Staff Member

    Fixed.
     
    Vincent likes this.

Share This Page