WordPress.org

Make WordPress Core

Opened 21 months ago

Closed 17 months ago

Last modified 17 months ago

#49239 closed enhancement (fixed)

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

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

Download all attachments as: .zip

Change History (29)

#1 @pikamander2
21 months ago

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

#2 @mukesh27
21 months 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
20 months 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
18 months ago

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

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