[wp-trac] [WordPress Trac] #54877: Occasional PHP exception being thrown on WPDB/MySQLi connections

WordPress Trac noreply at wordpress.org
Fri Jan 21 20:16:26 UTC 2022


#54877: Occasional PHP exception being thrown on WPDB/MySQLi connections
-----------------------------------+---------------------
 Reporter:  johnjamesjacoby        |       Owner:  (none)
     Type:  enhancement            |      Status:  new
 Priority:  normal                 |   Milestone:  6.0
Component:  Database               |     Version:  1.5
 Severity:  normal                 |  Resolution:
 Keywords:  2nd-opinion has-patch  |     Focuses:
-----------------------------------+---------------------
Changes (by johnjamesjacoby):

 * keywords:  2nd-opinion => 2nd-opinion has-patch


Comment:

 [https://core.trac.wordpress.org/attachment/ticket/54877/54877.patch
 54877.patch] proposes the following minimum change:

 After parsing and before returning:

 * When `$port` is truthy, return `absint( $port )`
 * When `$port` is falsy, return `null`

 ----

 A more comprehensive change could refactor the following code, removing
 the `foreach` loop & removing the only variable-variable (`$$component`)
 in WordPress:

 {{{
                 foreach ( array( 'host', 'port' ) as $component ) {
                         if ( ! empty( $matches[ $component ] ) ) {
                                 $$component = $matches[ $component ];
                         }
                 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54877#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list