From 3796360ba043dd27feb83ac0ad702f2912898efc Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 6 Jul 2022 10:32:12 +0000 Subject: [PATCH] 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 --- wp-includes/version.php | 2 +- wp-includes/wp-db.php | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/wp-includes/version.php b/wp-includes/version.php index 9ee46e5db0..52a4cb647d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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. diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index d61fc4f0a6..6dc7857152 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -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 ); }