MyBB Community Forums

Full Version: Inline Thread Deletion and Reported Posts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
If you delete multiple posts using "Inline Post Moderation" then any reported posts are not marked as reportstatus 0.

If you delete a single post using "Inline Post Moderation" then the report is properly marked as reportstatus 0.


To replicate:

1. Find a thread with more than 2 posts.
2. Report post #2.
3. Using "Inline Post Moderation" delete posts #2 and #3.
4. View reported posts and see the deleted post still there with no info

To View Normal behavior:
1. Find a thread with more than 2 posts.
2. Report post #2.
3. Using "Inline Post Moderation" delete post #2
4. View reported posts and see it's marked

Problem:
moderation.php
	case "do_multideleteposts":

		// Verify incoming POST request
		verify_post_check($mybb->input['my_post_key']);
		
		$postlist = explode("|", $mybb->input['posts']);
		if(!is_moderator_by_pids($postlist, "candeleteposts"))
		{
			error_no_permission();
		}
		$postlist = array_map('intval', $postlist);
		$pids = implode(',', $postlist);
		
		$tids = array();
		if($pids)
		{
			$query = $db->simple_select("threads", "tid", "firstpost IN({$pids})");
			while($tid = $db->fetch_field($query, "tid"))
			{
				$tids[] = $tid;
			}
		}
		
		$deletecount = 0;
		foreach($postlist as $pid)
		{
			$pid = intval($pid);
			$moderation->delete_post($pid);
			$plist[] = $pid;
			$deletecount++;
		}
		
		// If we have multiple threads, we must be coming from the search
		if(!empty($tids))
		{
			foreach($tids as $tid)
			{
				$moderation->delete_thread($tid);
				mark_reports($tid, "thread");
				$url = get_forum_link($fid);
			}
		}
		// Otherwise we're just deleting from showthread.php
		else
		{
			$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']);
			}
		}
		
		$lang->deleted_selective_posts = $lang->sprintf($lang->deleted_selective_posts, $deletecount);
		log_moderator_action($modlogdata, $lang->deleted_selective_posts);
		moderation_redirect($url, $lang->redirect_postsdeleted);
		break;

Seems a logic problem. Whatever the solution you choose there is a small bug here.
I remember this being reported before. I'm surprised it's not fixed
Unless it's not fixed in upgrade package it still exists.
Can you diagnose which one of these it enters in both of those scenarios (The "if" statement)? I don't have a live environment here at work:

$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']);
}
I sort of stopped at that point. I am short on time the next week or so but if this is still here I'll try to remember to do it.

However I think it was the $plist as the problem if I remember correctly. The issue was deleted posts not threads.

You posted a $tid delete and not a pid delete. That might help you with this.

The bug happens like if I have a report on a user. I then do a "find all posts" from the user and I would select multiple posts to delete. You can probably test right here at Mybboard.net using the test area. Just make 3 crap posts...report 2 of them and delete them both after a "Find all posts" search. That should repeat the bug.

Maybe I will test this with threads to see if it also has the problem.