-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace '==' with '===' #4292
Replace '==' with '===' #4292
Conversation
The WordPress core file wp-admin/update-core.php, on line 184, uses '=='. To ensure consistency with the WordPress coding standards and improve the security and stability of the code, I have replaced '==' with '===' on this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @akramulhasan, Can you apply similar changes in line no 45?
The WordPress core file wp-admin/update-core.php, on line 45, uses '=='. To ensure consistency with the WordPress coding standards and improve the security and stability of the code, I have replaced '==' with '===' on this line.
Thank you so much @mukeshpanchal27 for your feedback |
Imho to be able to use strict comparison with full confidence both sides will have to be cast to |
@@ -42,7 +42,7 @@ function list_core_update( $update ) { | |||
|
|||
if ( 'en_US' === $update->locale && 'en_US' === get_locale() ) { | |||
$version_string = $update->current; | |||
} elseif ( 'en_US' === $update->locale && $update->packages->partial && $wp_version == $update->partial_version ) { | |||
} elseif ( 'en_US' === $update->locale && $update->packages->partial && $wp_version === $update->partial_version ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} elseif ( 'en_US' === $update->locale && $update->packages->partial && $wp_version === $update->partial_version ) { | |
} elseif ( 'en_US' === $update->locale && $update->packages->partial && (string) $wp_version === (string) $update->partial_version ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @azaozz
@@ -181,7 +181,7 @@ function list_core_update( $update ) { | |||
|
|||
if ( 'en_US' !== $update->locale && ( ! isset( $wp_local_package ) || $wp_local_package != $update->locale ) ) { | |||
echo '<p class="hint">' . __( 'This localized version contains both the translation and various other localization fixes.' ) . '</p>'; | |||
} elseif ( 'en_US' === $update->locale && 'en_US' !== get_locale() && ( ! $update->packages->partial && $wp_version == $update->partial_version ) ) { | |||
} elseif ( 'en_US' === $update->locale && 'en_US' !== get_locale() && ( ! $update->packages->partial && $wp_version === $update->partial_version ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} elseif ( 'en_US' === $update->locale && 'en_US' !== get_locale() && ( ! $update->packages->partial && $wp_version === $update->partial_version ) ) { | |
} elseif ( 'en_US' === $update->locale && 'en_US' !== get_locale() && ( ! $update->packages->partial && (string) $wp_version === (string) $update->partial_version ) ) { |
Thanks for the PR! Merged in r57529. |
The WordPress PHP coding standards recommend using the strict equality operator '===' instead of '==' when checking conditions. This is because '==' performs type coercion, which can lead to unexpected results or security issues in some cases.
However, the WordPress core file wp-admin/update-core.php, on line 184, uses '=='. To ensure consistency with the WordPress coding standards and improve the security and stability of the code, I propose replacing '==' with '===' on this line.
This change will ensure that the comparison is performed using strict type checking, preventing any unexpected type coercion or security issues that may arise due to loose comparisons.
With this change, I will create a pull request to the WordPress core repository.
Trac ticket: https://core.trac.wordpress.org/ticket/58061
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.