Make WordPress Core

Opened 5 months ago

Closed 3 months ago

Last modified 3 months ago

#62283 closed enhancement (fixed)

Fix: Loose Comparisons in ms-functions.php

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

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.


5 months 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
5 months ago

  • Summary changed from Fix: Loose Comparisions in ms-functions.php to Fix: Loose Comparisons in ms-functions.php

@debarghyabanerjee commented on PR #7616:


5 months ago
#3

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

#4 @SergeyBiryukov
3 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
3 months ago

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

#6 @SergeyBiryukov
3 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
3 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
3 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
3 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
3 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
3 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
3 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
3 months ago

  • Resolution set to fixed
  • Status changed from reviewing to 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:


3 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.