From e5831cfd5a0358b5b8c95dd5a17ca935da82bd6b Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Tue, 26 Mar 2019 11:45:42 +0100 Subject: [PATCH] maintenance: Use the ?? feature together with explode() This gets rid of a few if(), count() and such that make the code appear quite complicated, even if it isn't. Change-Id: Iade6589eba2a9496b28042bfc777b92258b3332a --- maintenance/Maintenance.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 3403e82a06..3476a32a6a 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -862,14 +862,7 @@ abstract class Maintenance { $this->setParam( $options, $option, $param ); } else { $bits = explode( '=', $option, 2 ); - if ( count( $bits ) > 1 ) { - $option = $bits[0]; - $param = $bits[1]; - } else { - $param = 1; - } - - $this->setParam( $options, $option, $param ); + $this->setParam( $options, $bits[0], $bits[1] ?? 1 ); } } elseif ( $arg == '-' ) { # Lonely "-", often used to indicate stdin or stdout. @@ -1252,11 +1245,8 @@ abstract class Maintenance { } if ( isset( $this->mOptions['wiki'] ) ) { $bits = explode( '-', $this->mOptions['wiki'], 2 ); - if ( count( $bits ) == 1 ) { - $bits[] = ''; - } define( 'MW_DB', $bits[0] ); - define( 'MW_PREFIX', $bits[1] ); + define( 'MW_PREFIX', $bits[1] ?? '' ); } elseif ( isset( $this->mOptions['server'] ) ) { // Provide the option for site admins to detect and configure // multiple wikis based on server names. This offers --server -- 2.20.1