CoreCommunity ExtensionsIncubatorDistributionsTYPO3 4.5 ProjectsTYPO3 4.6 ProjectsTYPO3 4.7 ProjectsTYPO3 6.0 ProjectsTYPO3 6.1 ProjectsTYPO3 6.2 Projects (+)

Bug #10689

tx_mmforum_prelogin / and getunread

Added by Jonas Felix over 2 years ago. Updated over 2 years ago.

Status:Under Review Start date:2010-11-09
Priority:Must have Due date:
Assignee:- % Done:

0%

Category:-
Target version:-
Votes: 0

Description

If you have a huge forum (3 mio record +) you can not use the existing getunread method because it has a horrible slow SQL statement.

There is a solution with the tx_mmforum_prelogin in place which does not work, because tx_mmforum_prelogin is never filled with any data.

Is there any other extension that fills the information into tx_mmforum_prelogin? Because in fact mm_forum doesn't insert a timestamp into that field at any time.

I suggest at a alternative method which is 10000 times faster:

    function getunreadposts ($content, $conf, $lastlogin, $filter = array()) {
        if(!$this->unread) {
            return $this->unread;
        } else {

            $uid = $GLOBALS['TSFE']->fe_user->user['uid'];

            if(!$uid) return array();

            if (is_array($filter['forum_id'])) {
                $where = '(forum_id=' . implode(' OR forum_id=', $filter['forum_id']). ') AND ';
            } else if (is_array($filter['topic_id'])) {
                $where = '(topic_id=' . implode(' OR topic_id=', $filter['topic_id']). ') AND ';
            } else {
                $where = '';
            }

            $where .= 'deleted = 0 AND crdate > '.intval($lastlogin).' ';
            //debug ($where, 'where');
            if ($filter['onlyCategories']) {
                $select = 'distinct(forum_id)';
            } else {
                $select = 'distinct(topic_id)';
            }
            $unread    = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
                $select ,
                'tx_mmforum_posts a',
                $where
             );

            $this->unread = array();
            while ($row = mysql_fetch_assoc($unread)) {
                if ($filter['onlyCategories']) {
                    $this->unread[] = $row['forum_id'];
                } else {
                    $this->unread[] = $row['topic_id'];
                }
            }
        }

            return $this->unread;
    }

But for that we have to fix the tx_mmforum_prelogin.

History

Updated by Martin Helmich over 2 years ago

  • Status changed from New to Under Review

Also available in: Atom PDF