From 38e9142a6628eb755d0f7f0e326b228395ea5a50 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 25 Feb 2020 19:33:22 +0000 Subject: [PATCH] Coding Standards: Use strict comparison for `normalize_whitespace()` checks when comparing revisions or autosaves. Props dkarfa, itowhid06, TimothyBlynJacobs. Fixes #47965. git-svn-id: https://develop.svn.wordpress.org/trunk@47372 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/edit-form-advanced.php | 2 +- src/wp-admin/includes/post.php | 2 +- .../rest-api/endpoints/class-wp-rest-autosaves-controller.php | 2 +- src/wp-includes/revision.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-admin/edit-form-advanced.php b/src/wp-admin/edit-form-advanced.php index 13d4046c0333..e604573565f4 100644 --- a/src/wp-admin/edit-form-advanced.php +++ b/src/wp-admin/edit-form-advanced.php @@ -245,7 +245,7 @@ // Detect if there exists an autosave newer than the post and if that autosave is different than the post. if ( $autosave && mysql2date( 'U', $autosave->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/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index d9ef63f7b281..ad01e545b3dc 100644 --- a/src/wp-admin/includes/post.php +++ b/src/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/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php index af5f51f74f63..86c9cd45f6ef 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php @@ -368,7 +368,7 @@ public function create_post_autosave( $post_data ) { $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/src/wp-includes/revision.php b/src/wp-includes/revision.php index 00e58fa17992..eec6c297007f 100644 --- a/src/wp-includes/revision.php +++ b/src/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; }