From 3a333ef030345c459b9ba131b24735a3f8f635f3 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 25 Feb 2020 19:35:09 +0000 Subject: [PATCH] Coding Standards: Use strict comparison for `normalize_whitespace()` checks when comparing revisions or autosaves. Props dkarfa, itowhid06, TimothyBlynJacobs. Fixes #47965. Built from https://develop.svn.wordpress.org/trunk@47372 git-svn-id: http://core.svn.wordpress.org/trunk@47159 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-form-advanced.php | 2 +- wp-admin/includes/post.php | 2 +- .../rest-api/endpoints/class-wp-rest-autosaves-controller.php | 2 +- wp-includes/revision.php | 2 +- wp-includes/version.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 13d4046c03..e604573565 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -245,7 +245,7 @@ $form_extra .= "post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) { foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) { - if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) { + if ( normalize_whitespace( $autosave->$autosave_field ) !== normalize_whitespace( $post->$autosave_field ) ) { $notice = sprintf( /* translators: %s: URL to view the autosave. */ __( 'There is an autosave of this post that is more recent than the version below. View the autosave' ), diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index d9ef63f7b2..ad01e545b3 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -1829,7 +1829,7 @@ function wp_create_post_autosave( $post_data ) { // If the new autosave has the same content as the post, delete the autosave. $autosave_is_different = false; foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) { - if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->$field ) ) { + if ( normalize_whitespace( $new_autosave[ $field ] ) !== normalize_whitespace( $post->$field ) ) { $autosave_is_different = true; break; } diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php index af5f51f74f..86c9cd45f6 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php @@ -368,7 +368,7 @@ class WP_REST_Autosaves_Controller extends WP_REST_Revisions_Controller { $autosave_is_different = false; foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) { - if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->$field ) ) { + if ( normalize_whitespace( $new_autosave[ $field ] ) !== normalize_whitespace( $post->$field ) ) { $autosave_is_different = true; break; } diff --git a/wp-includes/revision.php b/wp-includes/revision.php index 00e58fa179..eec6c29700 100644 --- a/wp-includes/revision.php +++ b/wp-includes/revision.php @@ -162,7 +162,7 @@ function wp_save_post_revision( $post_id ) { $post_has_changed = false; foreach ( array_keys( _wp_post_revision_fields( $post ) ) as $field ) { - if ( normalize_whitespace( $post->$field ) != normalize_whitespace( $last_revision->$field ) ) { + if ( normalize_whitespace( $post->$field ) !== normalize_whitespace( $last_revision->$field ) ) { $post_has_changed = true; break; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 78eb9eb075..71596d2e03 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.4-beta2-47371'; +$wp_version = '5.4-beta2-47372'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.