Bug #401

Inline Moderation - do_multideleteposts

Added by Nick Palmer over 2 years ago. Updated about 2 years ago.

Status:Closed Start date:08/20/2009
Priority:Normal Due date:
Assignee:Tom Moore % Done:

100%

Category:Moderation
Target version:1.4.10
Reproducibility:Always Database Type:
Reported In MyBB Version:1.4.8 Database Version:
PHP Version: SQA assignments:
Browser:

Description

At the top of moderation.php:

$tid = intval($mybb->input['tid']);
$pid = intval($mybb->input['pid']);
$fid = intval($mybb->input['fid']);

if($pid)
{
    $post = get_post($pid);
    $tid = $post['tid'];
    if(!$post['pid'])
    {
        error($lang->error_invalidpost);
    }
}

Now, search for:
case "do_multideleteposts":

Scroll down and you'll find this:
        if($pids)
        {
            $query = $db->simple_select("threads", "tid", "firstpost IN({$pids})");
            while($tid = $db->fetch_field($query, "tid"))
            {
                $tids[] = $tid;
            }
        }

Here:

while($tid = $db->fetch_field($query, "tid"))

$tid will override the existing $tid and depending on the circunstances, it might be null / 0 / whatever you want to call it.

Now, scroll down a little bit more and you'll find:

            $query = $db->simple_select("posts", "*", "tid='$tid'");
            $numposts = $db->num_rows($query);
            if(!$numposts)
            {
                $moderation->delete_thread($tid);
                mark_reports($tid, "thread");
                $url = get_forum_link($fid);
            }
            else
            {
                mark_reports($plist, "posts");
                $url = get_thread_link($thread['tid']);
            }

Obviously, this will not work:
$query = $db->simple_select("posts", "*", "tid='$tid'");

So this is what's executed always:
            if(!$numposts)
            {
                $moderation->delete_thread($tid);
                mark_reports($tid, "thread");
                $url = get_forum_link($fid);
            }

(or at least most of the times, like I said, it depends if one of posts we're trying to delete is the first post or not but if it's not, it will still run that code)

By simply changing this:

            while($tid = $db->fetch_field($query, "tid"))
            {
                $tids[] = $tid;
            }

to:

            while($threadid = $db->fetch_field($query, "tid"))
            {
                $tids[] = $threadid;
            }

The bug is fixed. I've searched the duplicate, fixed and the forum I am posting it and couldn't find this report so I decided to post this.

Associated revisions

Revision 4466
Added by Tom Moore over 2 years ago

Fixes Inline Modertaion - do_multideleteposts (fixes:401)

Revision 4514
Added by Tom Moore about 2 years ago

Fixes Inline Moderation do_mutlideleteposts (fixes:401)

History

Updated by Tom Moore over 2 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Applied in changeset r4466.

Updated by Tom Moore over 2 years ago

  • Category set to Moderation
  • Assignee set to Tom Moore
  • Target version set to 1.4.10

Updated by Michael Schlechtinger over 2 years ago

  • Status changed from Resolved to Feedback

This fix is missing in the trunk.

Updated by Tom Moore about 2 years ago

  • Status changed from Feedback to Resolved

Applied in changeset r4514.

Updated by Michael Schlechtinger about 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF