Make WordPress Core

Opened 13 months ago

Last modified 3 months ago

#60023 new defect (bug)

Fixed force_ssl_admin to always return bool

Reported by: pbearne's profile pbearne Owned by:
Milestone: 6.8 Priority: low
Severity: minor Version:
Component: General Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

this function can be passed a random string
where the Gobal value set by is used we check if it is not empty
the doc say to set a bool but is allows you set any value eg 'false' which on empty
So I have added a cast to make sure the value set is bool
see pre fix tests
https://core.trac.wordpress.org/ticket/60018

Change History (9)

This ticket was mentioned in PR #5731 on WordPress/wordpress-develop by @pbearne.


13 months ago
#1

  • Keywords has-patch has-unit-tests added

#2 @swissspidy
11 months ago

  • Keywords needs-patch added; has-patch has-unit-tests removed

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


3 months ago
#3

  • Keywords has-patch added; needs-patch removed

Trac Ticket: Core-60023

## Description

  • This pull request addresses a potential issue with the force_ssl_admin function, ensuring that it always returns a boolean value, as intended by its documentation.

## Changes Made

  • Modified the force_ssl_admin function to cast the $force parameter to a boolean type. This guarantees that any input, whether it's a string, integer, or null, is converted to a boolean value (true or false).
  • Updated the function documentation to clarify that the $force parameter can accept string|bool|null, making it clear to developers what types are acceptable.

## Reasoning

  • The original implementation allowed for non-boolean values to be passed to the function, which could lead to unexpected behavior. By explicitly casting to boolean, we ensure consistency and prevent potential bugs caused by improperly handled input.

## Impact

  • This change enhances the reliability of the force_ssl_admin function, making it safer to use in various contexts without worrying about the type of input provided.

## Testing

  • Confirmed that the function behaves as expected with different input types, including boolean, string, and integer values.
  • Validated that the function returns the correct boolean value in all scenarios.

@debarghyabanerjee commented on PR #7624:


3 months ago
#4

Hi @swissspidy , can you please take a look into this PR. Thanks

@debarghyabanerjee commented on PR #7624:


3 months ago
#5

Hi @swissspidy , can you please take a look into this PR. Thanks

#6 @swissspidy
3 months ago

#57262 was marked as a duplicate.

#7 @swissspidy
3 months ago

  • Component changed from Build/Test Tools to General
  • Keywords has-unit-tests added
  • Milestone changed from Awaiting Review to 6.8
  • Priority changed from normal to low
  • Severity changed from normal to minor

Additional props to pbearne, costdev, autotutorial from #57262.

#8 @swissspidy
3 months ago

#57261 was marked as a duplicate.

@debarghyabanerjee commented on PR #7624:


3 months ago
#9

Hi @swissspidy , I have left a query, can you please check once. Thanks.

Note: See TracTickets for help on using tickets.