[wp-trac] [WordPress Trac] #32073: Undefined offset: 0 warning in wp-includes\capabilities.php on line 1119
WordPress Trac
noreply at wordpress.org
Wed Apr 22 23:35:32 UTC 2015
#32073: Undefined offset: 0 warning in wp-includes\capabilities.php on line 1119
--------------------------+-----------------------------
Reporter: hubertnguyen | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.1.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
Hello,
I'm sometime getting a PHP Notice:
Notice: Undefined offset: 0 in \wp-includes\capabilities.php on line 1119
It happens when $args is empty.
$post = get_post( $args[0] );
I've seen someone else complain of the same thing in the support forum:
https://wordpress.org/support/topic/php-error-on-addingupdating-
woocommerce-product
There is no real functional issues, but when developing with WP_DEBUG = 1,
this creates warnings that are a bit annoying. since get_post() supports a
null argument, would it be OK to do something like this:
if (empty($args)) {$post = get_post( null );}
else { $post = get_post( $args[0] ); }
Thank you,
--
Ticket URL: <https://core.trac.wordpress.org/ticket/32073>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list