From: Bill Pirkle Date: Thu, 11 Jul 2019 02:16:49 +0000 (-0500) Subject: Allow PHP version check to execute on older versions of PHP X-Git-Tag: 1.34.0-rc.0~1076^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/voir.php?a=commitdiff_plain;h=b8b2514940e0e3a52e9d27f5432cdbb4d7f0c8b5;p=lhc%2Fweb%2Fwiklou.git Allow PHP version check to execute on older versions of PHP A change to update.php used the null coalesce (??) operator. While this is normally fine, the code in question executes before the PHP version check, and causes an unfriendly PHP error rather than the intended helpful error. Use the older-style isset() call instead, so that the PHP version check will get a chance to execute. Bug: T213893 Change-Id: I22e4a24bed9e0b29e08afc7b9468e7bfd81d7d57 --- diff --git a/maintenance/update.php b/maintenance/update.php index fe405364c9..73edda9ed7 100755 --- a/maintenance/update.php +++ b/maintenance/update.php @@ -247,17 +247,26 @@ class UpdateMediaWiki extends Maintenance { ]; } + /** + * @throws FatalError + * @throws MWException + * @suppress PhanPluginDuplicateConditionalNullCoalescing + */ public function validateParamsAndArgs() { // Allow extensions to add additional params. $params = []; Hooks::run( 'MaintenanceUpdateAddParams', [ &$params ] ); + + // This executes before the PHP version check, so don't use null coalesce (??). + // Keeping this compatible with older PHP versions lets us reach the code that + // displays a more helpful error. foreach ( $params as $name => $param ) { $this->addOption( $name, $param['desc'], - $param['require'] ?? false, - $param['withArg'] ?? false, - $param['shortName'] ?? false, + isset( $param['require'] ) ? $param['require'] : false, + isset( $param['withArg'] ) ? $param['withArg'] : false, + isset( $param['shortName'] ) ? $param['shortName'] : false, $param['multiOccurrence'] ?? false ); }