Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/190348

Change subject: Expose installed libraries in action=query&meta=siteinfo
......................................................................

Expose installed libraries in action=query&meta=siteinfo

Bug: T89385
Change-Id: I4256f4d9858c09c042f649b7e701189acf85aedd
---
M includes/api/ApiQuerySiteinfo.php
M includes/api/i18n/en.json
2 files changed, 35 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/48/190348/1

diff --git a/includes/api/ApiQuerySiteinfo.php 
b/includes/api/ApiQuerySiteinfo.php
index 4e5c42b..5ac1036 100644
--- a/includes/api/ApiQuerySiteinfo.php
+++ b/includes/api/ApiQuerySiteinfo.php
@@ -69,6 +69,9 @@
                                case 'usergroups':
                                        $fit = $this->appendUserGroups( $p, 
$params['numberingroup'] );
                                        break;
+                               case 'libraries':
+                                       $fit = $this->appendInstalledLibraries( 
$p );
+                                       break;
                                case 'extensions':
                                        $fit = $this->appendExtensions( $p );
                                        break;
@@ -554,6 +557,36 @@
                return $this->getResult()->addValue( 'query', $property, $data 
);
        }
 
+       protected function appendInstalledLibraries( $property ) {
+               global $IP;
+               $path = "$IP/composer.lock";
+               if ( !file_exists( $path ) ) {
+                       // Maybe they're using mediawiki/vendor?
+                       $path = "$IP/vendor/composer.lock";
+                       if ( !file_exists( $path ) ) {
+                               return true;
+                       }
+               }
+
+               $data = array();
+               $lock = new ComposerLock( $path );
+               foreach ( $lock->getInstalledDependencies() as $name => $info ) 
{
+                       if ( strpos( $info['type'], 'mediawiki-' ) === 0 ) {
+                               // Skip any extensions or skins since they'll 
be listed
+                               // in their proper section
+                               continue;
+                       }
+                       $data[] = array(
+                               'name' => $name,
+                               'version' => $info['version'],
+                       );
+               }
+               $this->getResult()->setIndexedTagName( $data, 'library' );
+
+               return $this->getResult()->addValue( 'query', $property, $data 
);
+
+       }
+
        protected function appendExtensions( $property ) {
                $data = array();
                foreach ( $this->getConfig()->get( 'ExtensionCredits' ) as 
$type => $extensions ) {
@@ -810,6 +843,7 @@
                                        'dbrepllag',
                                        'statistics',
                                        'usergroups',
+                                       'libraries',
                                        'extensions',
                                        'fileextensions',
                                        'rightsinfo',
diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json
index 0e766bf..76f0461 100644
--- a/includes/api/i18n/en.json
+++ b/includes/api/i18n/en.json
@@ -871,7 +871,7 @@
        "apihelp-query+search-example-generator": "Ger page info about the 
pages returned for a search for <kbd>meaning</kbd>.",
 
        "apihelp-query+siteinfo-description": "Return general information about 
the site.",
-       "apihelp-query+siteinfo-param-prop": "Which information to 
get:\n;general:Overall system information.\n;namespaces:List of registered 
namespaces and their canonical names.\n;namespacealiases:List of registered 
namespace aliases.\n;specialpagealiases:List of special page 
aliases.\n;magicwords:List of magic words and their 
aliases.\n;statistics:Returns site statistics.\n;interwikimap:Returns interwiki 
map (optionally filtered, optionally localised by using 
<var>$1inlanguagecode</var>).\n;dbrepllag:Returns database server with the 
highest replication lag.\n;usergroups:Returns user groups and the associated 
permissions.\n;extensions:Returns extensions installed on the 
wiki.\n;fileextensions:Returns list of file extensions allowed to be 
uploaded.\n;rightsinfo:Returns wiki rights (license) information if 
available.\n;restrictions:Returns information on available restriction 
(protection) types.\n;languages:Returns a list of languages MediaWiki supports 
(optionally localised by using <var>$1inlanguagecode</var>).\n;skins:Returns a 
list of all enabled skins (optionally localised by using 
<var>$1inlanguagecode</var>, otherwise in the content 
language).\n;extensiontags:Returns a list of parser extension 
tags.\n;functionhooks:Returns a list of parser function 
hooks.\n;showhooks:Returns a list of all subscribed hooks (contents of 
<var>[[mw:Manual:$wgHooks|$wgHooks]]</var>).\n;variables:Returns a list of 
variable IDs.\n;protocols:Returns a list of protocols that are allowed in 
external links.\n;defaultoptions:Returns the default values for user 
preferences.",
+       "apihelp-query+siteinfo-param-prop": "Which information to 
get:\n;general:Overall system information.\n;namespaces:List of registered 
namespaces and their canonical names.\n;namespacealiases:List of registered 
namespace aliases.\n;specialpagealiases:List of special page 
aliases.\n;magicwords:List of magic words and their 
aliases.\n;statistics:Returns site statistics.\n;interwikimap:Returns interwiki 
map (optionally filtered, optionally localised by using 
<var>$1inlanguagecode</var>).\n;dbrepllag:Returns database server with the 
highest replication lag.\n;usergroups:Returns user groups and the associated 
permissions.\n;libraries:Returns libraries installed on the wiki. 
\n;extensions:Returns extensions installed on the 
wiki.\n;fileextensions:Returns list of file extensions allowed to be 
uploaded.\n;rightsinfo:Returns wiki rights (license) information if 
available.\n;restrictions:Returns information on available restriction 
(protection) types.\n;languages:Returns a list of languages MediaWiki supports 
(optionally localised by using <var>$1inlanguagecode</var>).\n;skins:Returns a 
list of all enabled skins (optionally localised by using 
<var>$1inlanguagecode</var>, otherwise in the content 
language).\n;extensiontags:Returns a list of parser extension 
tags.\n;functionhooks:Returns a list of parser function 
hooks.\n;showhooks:Returns a list of all subscribed hooks (contents of 
<var>[[mw:Manual:$wgHooks|$wgHooks]]</var>).\n;variables:Returns a list of 
variable IDs.\n;protocols:Returns a list of protocols that are allowed in 
external links.\n;defaultoptions:Returns the default values for user 
preferences.",
        "apihelp-query+siteinfo-param-filteriw": "Return only local or only 
nonlocal entries of the interwiki map.",
        "apihelp-query+siteinfo-param-showalldb": "List all database servers, 
not just the one lagging the most.",
        "apihelp-query+siteinfo-param-numberingroup": "Lists the number of 
users in user groups.",

-- 
To view, visit https://gerrit.wikimedia.org/r/190348
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4256f4d9858c09c042f649b7e701189acf85aedd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to