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
This commit is contained in:
Sergey Biryukov 2020-06-28 21:40:54 +00:00
parent c4a0e190d7
commit a234b91653
1 changed files with 8 additions and 4 deletions

View File

@ -870,8 +870,7 @@ function check_comment_flood_db() {
* @param string $email Comment author's email address. * @param string $email Comment author's email address.
* @param string $date MySQL time string. * @param string $date MySQL time string.
* @param bool $avoid_die When true, a disallowed comment will result in the function * @param bool $avoid_die When true, a disallowed comment will result in the function
* returning a WP_Error object, rather than executing wp_die(). * returning without executing wp_die() or die(). Default false.
* Default false.
* @return bool Whether comment flooding is occurring. * @return bool Whether comment flooding is occurring.
*/ */
function wp_check_comment_flood( $is_flood, $ip, $email, $date, $avoid_die = false ) { 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' ) ) { if ( current_user_can( 'manage_options' ) || current_user_can( 'moderate_comments' ) ) {
return false; return false;
} }
$hour_ago = gmdate( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS ); $hour_ago = gmdate( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS );
if ( is_user_logged_in() ) { if ( is_user_logged_in() ) {
@ -903,10 +903,13 @@ function wp_check_comment_flood( $is_flood, $ip, $email, $date, $avoid_die = fal
$user, $user,
$email $email
); );
$lasttime = $wpdb->get_var( $sql ); $lasttime = $wpdb->get_var( $sql );
if ( $lasttime ) { if ( $lasttime ) {
$time_lastcomment = mysql2date( 'U', $lasttime, false ); $time_lastcomment = mysql2date( 'U', $lasttime, false );
$time_newcomment = mysql2date( 'U', $date, false ); $time_newcomment = mysql2date( 'U', $date, false );
/** /**
* Filters the comment flood status. * 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. * @param int $time_newcomment Timestamp of when the new comment was posted.
*/ */
$flood_die = apply_filters( 'comment_flood_filter', false, $time_lastcomment, $time_newcomment ); $flood_die = apply_filters( 'comment_flood_filter', false, $time_lastcomment, $time_newcomment );
if ( $flood_die ) { if ( $flood_die ) {
/** /**
* Fires before the comment flood message is triggered. * 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 ); do_action( 'comment_flood_trigger', $time_lastcomment, $time_newcomment );
if ( true === $avoid_die ) { if ( $avoid_die ) {
return true; return true;
} else { } else {
/** /**