Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit f679cae

Browse files
committed
Finished querying extension version. See readme.
1 parent d27ed93 commit f679cae

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,17 @@ This return
7575

7676
It takes two arguments :
7777

78-
**Extension name** tba
78+
**Extension name** ( Name of the extension to query )
7979

80-
**type** tba
80+
**type** ( Query type, currenly only **version** is supported )
81+
82+
Example :
83+
```wikitext
84+
{{#w8y:action=extension
85+
|Extension name=ParserFunctions
86+
|type=version
87+
}}
88+
```
8189

8290
## Lua
8391
Call are the same as for the parser functions.

includes/Scribunto/ScribuntoLuaLibrary.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ public function w8y( ?array $arguments ): array {
4242
switch ( $action ) {
4343
case "extension":
4444
$eName = Utils::getOptionSetting( 'Extension name', true, $arguments );
45-
if ( $eName === null ) {
45+
$eVersion = Utils::getOptionSetting( 'version', true, $arguments );
46+
if ( $eName === null || $eVersion === null ) {
4647
return [];
4748
}
4849
$query = new Extensions();
49-
$result = $query->doQuery( $eName, 'lua' );
50+
$result = $query->doQuery( $eName, $eVersion, 'lua' );
5051
return [ $this->convertToLuaTable( $result ) ];
5152
case "wiki":
5253
$id = Utils::getOptionSetting( 'id', true, $arguments );

includes/TagHooks.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ public function w8y( Parser &$parser ): mixed {
5050
switch ( $action ) {
5151
case "extension":
5252
$eName = Utils::getOptionSetting( 'Extension name' );
53-
if ( $eName === null ) {
53+
$eType = Utils::getOptionSetting( 'type' );
54+
if ( $eName === null || $eType === null ) {
5455
break;
5556
}
5657
$extension = new Extensions();
57-
$result = $extension->doQuery( $eName );
58+
$result = $extension->doQuery( $eName, $eType );
5859
break;
5960
case "query":
6061
$query = new Query();

includes/data/query/Extensions.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,23 @@ private function getExtensionVersions( string $extensionName, DBConnRef $dbr ) {
6767

6868
/**
6969
* @param string $extensionName
70+
* @param string $queryType
7071
* @param string $export
7172
*
7273
* @return mixed
7374
*/
74-
public function doQuery( string $extensionName, string $export = "table" ): mixed {
75+
public function doQuery( string $extensionName, string $queryType, string $export = "table" ): mixed {
7576
$lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
7677
$dbr = $lb->getConnectionRef( DB_REPLICA );
7778
$result = [];
7879

79-
$result = $this->getExtensionVersions( $extensionName, $dbr );
80+
switch ( $queryType ) {
81+
case "version":
82+
$result = $this->getExtensionVersions( $extensionName, $dbr );
83+
break;
84+
default:
85+
$result = [];
86+
}
8087

8188
switch ( $export ) {
8289
case "table":

0 commit comments

Comments
 (0)