[wp-trac] [WordPress Trac] #48415: Calling current_user_can( 'publish_post' ) results in Notice on 5.3-RC2-46574
WordPress Trac
noreply at wordpress.org
Wed Oct 23 20:40:17 UTC 2019
#48415: Calling current_user_can( 'publish_post' ) results in Notice on
5.3-RC2-46574
----------------------------+-----------------------------
Reporter: johnstonphilip | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
----------------------------+-----------------------------
The spread operator change which was added to current_user_can in 5.3-RC2
is resulting in notices showing for calls that previously did not.
For example, calling
{{{
current_user_can( 'publish_post' );
}}}
Triggers this notice:
Notice: Undefined offset: 0 in /app/public/wp-includes/capabilities.php on
line 256
Perhaps an isset check should be done prior to attempting usage. Something
like this:
{{{
$post = isset( $args[0] ) ? $args[0] : false
}}}
The code in question is here:
https://github.com/WordPress/WordPress/blob/66f907b2eb0b7adaa57ecfac0e49535fce63a341
/wp-includes/capabilities.php#L256
But that type of call is done in a few places:
https://github.com/WordPress/WordPress/blob/66f907b2eb0b7adaa57ecfac0e49535fce63a341
/wp-includes/capabilities.php#L68
https://github.com/WordPress/WordPress/blob/66f907b2eb0b7adaa57ecfac0e49535fce63a341
/wp-includes/capabilities.php#L141
https://github.com/WordPress/WordPress/blob/66f907b2eb0b7adaa57ecfac0e49535fce63a341
/wp-includes/capabilities.php#L210
https://github.com/WordPress/WordPress/blob/66f907b2eb0b7adaa57ecfac0e49535fce63a341
/wp-includes/capabilities.php#L256
https://github.com/WordPress/WordPress/blob/66f907b2eb0b7adaa57ecfac0e49535fce63a341
/wp-includes/capabilities.php#L285
https://github.com/WordPress/WordPress/blob/66f907b2eb0b7adaa57ecfac0e49535fce63a341
/wp-includes/capabilities.php#L374
https://github.com/WordPress/WordPress/blob/66f907b2eb0b7adaa57ecfac0e49535fce63a341
/wp-includes/capabilities.php#L514
Making this change would follow suit with what is done for some other cap
checks, like edit_users:
https://github.com/WordPress/WordPress/blob/66f907b2eb0b7adaa57ecfac0e49535fce63a341
/wp-includes/capabilities.php#L55
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48415>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list