From: Thiemo Kreuz Date: Tue, 26 Mar 2019 10:45:42 +0000 (+0100) Subject: maintenance: Use the ?? feature together with explode() X-Git-Tag: 1.34.0-rc.0~2325^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=e5831cfd5a0358b5b8c95dd5a17ca935da82bd6b;p=lhc%2Fweb%2Fwiklou.git 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 --- 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