Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#58060 closed defect (bug) (duplicate)

Non-strict checking issue on line 209 of options-writing.php

Reported by: sharif200's profile sharif200 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch
Focuses: coding-standards Cc:

Description

I have found a non-strict checking issue on this line of code. This means the code is not checking the value type returned by the 'get_option' function. It is possible that the value could be a non-numeric string or a boolean value other than true or false, which could lead to unexpected behavior in the code.

Change History (3)

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


2 years ago
#1

  • Keywords has-patch added; needs-patch removed

I have identified a non-strict checking issue on line 209 of the options-writing.php file in WordPress. The code checks the value of the 'blog_public' option using a non-strict comparison operator (==) instead of a strict comparison operator (===).
This can potentially lead to unexpected behavior if the value returned by the 'get_option' function is a non-numeric string or a boolean value other than true or false.

I have tested the proposed fix, which resolves the non-strict checking issue without causing any other issues. I have created a pull request with the fix and would appreciate it if someone from the WordPress core team could review and merge it. Thank you.

Trac ticket:
https://core.trac.wordpress.org/ticket/58060

#2 @audrasjb
2 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version trunk deleted

Hello and thanks for the patch @sharif200.

However, it looks like a duplicate of #58039. I'm closing this as duplicate, but also, the patch would probably break the condition as this option returns a string by default, not an integer or a boolean (see #58039 for more details).

#3 @SergeyBiryukov
2 years ago

  • Component changed from General to Administration
Note: See TracTickets for help on using tickets.