Skip to content

Commit be6a610

Browse files
Editor: fix contributor "Slow down" message when updating Notes quickly.
Fix an issue where contributors’ notes edits were throttled. Notes are internal and from trusted users, they do not need throttling. Skip calling wp_allow_comment for notes in WP_REST_Comments_Controller::create_item. As a result the pre_comment_approved hook is also not fired for notes. Fixes WordPress/gutenberg#72892 where the issue was originally reported. Props adamsilverstein, desrosj, wildworks, mamaduka. Fixes #64199. git-svn-id: https://develop.svn.wordpress.org/trunk@61144 602fd350-edb4-49c9-b593-d223f7449a82
1 parent e1b474c commit be6a610

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/wp-includes/comment.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -714,11 +714,6 @@ function wp_allow_comment( $commentdata, $wp_error = false ) {
714714

715715
$dupe_id = $wpdb->get_var( $dupe );
716716

717-
// Allow duplicate notes for resolution purposes.
718-
if ( isset( $commentdata['comment_type'] ) && 'note' === $commentdata['comment_type'] ) {
719-
$dupe_id = false;
720-
}
721-
722717
/**
723718
* Filters the ID, if any, of the duplicate comment found when creating a new comment.
724719
*

src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,11 @@ public function create_item( $request ) {
714714
);
715715
}
716716

717-
$prepared_comment['comment_approved'] = wp_allow_comment( $prepared_comment, true );
717+
// Don't check for duplicates or flooding for notes.
718+
$prepared_comment['comment_approved'] =
719+
'note' === $prepared_comment['comment_type'] ?
720+
'1' :
721+
wp_allow_comment( $prepared_comment, true );
718722

719723
if ( is_wp_error( $prepared_comment['comment_approved'] ) ) {
720724
$error_code = $prepared_comment['comment_approved']->get_error_code();

0 commit comments

Comments
 (0)