From cc7ec36a577161bba06159abd15efddc8a4f745d Mon Sep 17 00:00:00 2001 From: Jforrester Date: Tue, 3 Sep 2019 16:35:48 +0000 Subject: [PATCH] =?utf8?q?Revert=20"Modify=20-=E2=80=94with-extensions=20t?= =?utf8?q?o=20throw=20extension=20dependency=20errors"?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This reverts commit d9eec3c9124d87fd44e6917d5b1512b78352afb3. Reason for revert: Breaking most of CI Bug: T231876 Change-Id: I9b64a2bb770ee2e7ee717669070843814f37e81e --- includes/installer/CliInstaller.php | 12 ++--------- includes/installer/Installer.php | 24 ++++++++-------------- includes/installer/WebInstallerOptions.php | 14 +++++-------- 3 files changed, 15 insertions(+), 35 deletions(-) diff --git a/includes/installer/CliInstaller.php b/includes/installer/CliInstaller.php index 0ff34b086f..424c9d7b78 100644 --- a/includes/installer/CliInstaller.php +++ b/includes/installer/CliInstaller.php @@ -120,11 +120,7 @@ class CliInstaller extends Installer { } $this->setVar( '_Extensions', $status->value ); } elseif ( isset( $options['with-extensions'] ) ) { - $status = $this->findExtensions(); - if ( !$status->isOK() ) { - throw new InstallException( $status ); - } - $this->setVar( '_Extensions', array_keys( $status->value ) ); + $this->setVar( '_Extensions', array_keys( $this->findExtensions() ) ); } // Set up the default skins @@ -135,11 +131,7 @@ class CliInstaller extends Installer { } $skins = $status->value; } else { - $status = $this->findExtensions( 'skins' ); - if ( !$status->isOK() ) { - throw new InstallException( $status ); - } - $skins = array_keys( $status->value ); + $skins = array_keys( $this->findExtensions( 'skins' ) ); } $this->setVar( '_Skins', $skins ); diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 289a721e92..c719c762e3 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -1270,8 +1270,7 @@ abstract class Installer { * * @param string $directory Directory to search in, relative to $IP, must be either "extensions" * or "skins" - * @return Status An object containing an error list. If there were no errors, an associative - * array of information about the extension can be found in $status->value. + * @return array[][] [ $extName => [ 'screenshots' => [ '...' ] ] */ public function findExtensions( $directory = 'extensions' ) { switch ( $directory ) { @@ -1290,40 +1289,33 @@ abstract class Installer { * * @param string $type Either "extension" or "skin" * @param string $directory Directory to search in, relative to $IP - * @return Status An object containing an error list. If there were no errors, an associative - * array of information about the extension can be found in $status->value. + * @return array [ $extName => [ 'screenshots' => [ '...' ] ] */ protected function findExtensionsByType( $type = 'extension', $directory = 'extensions' ) { if ( $this->getVar( 'IP' ) === null ) { - return Status::newGood( [] ); + return []; } $extDir = $this->getVar( 'IP' ) . '/' . $directory; if ( !is_readable( $extDir ) || !is_dir( $extDir ) ) { - return Status::newGood( [] ); + return []; } $dh = opendir( $extDir ); $exts = []; - $status = new Status; while ( ( $file = readdir( $dh ) ) !== false ) { - // skip non-dirs and hidden directories - if ( !is_dir( "$extDir/$file" ) || $file[0] === '.' ) { + if ( !is_dir( "$extDir/$file" ) ) { continue; } - $extStatus = $this->getExtensionInfo( $type, $directory, $file ); - if ( $extStatus->isOK() ) { + $status = $this->getExtensionInfo( $type, $directory, $file ); + if ( $status->isOK() ) { $exts[$file] = $status->value; - } else { - $status->merge( $extStatus ); } } closedir( $dh ); uksort( $exts, 'strnatcasecmp' ); - $status->value = $exts; - - return $status; + return $exts; } /** diff --git a/includes/installer/WebInstallerOptions.php b/includes/installer/WebInstallerOptions.php index 7c1619ab5a..2412319ea3 100644 --- a/includes/installer/WebInstallerOptions.php +++ b/includes/installer/WebInstallerOptions.php @@ -104,7 +104,7 @@ class WebInstallerOptions extends WebInstallerPage { $this->getFieldsetEnd() ); - $skins = $this->parent->findExtensions( 'skins' )->value; + $skins = $this->parent->findExtensions( 'skins' ); $skinHtml = $this->getFieldsetStart( 'config-skins' ); $skinNames = array_map( 'strtolower', array_keys( $skins ) ); @@ -118,7 +118,6 @@ class WebInstallerOptions extends WebInstallerPage { 'value' => $chosenSkinName, ] ); - // @phan-suppress-next-line PhanTypeNoAccessiblePropertiesForeach foreach ( $skins as $skin => $info ) { if ( isset( $info['screenshots'] ) ) { $screenshotText = $this->makeScreenshotsLink( $skin, $info['screenshots'] ); @@ -145,7 +144,7 @@ class WebInstallerOptions extends WebInstallerPage { $this->getFieldsetEnd(); $this->addHTML( $skinHtml ); - $extensions = $this->parent->findExtensions()->value; + $extensions = $this->parent->findExtensions(); $dependencyMap = []; if ( $extensions ) { @@ -154,7 +153,6 @@ class WebInstallerOptions extends WebInstallerPage { $extByType = []; $types = SpecialVersion::getExtensionTypes(); // Sort by type first - // @phan-suppress-next-line PhanTypeNoAccessiblePropertiesForeach foreach ( $extensions as $ext => $info ) { if ( !isset( $info['type'] ) || !isset( $types[$info['type']] ) ) { // We let extensions normally define custom types, but @@ -331,8 +329,6 @@ class WebInstallerOptions extends WebInstallerPage { if ( count( $screenshots ) > 1 ) { $links = []; $counter = 1; - - // @phan-suppress-next-line PhanTypeNoAccessiblePropertiesForeach foreach ( $screenshots as $shot ) { $links[] = Html::element( 'a', @@ -452,7 +448,7 @@ class WebInstallerOptions extends WebInstallerPage { * @return bool */ public function submitSkins() { - $skins = array_keys( $this->parent->findExtensions( 'skins' )->value ); + $skins = array_keys( $this->parent->findExtensions( 'skins' ) ); $this->parent->setVar( '_Skins', $skins ); if ( $skins ) { @@ -502,7 +498,7 @@ class WebInstallerOptions extends WebInstallerPage { $this->setVar( 'wgRightsIcon', '' ); } - $skinsAvailable = array_keys( $this->parent->findExtensions( 'skins' )->value ); + $skinsAvailable = array_keys( $this->parent->findExtensions( 'skins' ) ); $skinsToInstall = []; foreach ( $skinsAvailable as $skin ) { $this->parent->setVarsFromRequest( [ "skin-$skin" ] ); @@ -523,7 +519,7 @@ class WebInstallerOptions extends WebInstallerPage { $retVal = false; } - $extsAvailable = array_keys( $this->parent->findExtensions()->value ); + $extsAvailable = array_keys( $this->parent->findExtensions() ); $extsToInstall = []; foreach ( $extsAvailable as $ext ) { $this->parent->setVarsFromRequest( [ "ext-$ext" ] ); -- 2.20.1