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.
Built from https://develop.svn.wordpress.org/trunk@48207


git-svn-id: http://core.svn.wordpress.org/trunk@47976 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-06-28 21:42:03 +00:00
parent 8d7a19cdc2
commit 8c721c9c34
2 changed files with 9 additions and 5 deletions

View File

@ -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 {
/**

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-48206';
$wp_version = '5.5-alpha-48207';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.