summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorSergey Biryukov <sergeybiryukov@git.wordpress.org>2020-06-28 21:40:54 +0000
committerSergey Biryukov <sergeybiryukov@git.wordpress.org>2020-06-28 21:40:54 +0000
commita234b9165367b0e2682393bea55e9e7046d9d368 (patch)
tree72cc71b910ecf210ce04caeb588a795754bbf15a /src
parentc4a0e190d75f8d557cd8f5123b897f8cf8b6e745 (diff)
downloadwordpress-a234b9165367b0e2682393bea55e9e7046d9d368.tar.gz
wordpress-a234b9165367b0e2682393bea55e9e7046d9d368.zip
Docs: Correct description for the `$avoid_die` parameter of `wp_check_comment_flood()`.
The function always return a boolean value, never a `WP_Error` object. See #49572, #39732. git-svn-id: https://develop.svn.wordpress.org/trunk@48207 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'src')
-rw-r--r--src/wp-includes/comment.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php
index 055d1d11e5..2f225ae2c6 100644
--- a/src/wp-includes/comment.php
+++ b/src/wp-includes/comment.php
@@ -870,8 +870,7 @@ function check_comment_flood_db() {
* @param string $email Comment author's email address.
* @param string $date MySQL time string.
* @param bool $avoid_die When true, a disallowed comment will result in the function
- * returning a WP_Error object, rather than executing wp_die().
- * Default false.
+ * returning without executing wp_die() or die(). Default false.
* @return bool Whether comment flooding is occurring.
*/
function wp_check_comment_flood( $is_flood, $ip, $email, $date, $avoid_die = false ) {
@@ -887,6 +886,7 @@ function wp_check_comment_flood( $is_flood, $ip, $email, $date, $avoid_die = fal
if ( current_user_can( 'manage_options' ) || current_user_can( 'moderate_comments' ) ) {
return false;
}
+
$hour_ago = gmdate( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS );
if ( is_user_logged_in() ) {
@@ -897,16 +897,19 @@ function wp_check_comment_flood( $is_flood, $ip, $email, $date, $avoid_die = fal
$check_column = '`comment_author_IP`';
}
- $sql = $wpdb->prepare(
+ $sql = $wpdb->prepare(
"SELECT `comment_date_gmt` FROM `$wpdb->comments` WHERE `comment_date_gmt` >= %s AND ( $check_column = %s OR `comment_author_email` = %s ) ORDER BY `comment_date_gmt` DESC LIMIT 1",
$hour_ago,
$user,
$email
);
+
$lasttime = $wpdb->get_var( $sql );
+
if ( $lasttime ) {
$time_lastcomment = mysql2date( 'U', $lasttime, false );
$time_newcomment = mysql2date( 'U', $date, false );
+
/**
* Filters the comment flood status.
*
@@ -917,6 +920,7 @@ function wp_check_comment_flood( $is_flood, $ip, $email, $date, $avoid_die = fal
* @param int $time_newcomment Timestamp of when the new comment was posted.
*/
$flood_die = apply_filters( 'comment_flood_filter', false, $time_lastcomment, $time_newcomment );
+
if ( $flood_die ) {
/**
* Fires before the comment flood message is triggered.
@@ -928,7 +932,7 @@ function wp_check_comment_flood( $is_flood, $ip, $email, $date, $avoid_die = fal
*/
do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment );
- if ( true === $avoid_die ) {
+ if ( $avoid_die ) {
return true;
} else {
/**