[wp-trac] [WordPress Trac] #53066: Trigger errors when non-existent methods are called on objects.
WordPress Trac
noreply at wordpress.org
Wed Apr 21 07:40:24 UTC 2021
#53066: Trigger errors when non-existent methods are called on objects.
------------------------------+-----------------------------
Reporter: dd32 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: coding-standards |
------------------------------+-----------------------------
Numerous WordPress classes include a `__call()` function for back-compat,
however, simply return false on invalid calls.
For example, the following code outputs 'No' even though it should be a
fatal error.
{{{
$wp_query = new WP_Query();
echo $wp_query->delete_all_posts() ? 'Yes' : 'No';
}}}
This can cause logic errors, where someone were to use something like:
`WP_User::has_role( 'something' )` and expect to receive true/false, but
only ever get false. (Note that `has_role()` doesn't exist and won't
exist: [comment:10:ticket:22624])
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53066>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list