mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-31 13:37:51 +01:00
Comments: Make sure the comment data passed to the preprocess_comment
filter includes the comment_agent
and comment_author_IP
values.
Props zodiac1978, SergeyBiryukov. Fixes #51044. Built from https://develop.svn.wordpress.org/trunk@48822 git-svn-id: http://core.svn.wordpress.org/trunk@48584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8b3a813e1a
commit
3e16f7510a
@ -688,8 +688,6 @@ function set_screen_options() {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$screen_option = false;
|
||||
|
||||
if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) {
|
||||
/**
|
||||
* Filters a screen option value before it is set.
|
||||
@ -710,27 +708,29 @@ function set_screen_options() {
|
||||
* @param string $option The option name.
|
||||
* @param int $value The option value.
|
||||
*/
|
||||
$screen_option = apply_filters( 'set-screen-option', $screen_option, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
|
||||
$value = apply_filters( 'set-screen-option', false, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
|
||||
} else {
|
||||
/**
|
||||
* Filters a screen option value before it is set.
|
||||
*
|
||||
* The dynamic portion of the hook, `$option`, refers to the option name.
|
||||
*
|
||||
* Returning false from the filter will skip saving the current option.
|
||||
*
|
||||
* @since 5.4.2
|
||||
* @since 5.4.3 Only applied to options not ending with '_page',
|
||||
* and not the 'layout_columns' option.
|
||||
*
|
||||
* @see set_screen_options()
|
||||
*
|
||||
* @param mixed $screen_option The value to save instead of the option value.
|
||||
* Default false (to skip saving the current option).
|
||||
* @param string $option The option name.
|
||||
* @param int $value The option value.
|
||||
*/
|
||||
$value = apply_filters( "set_screen_option_{$option}", false, $option, $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters a screen option value before it is set.
|
||||
*
|
||||
* The dynamic portion of the hook, `$option`, refers to the option name.
|
||||
*
|
||||
* Returning false from the filter will skip saving the current option.
|
||||
*
|
||||
* @since 5.4.2
|
||||
*
|
||||
* @see set_screen_options()
|
||||
*
|
||||
* @param mixed $screen_option The value to save instead of the option value.
|
||||
* Default false (to skip saving the current option).
|
||||
* @param string $option The option name.
|
||||
* @param int $value The option value.
|
||||
*/
|
||||
$value = apply_filters( "set_screen_option_{$option}", $screen_option, $option, $value );
|
||||
|
||||
if ( false === $value ) {
|
||||
return;
|
||||
}
|
||||
|
@ -2188,10 +2188,19 @@ function wp_new_comment( $commentdata, $wp_error = false ) {
|
||||
|
||||
$prefiltered_user_id = ( isset( $commentdata['user_id'] ) ) ? (int) $commentdata['user_id'] : 0;
|
||||
|
||||
if ( ! isset( $commentdata['comment_author_IP'] ) ) {
|
||||
$commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
if ( ! isset( $commentdata['comment_agent'] ) ) {
|
||||
$commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters a comment's data before it is sanitized and inserted into the database.
|
||||
*
|
||||
* @since 1.5.0
|
||||
* @since 5.6.0 Comment data includes the `comment_agent` and `comment_author_IP` values.
|
||||
*
|
||||
* @param array $commentdata Comment data.
|
||||
*/
|
||||
@ -2211,14 +2220,8 @@ function wp_new_comment( $commentdata, $wp_error = false ) {
|
||||
|
||||
$commentdata['comment_parent'] = ( 'approved' === $parent_status || 'unapproved' === $parent_status ) ? $commentdata['comment_parent'] : 0;
|
||||
|
||||
if ( ! isset( $commentdata['comment_author_IP'] ) ) {
|
||||
$commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
$commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '', $commentdata['comment_author_IP'] );
|
||||
|
||||
if ( ! isset( $commentdata['comment_agent'] ) ) {
|
||||
$commentdata['comment_agent'] = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
|
||||
}
|
||||
$commentdata['comment_agent'] = substr( $commentdata['comment_agent'], 0, 254 );
|
||||
|
||||
if ( empty( $commentdata['comment_date'] ) ) {
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.6-alpha-48820';
|
||||
$wp_version = '5.6-alpha-48822';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user