From 153ade3fb6a93162dabb3be8ea7fcd3289cc88d8 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 28 Aug 2018 12:29:04 -0700 Subject: [PATCH] registration: Short-circuit if dependency constraint is '*' Most extensions depend upon any version of other extensions/skins since versioning is pretty inconsistent. Since '*' is so commonly used, explicitly short-circuit that constraint since we only need to check whether the dependency is loaded. Bug: T198044 Change-Id: I5526c8068d3b9a6ee5ca71ea6bdbcd693f1ffb7a --- includes/registration/VersionChecker.php | 26 ++++++++++-------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/includes/registration/VersionChecker.php b/includes/registration/VersionChecker.php index 59853b42ba..1569e088b8 100644 --- a/includes/registration/VersionChecker.php +++ b/includes/registration/VersionChecker.php @@ -183,23 +183,19 @@ class VersionChecker { 'missing' => $dependencyName, ]; } + if ( $constraint === '*' ) { + // short-circuit since any version is OK. + return false; + } // Check if the dependency has specified a version if ( !isset( $this->loaded[$dependencyName]['version'] ) ) { - // If we depend upon any version, and none is set, that's fine. - if ( $constraint === '*' ) { - wfDebug( "{$dependencyName} does not expose its version, but {$checkedExt}" - . " mentions it with constraint '*'. Assume it's ok so." ); - return false; - } else { - // Otherwise, mark it as incompatible. - $msg = "{$dependencyName} does not expose its version, but {$checkedExt}" - . " requires: {$constraint}."; - return [ - 'msg' => $msg, - 'type' => "incompatible-$type", - 'incompatible' => $checkedExt, - ]; - } + $msg = "{$dependencyName} does not expose its version, but {$checkedExt}" + . " requires: {$constraint}."; + return [ + 'msg' => $msg, + 'type' => "incompatible-$type", + 'incompatible' => $checkedExt, + ]; } else { // Try to get a constraint for the dependency version try { -- 2.20.1