[wp-trac] [WordPress Trac] #54453: Warning: Undefined array key 0 in /app/news/wp-includes/wp-db.php on line 1323

WordPress Trac noreply at wordpress.org
Tue Nov 16 11:40:27 UTC 2021


#54453: Warning: Undefined array key 0 in /app/news/wp-includes/wp-db.php on line
1323
--------------------------+-----------------------------
 Reporter:  mjaschen      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Database      |    Version:  5.8.2
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 When using `$wpdb->prepare()` without passing values to `...$args` (i.e.
 preparing a query without bound values), a warning is issued by PHP >=
 8.0:

 {{{
 Warning: Undefined array key 0 in /app/news/wp-includes/wp-db.php on line
 1323
 }}}

 Reason: it's assumed that at least one value is bound to the query by
 passing method arguments besides the query string which is not necessarily
 the case.

 The fix: just check if the array contains a value at index 0 before using
 it.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54453>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list