Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#49239 closed enhancement (fixed)

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

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

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

Download all attachments as: .zip

Change History (29)

#1 @pikamander2
5 years ago

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

#2 @mukesh27
5 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
5 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
5 years ago

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

#5 @SergeyBiryukov
5 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 47785:

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

Props pikamander2, mukesh27, SergeyBiryukov.
Fixes #49239.

#6 @SergeyBiryukov
5 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.