From: Perside Rosalie Date: Sun, 25 Oct 2015 23:55:47 +0000 (+0100) Subject: Changed paths to package dependency file X-Git-Tag: 1.31.0-rc.0~9243 X-Git-Url: https://git.cyclocoop.org/%27%20.%20%24this-%3EgetSkin%28%29-%3EescapeSearchLink%28%29%20.%20%27?a=commitdiff_plain;h=6ba942258aa3ccfa3a21ecc318e733a0b7910c61;p=lhc%2Fweb%2Fwiklou.git Changed paths to package dependency file Paths to ./composer.lock is changed to ./vendor/composer/installed.json and dependency information now is read from the installed.json file. A new ComposerInstalled class has been declared and uses the class now to access the getInstalledDependencies() method to read data Bug: T106247 Change-Id: Ic216577bb19b4fc5832ba003fcbbe9195d707b41 --- diff --git a/autoload.php b/autoload.php index 9b5e10f868..731bdaaf5f 100644 --- a/autoload.php +++ b/autoload.php @@ -242,6 +242,7 @@ $wgAutoloadLocalClasses = array( 'CompareParserCache' => __DIR__ . '/maintenance/compareParserCache.php', 'CompareParsers' => __DIR__ . '/maintenance/compareParsers.php', 'ComposerHookHandler' => __DIR__ . '/includes/composer/ComposerHookHandler.php', + 'ComposerInstalled' => __DIR__ . '/includes/libs/composer/ComposerInstalled.php', 'ComposerJson' => __DIR__ . '/includes/libs/composer/ComposerJson.php', 'ComposerLock' => __DIR__ . '/includes/libs/composer/ComposerLock.php', 'ComposerPackageModifier' => __DIR__ . '/includes/composer/ComposerPackageModifier.php', diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index 1265155809..c13b30b47f 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -540,18 +540,14 @@ class ApiQuerySiteinfo extends ApiQueryBase { protected function appendInstalledLibraries( $property ) { global $IP; - $path = "$IP/composer.lock"; + $path = "$IP/vendor/composer/installed.json"; if ( !file_exists( $path ) ) { - // Maybe they're using mediawiki/vendor? - $path = "$IP/vendor/composer.lock"; - if ( !file_exists( $path ) ) { - return true; - } + return true; } $data = array(); - $lock = new ComposerLock( $path ); - foreach ( $lock->getInstalledDependencies() as $name => $info ) { + $installed = new ComposerInstalled( $path ); + foreach ( $installed->getInstalledDependencies() as $name => $info ) { if ( strpos( $info['type'], 'mediawiki-' ) === 0 ) { // Skip any extensions or skins since they'll be listed // in their proper section diff --git a/includes/libs/composer/ComposerInstalled.php b/includes/libs/composer/ComposerInstalled.php new file mode 100644 index 0000000000..5f87b54b1d --- /dev/null +++ b/includes/libs/composer/ComposerInstalled.php @@ -0,0 +1,38 @@ +contents = json_decode( file_get_contents( $location ), true ); + } + + /** + * Dependencies currently installed according to installed.json + * + * @return array + */ + public function getInstalledDependencies() { + $deps = array(); + foreach ( $this->contents as $installed ) { + $deps[$installed['name']] = array( + 'version' => ComposerJson::normalizeVersion( $installed['version'] ), + 'type' => $installed['type'], + 'licenses' => isset( $installed['license'] ) ? $installed['license'] : array(), + 'authors' => isset( $installed['authors'] ) ? $installed['authors'] : array(), + 'description' => isset( $installed['description'] ) ? $installed['description']: '', + ); + } + + ksort( $deps ); + return $deps; + } +} diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index 38baf5b953..7e0f0b2629 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -518,16 +518,12 @@ class SpecialVersion extends SpecialPage { */ protected function getExternalLibraries() { global $IP; - $path = "$IP/composer.lock"; + $path = "$IP/vendor/composer/installed.json"; if ( !file_exists( $path ) ) { - // Maybe they're using mediawiki/vendor? - $path = "$IP/vendor/composer.lock"; - if ( !file_exists( $path ) ) { - return ''; - } + return ''; } - $lock = new ComposerLock( $path ); + $installed = new ComposerInstalled( $path ); $out = Html::element( 'h2', array( 'id' => 'mw-version-libraries' ), @@ -545,7 +541,7 @@ class SpecialVersion extends SpecialPage { . Html::element( 'th', array(), $this->msg( 'version-libraries-authors' )->text() ) . Html::closeElement( 'tr' ); - foreach ( $lock->getInstalledDependencies() as $name => $info ) { + foreach ( $installed->getInstalledDependencies() as $name => $info ) { if ( strpos( $info['type'], 'mediawiki-' ) === 0 ) { // Skip any extensions or skins since they'll be listed // in their proper section