MyBB Community Forums

Full Version: Moderator Tools no longer have any effect after upgrading to MyBB 1.8.41
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Since upgrading my forum to MyBB 1.8.41, my Moderator Tools no longer seem to work.

I currently have two Moderator Tools configured:
  1. A tool that changes the thread title and adds a reply.
  2. A tool that moves the thread to another forum.

When I run either tool, the confirmation window appears correctly and I can confirm that I want to perform the action. However, after confirming, I am simply redirected back to the post, and no changes are applied.

I have not noticed any related errors in the MyBB error logs.

The issue appears to have started after upgrading to MyBB 1.8.41. The Moderator Tools were working correctly before the upgrade.


Steps to reproduce:

  1. Create or use a Moderator Tool.
  2. Run the tool on a thread.
  3. Confirm the action in the confirmation window.
  4. You are redirected back to the post, but the requested action has not been performed.
With the help of ChatGPT, I was able to identify and fix the issue. The proposed fix is currently working on my forum, but I would appreciate feedback from the community on whether this is the correct approach and whether it could have any unintended side effects.

### Conclusion and proposed fix

The issue appears to be caused by the forum validation logic in tool_forums_allowed() in inc/class_custommoderation.php introduced in 1.8.41.

When a thread-level Moderator Tool is executed, no post IDs are passed, so $pids defaults to 0. The current code converts this value into array(0). The validation then attempts to retrieve a post with ID 0, fails, and returns false. As a result, the Moderator Tool is aborted without performing any action.

**Proposed fix**

In the execute() method, replace the existing parameter normalization:
if(!is_array($tids))
{
    $tids = array($tids);
}

if(!is_array($pids))
{
    $pids = array($pids);
}


with:
if(!is_array($tids))
{
    $tids = $tids ? array($tids) : array();
}

if(!is_array($pids))
{
    $pids = $pids ? array($pids) : array();
}
Hi,
There is an issue scoped in the next release: https://github.com/mybb/mybb/issues/5432
WIth the fix pushed by dvz in the following pull request: https://github.com/mybb/mybb/pull/5433

You current fix will work until 1.8.42 is released.