Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple confirmation clicks in Moderation Queue results in duplicate posts #11142

Open
juliecampbell opened this issue Dec 17, 2021 · 0 comments

Comments

@juliecampbell
Copy link

Describe the bug
When someone with the ability to manage the Moderation Queue clicks to approve any number of items in the list, multiple clicks on "Yes" in the confirmation modal results in each item being published multiple times.

Vanilla info

  1. Are you sure this is a core Vanilla problem and not caused by any addon you are using?
    We have made no changes to how the moderation queue functions.

  2. Did you follow our generic troubleshooting steps already?
    Yes

  3. What Vanilla version are you using?
    2021.012

  4. When did the issue start?
    Not certain, could have been there since we updated to 2021.012.

To Reproduce
Steps to reproduce the behavior:

  1. Prerequisite: Have at least one item in the Moderation Queue. May require logging on as a normal user to do this depending on the site configuration.
  2. Log in as a user with the ability to manage the Moderation Queue.
  3. Go to the Moderation Queue.
  4. Select one or more items and click "Approve".
  5. In the confirmation modal that pops up, click "Yes" multiple times. We have easily been able to click 4-5 times before errors pop up and/or the modal disappears.

Expected behavior
All selected items are published exactly once and appear exactly once in the appropriate place on the frontend.

Current behavior
All selected items are published the number of times that the "Yes" button was clicked before errors begin to pop up. So if the button was clicked 4 times to approve a new discussion, that new discussion is published 4 times and appears 4 times on the frontend.

Additional context
We have found in applications/dashboard/controllers/class.logcontroller.php in the restore() function that checking for and stashing a session variable seems to be a good way to address this situation. Something like this seems to have worked for us in a patch:

$logIDs = Gdn::request()->post('LogIDs');
// Handle multiple clicks on "Yes" when restoring logs.
$session = Gdn::session();
$restoreIds = $session->stash('restoring_logs', '', false);
if ($restoreIds && $restoreIds === $logIDs) {
    // Already restoring these logs, so multiple clicks detected.
    return;
} else {
    // Not already restoring the logs, so this is the first click.
    $session->stash('restoring_logs', $logIDs);
}
 ....
$this->LogModel->recalculate();
// Now that the logs have been restored, remove the session value so that other logs can be restored.
$session->stash('restoring_logs');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant