[wp-trac] [WordPress Trac] #63445: Replace value casting with ! empty() check for positive value validation
WordPress Trac
noreply at wordpress.org
Wed May 14 06:39:57 UTC 2025
#63445: Replace value casting with ! empty() check for positive value validation
------------------------------+-----------------------------
Reporter: dilipbheda | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Comments | Version:
Severity: normal | Keywords:
Focuses: coding-standards |
------------------------------+-----------------------------
The current logic for reading `$_POST['position']` can be simplified.
Instead of relying on value casting or a longer conditional expression, we
can use `! empty()` for a more concise and readable approach.
{{{
$position = ( isset( $_POST['position'] ) && (int) $_POST['position'] ) ?
(int) $_POST['position'] : '-1';
}}}
TO:
{{{
$position = ! empty( $_POST['position'] ) ? (int) $_POST['position'] : -1;
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63445>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list