Opened 21 months ago
Closed 3 months ago
#58041 closed defect (bug) (fixed)
Fix non-strict checking issue on /wp-admin/includes/upgrade.php file
Reported by: | faisalahammad | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 6.7 | Priority: | normal |
Severity: | normal | Version: | 6.3 |
Component: | General | Keywords: | has-patch |
Focuses: | coding-standards | Cc: |
Description
This PR fixes a non-strict checking issue on line 1419 of the /wp-admin/includes/upgrade.php file in WordPress core. The current code uses the "==" operator instead of the "===" operator, which can lead to unexpected behavior due to type coercion.
To fix this issue, we replace the "==" operator with the "===" operator to perform a strict comparison between the value of the $link->link_category variable and the integer 0. This ensures that the comparison is done in a type-safe way and that unexpected behavior is avoided.
The fixed code is as follows:
<?php if ( 0 === $link->link_category ) ) { continue; }
With this fix, the code in the upgrade.php file will be more reliable and less prone to unexpected behavior.
Change History (4)
This ticket was mentioned in PR #4277 on WordPress/wordpress-develop by @faisalahammad.
21 months ago
#1
- Keywords has-patch added; needs-patch removed
#3
@
3 months ago
- Milestone changed from Awaiting Review to 6.7
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
Hi there, welcome back to WordPress Trac! Thanks for the ticket.
Please note that $link->link_category
is a string here, so the strict comparison would not work as is, it would require casting to an integer: 0 === (int) $link->link_category
.
This PR fixes a non-strict checking issue on line 1419 of the /wp-admin/includes/upgrade.php file in WordPress core. The current code uses the "==" operator instead of the "===" operator, which can lead to unexpected behavior due to type coercion.
To fix this issue, we replace the "==" operator with the "===" operator to perform a strict comparison between the value of the $link->link_category variable and the integer 0. This ensures that the comparison is done in a type-safe way and that unexpected behavior is avoided.
The fixed code is as follows:
{{{php
if ( 0 === $link->link_category ) ) {
}
}}}
With this fix, the code in the upgrade.php file will be more reliable and less prone to unexpected behavior.
Trac ticket: https://core.trac.wordpress.org/ticket/58041