Skip to content

Commit 38e9142

Browse files
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
1 parent f852ca2 commit 38e9142

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/wp-admin/edit-form-advanced.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@
245245
// Detect if there exists an autosave newer than the post and if that autosave is different than the post.
246246
if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
247247
foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) {
248-
if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {
248+
if ( normalize_whitespace( $autosave->$autosave_field ) !== normalize_whitespace( $post->$autosave_field ) ) {
249249
$notice = sprintf(
250250
/* translators: %s: URL to view the autosave. */
251251
__( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>' ),

src/wp-admin/includes/post.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1829,7 +1829,7 @@ function wp_create_post_autosave( $post_data ) {
18291829
// If the new autosave has the same content as the post, delete the autosave.
18301830
$autosave_is_different = false;
18311831
foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) {
1832-
if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->$field ) ) {
1832+
if ( normalize_whitespace( $new_autosave[ $field ] ) !== normalize_whitespace( $post->$field ) ) {
18331833
$autosave_is_different = true;
18341834
break;
18351835
}

src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ public function create_post_autosave( $post_data ) {
368368
$autosave_is_different = false;
369369

370370
foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) {
371-
if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->$field ) ) {
371+
if ( normalize_whitespace( $new_autosave[ $field ] ) !== normalize_whitespace( $post->$field ) ) {
372372
$autosave_is_different = true;
373373
break;
374374
}

src/wp-includes/revision.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ function wp_save_post_revision( $post_id ) {
162162
$post_has_changed = false;
163163

164164
foreach ( array_keys( _wp_post_revision_fields( $post ) ) as $field ) {
165-
if ( normalize_whitespace( $post->$field ) != normalize_whitespace( $last_revision->$field ) ) {
165+
if ( normalize_whitespace( $post->$field ) !== normalize_whitespace( $last_revision->$field ) ) {
166166
$post_has_changed = true;
167167
break;
168168
}

0 commit comments

Comments
 (0)