NikiWiki (Code Review)
2017-12-30 20:38:55 UTC
NikiWiki has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/401094 )
Change subject: Specials: Add LibraryInfoHook
......................................................................
Specials: Add LibraryInfoHook
I would like to extend Extension:ControlSpecialVersion to be able to
hide the versions of the installed libraries. It already does so for
php, extensions, etc.
To accomplish this, a hook in SpecialVersions::getExternalLibraries is
needed.
Similar hooks already exist for softwareInformation, getExtensionTypes
and other information about versions.
I considered adding the hook to ComposerInstalled, however I prefer to
keep that as a source of truth and only allow changing the presentation.
Change-Id: I3b0f31f2a9b9ee379781d13555cd186739f02a6f
---
M docs/hooks.txt
M includes/specials/SpecialVersion.php
2 files changed, 11 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/94/401094/1
diff --git a/docs/hooks.txt b/docs/hooks.txt
index 45387a3..75f1e8a 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -1538,6 +1538,12 @@
change the tables headers.
&$extTypes: associative array of extensions types
+'ExternalLibraryInfo': Called by Special:Version for returning information about the
+installed external libraries.
+&$software: The array of software in format 'name' => ['version', 'type', 'licenses'
+, 'authors', 'description']. See
+ ComposerInstalled::getInstalledDependencies().
+
'FetchChangesList': When fetching the ChangesList derivative for a particular
user.
$user: User the list is being fetched for
diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php
index f176b40..b2530c9 100644
--- a/includes/specials/SpecialVersion.php
+++ b/includes/specials/SpecialVersion.php
@@ -488,7 +488,10 @@
return '';
}
- $installed = new ComposerInstalled( $path );
+ $composerInstalled = new ComposerInstalled( $path );
+ $installed = $composerInstalled->getInstalledDependencies();
+ Hooks::run( 'ExternalLibraryInfo', [ &$installed ] );
+
$out = Html::element(
'h2',
[ 'id' => 'mw-version-libraries' ],
@@ -506,7 +509,7 @@
. Html::element( 'th', [], $this->msg( 'version-libraries-authors' )->text() )
. Html::closeElement( 'tr' );
- foreach ( $installed->getInstalledDependencies() as $name => $info ) {
+ foreach ( $installed as $name => $info ) {
if ( strpos( $info['type'], 'mediawiki-' ) === 0 ) {
// Skip any extensions or skins since they'll be listed
// in their proper section
--
To view, visit https://gerrit.wikimedia.org/r/401094
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3b0f31f2a9b9ee379781d13555cd186739f02a6f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: NikiWiki <mf-***@hansche.de>
Change subject: Specials: Add LibraryInfoHook
......................................................................
Specials: Add LibraryInfoHook
I would like to extend Extension:ControlSpecialVersion to be able to
hide the versions of the installed libraries. It already does so for
php, extensions, etc.
To accomplish this, a hook in SpecialVersions::getExternalLibraries is
needed.
Similar hooks already exist for softwareInformation, getExtensionTypes
and other information about versions.
I considered adding the hook to ComposerInstalled, however I prefer to
keep that as a source of truth and only allow changing the presentation.
Change-Id: I3b0f31f2a9b9ee379781d13555cd186739f02a6f
---
M docs/hooks.txt
M includes/specials/SpecialVersion.php
2 files changed, 11 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/94/401094/1
diff --git a/docs/hooks.txt b/docs/hooks.txt
index 45387a3..75f1e8a 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -1538,6 +1538,12 @@
change the tables headers.
&$extTypes: associative array of extensions types
+'ExternalLibraryInfo': Called by Special:Version for returning information about the
+installed external libraries.
+&$software: The array of software in format 'name' => ['version', 'type', 'licenses'
+, 'authors', 'description']. See
+ ComposerInstalled::getInstalledDependencies().
+
'FetchChangesList': When fetching the ChangesList derivative for a particular
user.
$user: User the list is being fetched for
diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php
index f176b40..b2530c9 100644
--- a/includes/specials/SpecialVersion.php
+++ b/includes/specials/SpecialVersion.php
@@ -488,7 +488,10 @@
return '';
}
- $installed = new ComposerInstalled( $path );
+ $composerInstalled = new ComposerInstalled( $path );
+ $installed = $composerInstalled->getInstalledDependencies();
+ Hooks::run( 'ExternalLibraryInfo', [ &$installed ] );
+
$out = Html::element(
'h2',
[ 'id' => 'mw-version-libraries' ],
@@ -506,7 +509,7 @@
. Html::element( 'th', [], $this->msg( 'version-libraries-authors' )->text() )
. Html::closeElement( 'tr' );
- foreach ( $installed->getInstalledDependencies() as $name => $info ) {
+ foreach ( $installed as $name => $info ) {
if ( strpos( $info['type'], 'mediawiki-' ) === 0 ) {
// Skip any extensions or skins since they'll be listed
// in their proper section
--
To view, visit https://gerrit.wikimedia.org/r/401094
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3b0f31f2a9b9ee379781d13555cd186739f02a6f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: NikiWiki <mf-***@hansche.de>