Make WordPress Core

Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#49239 closed enhancement (fixed)

Prefer strict PHP comparisons over loose PHP comparisons (batch 2)

Reported by: pikamander2 Owned by: SergeyBiryukov
Priority: normal Milestone: 5.5
Component: General Version:
Severity: normal Keywords: needs-patch
Cc: Focuses: coding-standards

Description

(Continuation of #48965)

Here are some more patch files to change loose comparisons to strict comparisons

Attachments (23)

admin.php.patch​ (2.7 KB ) - added by pikamander2 7 years ago.
admin-header.php.patch​ (843 bytes ) - added by pikamander2 7 years ago.
async-upload.php.patch​ (556 bytes ) - added by pikamander2 7 years ago.
comment.php.patch​ (1.8 KB ) - added by pikamander2 7 years ago.
comment.php.2.patch​ (1.8 KB ) - added by pikamander2 7 years ago.
edit-comments.php.patch​ (1.2 KB ) - added by pikamander2 7 years ago.
edit-form-advanced.php.patch​ (8.0 KB ) - added by pikamander2 7 years ago.
edit-tag-form.php.patch​ (2.4 KB ) - added by pikamander2 7 years ago.
edit-tag-form.php.2.patch​ (2.4 KB ) - added by pikamander2 7 years ago.
export.php.patch​ (1.1 KB ) - added by pikamander2 7 years ago.
import.php.patch​ (645 bytes ) - added by pikamander2 7 years ago.
index.php.patch​ (609 bytes ) - added by pikamander2 7 years ago.
install.php.patch​ (1.1 KB ) - added by pikamander2 7 years ago.
install-helper.php.patch​ (2.5 KB ) - added by pikamander2 7 years ago.
link-manager.php.patch​ (430 bytes ) - added by pikamander2 7 years ago.
link-manager.php.2.patch​ (430 bytes ) - added by pikamander2 7 years ago.
load-styles.php.patch​ (406 bytes ) - added by pikamander2 7 years ago.
media.php.patch​ (929 bytes ) - added by pikamander2 7 years ago.
media-upload.php.patch​ (932 bytes ) - added by pikamander2 7 years ago.
menu-header.php.patch​ (3.7 KB ) - added by pikamander2 7 years ago.
menu-header.php.2.patch​ (3.7 KB ) - added by pikamander2 7 years ago.
ms-delete-site.php.patch​ (1.0 KB ) - added by pikamander2 7 years ago.
my-sites.php.patch​ (843 bytes ) - added by pikamander2 7 years ago.

Download all attachments as: .zip

Change History (29)

#1 @pikamander2
7 years ago

@SergeyBiryukov - Here's another batch of strict comparisons.

#2 @mukesh27
7 years ago

  • Keywords needs-patch added

@pikamander2 can you please update comment.php.2.patch patch?

if ( $comment->comment_approved != '0' ) { // if not unapproved

Replace to

if ( '0' !== $comment->comment_approved ) { // if not unapproved

#3 @pikamander2
7 years ago

@mukesh27 - Sorry for the late reply.

I was hesitant to replace the loose comparisons that involved things like '0' or 0 because that would change the resulting logic when comparing it to things like null or false.

For backwards compatibility reasons, I think it would be best to do the easy ones first and then revisit comparisons like the one you mentioned later on.

#4 @SergeyBiryukov
7 years ago

  • Milestone Awaiting Review → 5.5
  • Owner set to SergeyBiryukov
  • Status new → reviewing

#5 @SergeyBiryukov
6 years ago

  • Resolution → fixed
  • Status reviewing → closed

In 47785:

Coding Standards: Use strict comparison in some wp-admin files.

Props pikamander2, mukesh27, SergeyBiryukov.
Fixes #49239.

#6 @SergeyBiryukov
6 years ago

In 47787:

Coding Standards: Correct db_version check in wp-admin/admin.php.

Follow-up to [47785].

See #49239.

Note: See TracTickets for help on using tickets.