WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 4 days ago

#49239 reviewing enhancement

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

Download all attachments as: .zip

Change History (27)

#1 @pikamander2
3 months ago

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

#2 @mukesh27
3 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
2 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
4 days ago

  • Milestone changed from Awaiting Review to 5.5
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing
Note: See TracTickets for help on using tickets.