BirdOPrey5
12-21-2010, 05:56 PM
So i've been updating my "All Topics" mod and got an excellent version going that needs no file edits working from vBulletin 3.6 through 4.0.7 just fine...
But in 4.0.8 (and I presume, above) vital code was changed in 1 part which kills my hopes for a mod requiring no file edits.
I'm looking at forumdisplay.php at the forumdiplay_query_threadscount hook. The relevant code is:
$hook_query_fields = $hook_query_joins = $hook_query_where = '';
($hook = vBulletinHook::fetch_hook('forumdisplay_query_thre adscount')) ? eval($hook) : false;
# Include visible IN (0,1,2) in order to hit upon the 4 column index
$threadscount = $db->query_first_slave("
SELECT COUNT(*) AS threads,
(
SELECT COUNT(*) AS newthread
FROM " . TABLE_PREFIX . "thread AS thread
WHERE forumid = $foruminfo[forumid]
AND lastpost > $lastread
AND open <> 10
AND sticky = 0
$prefix_filter
$visiblethreads
$globalignore
$limitothers
$datecut
$hook_query_where
) AS newthread
$hook_query_fields
FROM " . TABLE_PREFIX . "thread AS thread
$tachyjoin
$hook_query_joins
WHERE forumid = $foruminfo[forumid]
AND sticky = 0
$prefix_filter
$visiblethreads
$globalignore
$limitothers
$datecut
$hook_query_where
");
$totalthreads = $threadscount['threads'];
$newthreads = $threadscount['newthread'];
In previous versions I was able to use the $hook_query_where and $hook_query_join hooks to edit this database call however in 4.0.8 they added new code, the old code is here:
$hook_query_fields = $hook_query_joins = $hook_query_where = '';
($hook = vBulletinHook::fetch_hook('forumdisplay_query_thre adscount')) ? eval($hook) : false;
# Include visible IN (0,1,2) in order to hit upon the 4 column index
$threadscount = $db->query_first_slave("
SELECT COUNT(*) AS threads, SUM(IF(thread.lastpost > $lastread AND open <> 10, 1, 0)) AS newthread
$hook_query_fields
FROM " . TABLE_PREFIX . "thread AS thread
$tachyjoin
$hook_query_joins
WHERE forumid = $foruminfo[forumid]
AND sticky = 0
$prefix_filter
$visiblethreads
$globalignore
$limitothers
$datecut
$hook_query_where
");
$totalthreads = $threadscount['threads'];
$newthreads = $threadscount['newthread'];
As you can see in the new code the $hook_query_joins is not above the first WHERE statement but $hook_query_where is in both sections of code.
I thought about overriding the entire $threadcount variable in a plugin but there is no hook between the time the variable is given value and the time it's used.
Are there any other tricks for this? Basically I need to change WHERE forumid = $foruminfo[forumid] to WHERE forumid IN ($myforums)...
I know I don't usually visit the 4.x forums- let me find out what I've been missing. :D
Also I'm 98% this is impossible but I wanted to confirm before I make people do manual file edits.
But in 4.0.8 (and I presume, above) vital code was changed in 1 part which kills my hopes for a mod requiring no file edits.
I'm looking at forumdisplay.php at the forumdiplay_query_threadscount hook. The relevant code is:
$hook_query_fields = $hook_query_joins = $hook_query_where = '';
($hook = vBulletinHook::fetch_hook('forumdisplay_query_thre adscount')) ? eval($hook) : false;
# Include visible IN (0,1,2) in order to hit upon the 4 column index
$threadscount = $db->query_first_slave("
SELECT COUNT(*) AS threads,
(
SELECT COUNT(*) AS newthread
FROM " . TABLE_PREFIX . "thread AS thread
WHERE forumid = $foruminfo[forumid]
AND lastpost > $lastread
AND open <> 10
AND sticky = 0
$prefix_filter
$visiblethreads
$globalignore
$limitothers
$datecut
$hook_query_where
) AS newthread
$hook_query_fields
FROM " . TABLE_PREFIX . "thread AS thread
$tachyjoin
$hook_query_joins
WHERE forumid = $foruminfo[forumid]
AND sticky = 0
$prefix_filter
$visiblethreads
$globalignore
$limitothers
$datecut
$hook_query_where
");
$totalthreads = $threadscount['threads'];
$newthreads = $threadscount['newthread'];
In previous versions I was able to use the $hook_query_where and $hook_query_join hooks to edit this database call however in 4.0.8 they added new code, the old code is here:
$hook_query_fields = $hook_query_joins = $hook_query_where = '';
($hook = vBulletinHook::fetch_hook('forumdisplay_query_thre adscount')) ? eval($hook) : false;
# Include visible IN (0,1,2) in order to hit upon the 4 column index
$threadscount = $db->query_first_slave("
SELECT COUNT(*) AS threads, SUM(IF(thread.lastpost > $lastread AND open <> 10, 1, 0)) AS newthread
$hook_query_fields
FROM " . TABLE_PREFIX . "thread AS thread
$tachyjoin
$hook_query_joins
WHERE forumid = $foruminfo[forumid]
AND sticky = 0
$prefix_filter
$visiblethreads
$globalignore
$limitothers
$datecut
$hook_query_where
");
$totalthreads = $threadscount['threads'];
$newthreads = $threadscount['newthread'];
As you can see in the new code the $hook_query_joins is not above the first WHERE statement but $hook_query_where is in both sections of code.
I thought about overriding the entire $threadcount variable in a plugin but there is no hook between the time the variable is given value and the time it's used.
Are there any other tricks for this? Basically I need to change WHERE forumid = $foruminfo[forumid] to WHERE forumid IN ($myforums)...
I know I don't usually visit the 4.x forums- let me find out what I've been missing. :D
Also I'm 98% this is impossible but I wanted to confirm before I make people do manual file edits.