2011-01-21, 05:34 PM
I'd like to suggest a hook for the showthread.php page. It's come to my attention there doesn't appear to be a way to add to the build_postbit() function without adding a new query to each and every post.
Example is my My Awards plugin. Currently each post with a user with awards has to do a query. I'm checking for a way to do a grab with all users WHERE IN($pids) before the build_postbit() in order to save 15-20 queries on the page. There appears to be sufficient hooks in the functions_post.php page inside build_postbit() function but not before I hit that function in showthread.php.
After carefully reviewing the code I've come to the conclusion that a hook is going to be needed. I also feel that this hook would benefit the plugin author community.
The hook has to appear before the build_postbit() but before the while statements to avoid looping queries.
Here is example existing code.
And...
Please note in the second example the hook that is there is AFTER the eval which I believe MyBB has begun to correct by moving these hooks before the eval statement.
I'm not sure the best method to add a hook there to execute my suggestion. Maybe the development team can review my post and consider my statements. I realize this might be a complicated request but I do 100% believe this will benefit authors providing a more efficient way to add postbit content.
Thank you.
Example is my My Awards plugin. Currently each post with a user with awards has to do a query. I'm checking for a way to do a grab with all users WHERE IN($pids) before the build_postbit() in order to save 15-20 queries on the page. There appears to be sufficient hooks in the functions_post.php page inside build_postbit() function but not before I hit that function in showthread.php.
After carefully reviewing the code I've come to the conclusion that a hook is going to be needed. I also feel that this hook would benefit the plugin author community.
The hook has to appear before the build_postbit() but before the while statements to avoid looping queries.
Here is example existing code.
// Get the actual posts from the database here.
$posts = '';
$query = $db->query("
SELECT u.*, u.username AS userusername, p.*, f.*, eu.username AS editusername
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
LEFT JOIN ".TABLE_PREFIX."userfields f ON (f.ufid=u.uid)
LEFT JOIN ".TABLE_PREFIX."users eu ON (eu.uid=p.edituid)
WHERE $pids
ORDER BY p.dateline
");
while($post = $db->fetch_array($query))
{
if($thread['firstpost'] == $post['pid'] && $thread['visible'] == 0)
{
$post['visible'] = 0;
}
$posts .= build_postbit($post);
$post = '';
}
$plugins->run_hooks("showthread_linear");
And...
// Build the threaded post display tree.
$query = $db->query("
SELECT p.username, p.uid, p.pid, p.replyto, p.subject, p.dateline
FROM ".TABLE_PREFIX."posts p
WHERE p.tid='$tid'
$visible
ORDER BY p.dateline
");
while($post = $db->fetch_array($query))
{
if(!$postsdone[$post['pid']])
{
if($post['pid'] == $mybb->input['pid'] || ($isfirst && !$mybb->input['pid']))
{
$postcounter = count($postsdone);
$isfirst = 0;
}
$tree[$post['replyto']][$post['pid']] = $post;
$postsdone[$post['pid']] = 1;
}
}
$threadedbits = buildtree();
$posts = build_postbit($showpost);
eval("\$threadexbox = \"".$templates->get("showthread_threadedbox")."\";");
$plugins->run_hooks("showthread_threaded");
Please note in the second example the hook that is there is AFTER the eval which I believe MyBB has begun to correct by moving these hooks before the eval statement.
I'm not sure the best method to add a hook there to execute my suggestion. Maybe the development team can review my post and consider my statements. I realize this might be a complicated request but I do 100% believe this will benefit authors providing a more efficient way to add postbit content.
Thank you.