Skip to content

Commit

Permalink
Coding Standards: Use strict comparison for normalize_whitespace()
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
SergeyBiryukov committed Feb 25, 2020
1 parent f852ca2 commit 38e9142
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/wp-admin/edit-form-advanced.php
Expand Up @@ -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. <a href="%s">View the autosave</a>' ),
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/post.php
Expand Up @@ -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;
}
Expand Down
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/revision.php
Expand Up @@ -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;
}
Expand Down

0 comments on commit 38e9142

Please sign in to comment.