MarcoH64
11-15-2005, 03:42 PM
In modules/latesttopics.php the forumtitles (of selected to show) are pulled from the database. This information is already available in the in-memory copy of the datastore though. Moving it to datastore would save some query processing:
Replace:
$threads = $db->query_read("
SELECT
" . iif($mod_options['portal_threads_showrating'], 'IF(votenum >= ' . $vbulletin->options['showvotes'] . ', votenum, 0) AS numbvote, IF(votenum >= ' . $vbulletin->options['showvotes'] . ' AND votenum != 0, votetotal / votenum, 0) AS voteavg,') . "
thread.threadid, thread.title, thread.replycount, postusername, postuserid, thread.dateline AS postdateline, IF(views <= thread.replycount, thread.replycount+1, views) AS views, thread.lastposter, thread.lastpost, pollid
" . iif($mod_options['portal_threads_showsubscribed'] AND $vbulletin->userinfo['userid'], ', NOT ISNULL(subscribethread.subscribethreadid) AS subscribed') .
iif($mod_options['portal_threads_showicon'], ', thread.iconid AS threadiconid, iconpath AS threadiconpath') .
iif($mod_options['portal_threads_showforum'], ',thread.forumid, forum.title AS forumtitle') .
iif ($mod_options['portal_threads_showpreview'] AND $vbulletin->options['threadpreview'], ', post.pagetext AS preview') . "
FROM " . TABLE_PREFIX . "thread as thread
" . iif($mod_options['portal_threads_showicon'], ' LEFT JOIN ' . TABLE_PREFIX . 'icon USING (iconid)') .
iif($mod_options['portal_threads_showforum'], ' LEFT JOIN ' . TABLE_PREFIX . 'forum AS forum ON (thread.forumid = forum.forumid)') .
iif($mod_options['portal_threads_showpreview'] AND $vbulletin->options['threadpreview'], ' LEFT JOIN ' . TABLE_PREFIX . 'post AS post ON (post.postid = thread.firstpostid)') .
$deljoin .
iif ($mod_options['portal_threads_showsubscribed'] AND $vbulletin->userinfo['userid'], ' LEFT JOIN ' . TABLE_PREFIX . 'subscribethread AS subscribethread ON (subscribethread.threadid = thread.threadid AND subscribethread.userid = ' . $vbulletin->userinfo['userid'] . ')') . "
WHERE open != 10 AND thread.visible = 1
$mods[threadids]
$mods[inforums]
$mods[exforums]
$notdeleted
ORDER BY $mod_options[portal_threads_orderby] $mod_options[portal_threads_direction]
LIMIT $mod_options[portal_threads_maxthreads]
");
by:$threads = $db->query_read("
SELECT
" . iif($mod_options['portal_threads_showrating'], 'IF(votenum >= ' . $vbulletin->options['showvotes'] . ', votenum, 0) AS numbvote, IF(votenum >= ' . $vbulletin->options['showvotes'] . ' AND votenum != 0, votetotal / votenum, 0) AS voteavg,') . "
thread.threadid, thread.forumid, thread.title, thread.replycount, postusername, postuserid, thread.dateline AS postdateline, IF(views <= thread.replycount, thread.replycount+1, views) AS views, thread.lastposter, thread.lastpost, pollid
" . iif($mod_options['portal_threads_showsubscribed'] AND $vbulletin->userinfo['userid'], ', NOT ISNULL(subscribethread.subscribethreadid) AS subscribed') .
iif($mod_options['portal_threads_showicon'], ', thread.iconid AS threadiconid, iconpath AS threadiconpath') .
iif ($mod_options['portal_threads_showpreview'] AND $vbulletin->options['threadpreview'], ', post.pagetext AS preview') . "
FROM " . TABLE_PREFIX . "thread as thread
" . iif($mod_options['portal_threads_showicon'], ' LEFT JOIN ' . TABLE_PREFIX . 'icon USING (iconid)') .
iif($mod_options['portal_threads_showpreview'] AND $vbulletin->options['threadpreview'], ' LEFT JOIN ' . TABLE_PREFIX . 'post AS post ON (post.postid = thread.firstpostid)') .
$deljoin .
iif ($mod_options['portal_threads_showsubscribed'] AND $vbulletin->userinfo['userid'], ' LEFT JOIN ' . TABLE_PREFIX . 'subscribethread AS subscribethread ON (subscribethread.threadid = thread.threadid AND subscribethread.userid = ' . $vbulletin->userinfo['userid'] . ')') . "
WHERE open != 10 AND thread.visible = 1
$mods[threadids]
$mods[inforums]
$mods[exforums]
$notdeleted
ORDER BY $mod_options[portal_threads_orderby] $mod_options[portal_threads_direction]
LIMIT $mod_options[portal_threads_maxthreads]
");
Then find:
$mods['threadcount'] = $db->num_rows($threads);
while ($thread = $db->fetch_array($threads))
{
$bgclass = exec_switch_bg();
and add under: if ($mod_options['portal_threads_showforum'])
{
$thread['forumtitle'] = $vbulletin->datastore->registry->forumcache["$thread[forumid]"]['title_clean'];
}
Replace:
$threads = $db->query_read("
SELECT
" . iif($mod_options['portal_threads_showrating'], 'IF(votenum >= ' . $vbulletin->options['showvotes'] . ', votenum, 0) AS numbvote, IF(votenum >= ' . $vbulletin->options['showvotes'] . ' AND votenum != 0, votetotal / votenum, 0) AS voteavg,') . "
thread.threadid, thread.title, thread.replycount, postusername, postuserid, thread.dateline AS postdateline, IF(views <= thread.replycount, thread.replycount+1, views) AS views, thread.lastposter, thread.lastpost, pollid
" . iif($mod_options['portal_threads_showsubscribed'] AND $vbulletin->userinfo['userid'], ', NOT ISNULL(subscribethread.subscribethreadid) AS subscribed') .
iif($mod_options['portal_threads_showicon'], ', thread.iconid AS threadiconid, iconpath AS threadiconpath') .
iif($mod_options['portal_threads_showforum'], ',thread.forumid, forum.title AS forumtitle') .
iif ($mod_options['portal_threads_showpreview'] AND $vbulletin->options['threadpreview'], ', post.pagetext AS preview') . "
FROM " . TABLE_PREFIX . "thread as thread
" . iif($mod_options['portal_threads_showicon'], ' LEFT JOIN ' . TABLE_PREFIX . 'icon USING (iconid)') .
iif($mod_options['portal_threads_showforum'], ' LEFT JOIN ' . TABLE_PREFIX . 'forum AS forum ON (thread.forumid = forum.forumid)') .
iif($mod_options['portal_threads_showpreview'] AND $vbulletin->options['threadpreview'], ' LEFT JOIN ' . TABLE_PREFIX . 'post AS post ON (post.postid = thread.firstpostid)') .
$deljoin .
iif ($mod_options['portal_threads_showsubscribed'] AND $vbulletin->userinfo['userid'], ' LEFT JOIN ' . TABLE_PREFIX . 'subscribethread AS subscribethread ON (subscribethread.threadid = thread.threadid AND subscribethread.userid = ' . $vbulletin->userinfo['userid'] . ')') . "
WHERE open != 10 AND thread.visible = 1
$mods[threadids]
$mods[inforums]
$mods[exforums]
$notdeleted
ORDER BY $mod_options[portal_threads_orderby] $mod_options[portal_threads_direction]
LIMIT $mod_options[portal_threads_maxthreads]
");
by:$threads = $db->query_read("
SELECT
" . iif($mod_options['portal_threads_showrating'], 'IF(votenum >= ' . $vbulletin->options['showvotes'] . ', votenum, 0) AS numbvote, IF(votenum >= ' . $vbulletin->options['showvotes'] . ' AND votenum != 0, votetotal / votenum, 0) AS voteavg,') . "
thread.threadid, thread.forumid, thread.title, thread.replycount, postusername, postuserid, thread.dateline AS postdateline, IF(views <= thread.replycount, thread.replycount+1, views) AS views, thread.lastposter, thread.lastpost, pollid
" . iif($mod_options['portal_threads_showsubscribed'] AND $vbulletin->userinfo['userid'], ', NOT ISNULL(subscribethread.subscribethreadid) AS subscribed') .
iif($mod_options['portal_threads_showicon'], ', thread.iconid AS threadiconid, iconpath AS threadiconpath') .
iif ($mod_options['portal_threads_showpreview'] AND $vbulletin->options['threadpreview'], ', post.pagetext AS preview') . "
FROM " . TABLE_PREFIX . "thread as thread
" . iif($mod_options['portal_threads_showicon'], ' LEFT JOIN ' . TABLE_PREFIX . 'icon USING (iconid)') .
iif($mod_options['portal_threads_showpreview'] AND $vbulletin->options['threadpreview'], ' LEFT JOIN ' . TABLE_PREFIX . 'post AS post ON (post.postid = thread.firstpostid)') .
$deljoin .
iif ($mod_options['portal_threads_showsubscribed'] AND $vbulletin->userinfo['userid'], ' LEFT JOIN ' . TABLE_PREFIX . 'subscribethread AS subscribethread ON (subscribethread.threadid = thread.threadid AND subscribethread.userid = ' . $vbulletin->userinfo['userid'] . ')') . "
WHERE open != 10 AND thread.visible = 1
$mods[threadids]
$mods[inforums]
$mods[exforums]
$notdeleted
ORDER BY $mod_options[portal_threads_orderby] $mod_options[portal_threads_direction]
LIMIT $mod_options[portal_threads_maxthreads]
");
Then find:
$mods['threadcount'] = $db->num_rows($threads);
while ($thread = $db->fetch_array($threads))
{
$bgclass = exec_switch_bg();
and add under: if ($mod_options['portal_threads_showforum'])
{
$thread['forumtitle'] = $vbulletin->datastore->registry->forumcache["$thread[forumid]"]['title_clean'];
}