Make WordPress Core

Opened 2 years ago

Closed 22 months ago

Last modified 22 months ago

#62283 closed enhancement (fixed)

Fix: Loose Comparisons in ms-functions.php

Reported by: debarghyabanerjee Owned by: SergeyBiryukov
Priority: normal Milestone: 6.8
Component: Networks and Sites Version:
Severity: minor Keywords: has-patch
Cc: Focuses: multisite, coding-standards

Description

While going through the ms-functions.php file, I found that loose comparisons are used in several instances.

Change History (14)

This ticket was mentioned in ​PR #7616 on ​WordPress/wordpress-develop by ​@debarghyabanerjee.


2 years ago
#1

  • Keywords has-patch added; needs-patch removed

Trac Ticket: Core-62283

## Overview

  • This pull request addresses the use of loose comparisons in the ms-functions.php file. Loose comparisons can lead to unexpected behavior and potential bugs, so this update replaces them with strict comparisons for improved reliability and clarity.

## Changes Made

  • Identified and updated all instances of loose comparisons to use strict comparisons ( === and !== ).
  • Ensured that any necessary type checks are handled appropriately to maintain the intended functionality of the code.

## Benefits

  • Enhances code reliability by preventing unexpected type coercion.
  • Improves code readability and maintainability by following best practices for comparison.

## Testing

  • Conducted tests to ensure that all functionality remains intact after the changes.
  • Verified that no new issues were introduced during the refactoring process.

#2 @debarghyabanerjee
2 years ago

  • Summary Fix: Loose Comparisions in ms-functions.php → Fix: Loose Comparisons in ms-functions.php

​@debarghyabanerjee commented on ​PR #7616:


2 years ago
#3

Hi @hellofromtonya, hope you are doing well.
Can you please take a look into this PR. Thanks.

#4 @SergeyBiryukov
22 months ago

In 59512:

Coding Standards: Use strict comparison in get_blog_id_from_url().

Follow-up to ​mu:1538.

Props debarghyabanerjee.
See #62283.

#5 @SergeyBiryukov
22 months ago

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

#6 @SergeyBiryukov
22 months ago

In 59557:

Coding Standards: Use strict comparison in wpmu_validate_user_signup().

Follow-up to [14298], [19852].

Props debarghyabanerjee.
See #62283.

#7 @SergeyBiryukov
22 months ago

In 59560:

Coding Standards: Use strict comparison in wpmu_signup_blog_notification().

Follow-up to ​mu:1970.

Props debarghyabanerjee.
See #62283.

#8 @SergeyBiryukov
22 months ago

In 59561:

Coding Standards: Use strict comparison in remove_user_from_blog().

Follow-up to ​mu:543.

Props debarghyabanerjee, aristath, poena, afercia, SergeyBiryukov.
See #62279, #62283.

#9 @SergeyBiryukov
22 months ago

Hi there, thanks for the PR!

Just noting that some of the proposed changes, e.g. 1 === $primary->archived would not work as expected, because these properties are numeric strings, not integers. I will make some adjustments on commit based on a closer review and testing.

#10 @SergeyBiryukov
22 months ago

In 59562:

Coding Standards: Use strict comparison in get_active_blog_for_user().

Follow-up to ​mu:804, ​mu:1918.

Props debarghyabanerjee, aristath, poena, afercia, SergeyBiryukov.
See #62279, #62283.

#11 @SergeyBiryukov
22 months ago

In 59563:

Coding Standards: Use strict comparison in is_user_spammy().

Follow-up to ​mu:1640.

Props debarghyabanerjee, aristath, poena, afercia, SergeyBiryukov.
See #62279, #62283.

#12 @SergeyBiryukov
22 months ago

In 59573:

Coding Standards: Use strict comparison in wpmu_validate_blog_signup().

Follow-up to ​mu:8, ​mu:543, ​mu:550, ​mu:1364, ​mu:1958, [12603], [32733].

Props debarghyabanerjee, aristath, poena, afercia, SergeyBiryukov.
See #62279, #62283.

#13 @SergeyBiryukov
22 months ago

  • Resolution → fixed
  • Status reviewing → closed

In 59574:

Coding Standards: Replace loose comparison in wpmu_welcome_notification().

Follow-up to ​mu:543.

Props debarghyabanerjee, aristath, poena, afercia, SergeyBiryukov.
Fixes #62283. See #62279.

​@SergeyBiryukov commented on ​PR #7616:


22 months ago
#14

Thanks for the PR! Merged in r59512, r59557, r59560, r59561, r59562, r59563, r59573, and r59574.

Note: See TracTickets for help on using tickets.