Coding Standards: Simplify the logic for setting DB host and port in `wpdb::parse_db_host()`.
This removes an extra `foreach` loop and the only variable variable (`$$component`) in core. Follow-up to [20088,28342,28736-28747], [41629], [41820], [42226], [53670]. Props johnjamesjacoby. See #54877, #55647. Built from https://develop.svn.wordpress.org/trunk@53671 git-svn-id: http://core.svn.wordpress.org/trunk@53230 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d7d9adbf02
commit
3796360ba0
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.1-alpha-53670';
|
||||
$wp_version = '6.1-alpha-53671';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
|
@ -2041,7 +2041,6 @@ class wpdb {
|
|||
* }
|
||||
*/
|
||||
public function parse_db_host( $host ) {
|
||||
$port = null;
|
||||
$socket = null;
|
||||
$is_ipv6 = false;
|
||||
|
||||
|
@ -2070,15 +2069,9 @@ class wpdb {
|
|||
return false;
|
||||
}
|
||||
|
||||
$host = '';
|
||||
foreach ( array( 'host', 'port' ) as $component ) {
|
||||
if ( ! empty( $matches[ $component ] ) ) {
|
||||
$$component = $matches[ $component ];
|
||||
}
|
||||
}
|
||||
|
||||
$host = ! empty( $matches['host'] ) ? $matches['host'] : '';
|
||||
// MySQLi port cannot be a string; must be null or an integer.
|
||||
$port = $port ? absint( $port ) : null;
|
||||
$port = ! empty( $matches['port'] ) ? absint( $matches['port'] ) : null;
|
||||
|
||||
return array( $host, $port, $socket, $is_ipv6 );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue