[MediaWiki-commits] [Gerrit] API: Add prop=redirects and list=allredirects - change (mediawiki/core)
jenkins-bot has submitted this change and it was merged. Change subject: API: Add prop=redirects and list=allredirects .. API: Add prop=redirects and list=allredirects While redirects can be sort-of queried using list=backlinks with blfilterredir=redirects, we can get more accurate results with a module dedicated to this purpose. We can also get the fragment of the redirect without having to load the content of the redirect page and parse it. I'm a bit surprised I was able to put together a query for this that will work as a prop module. Or did I overlook something? And then we may as well add the corresponding list=allredirects, to work like alllinks, allfileusages, and alltransclusions. Bug: 57057 Change-Id: I81082aa9e4e3a3b2c66cc4f9970a97eed83a6a4f --- M RELEASE-NOTES-1.23 M includes/AutoLoader.php M includes/api/ApiQuery.php M includes/api/ApiQueryAllLinks.php A includes/api/ApiQueryRedirects.php 5 files changed, 324 insertions(+), 17 deletions(-) Approvals: Aaron Schulz: Looks good to me, approved jenkins-bot: Verified diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23 index 2350b8e..adf17b5 100644 --- a/RELEASE-NOTES-1.23 +++ b/RELEASE-NOTES-1.23 @@ -187,6 +187,8 @@ * (bug 58627) Provide language names on action=parseprop=langlinks. * Deprecated llurl= in favour of llprop=url for action=queryprop=langlinks. * Added llprop=langname and llprop=autonym for action=queryprop=langlinks. +* prop=redirects is added, to return redirects to the pages in the query. +* list=allredirects is added, to list all redirects pointing to a namespace. === Languages updated in 1.23 === diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 54635e9..9a6d90b 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -355,6 +355,7 @@ 'ApiQueryRandom' = 'includes/api/ApiQueryRandom.php', 'ApiQueryRecentChanges' = 'includes/api/ApiQueryRecentChanges.php', 'ApiQueryFileRepoInfo' = 'includes/api/ApiQueryFileRepoInfo.php', + 'ApiQueryRedirects' = 'includes/api/ApiQueryRedirects.php', 'ApiQueryRevisions' = 'includes/api/ApiQueryRevisions.php', 'ApiQuerySearch' = 'includes/api/ApiQuerySearch.php', 'ApiQuerySiteinfo' = 'includes/api/ApiQuerySiteinfo.php', diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index c054bc1..49ab591 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -54,6 +54,7 @@ 'iwlinks' = 'ApiQueryIWLinks', 'langlinks' = 'ApiQueryLangLinks', 'pageprops' = 'ApiQueryPageProps', + 'redirects' = 'ApiQueryRedirects', 'revisions' = 'ApiQueryRevisions', 'stashimageinfo' = 'ApiQueryStashImageInfo', 'templates' = 'ApiQueryLinks', @@ -69,6 +70,7 @@ 'allimages' = 'ApiQueryAllImages', 'alllinks' = 'ApiQueryAllLinks', 'allpages' = 'ApiQueryAllPages', + 'allredirects' = 'ApiQueryAllLinks', 'alltransclusions' = 'ApiQueryAllLinks', 'allusers' = 'ApiQueryAllUsers', 'backlinks' = 'ApiQueryBacklinks', diff --git a/includes/api/ApiQueryAllLinks.php b/includes/api/ApiQueryAllLinks.php index bccc25f..7b5123d 100644 --- a/includes/api/ApiQueryAllLinks.php +++ b/includes/api/ApiQueryAllLinks.php @@ -31,15 +31,21 @@ */ class ApiQueryAllLinks extends ApiQueryGeneratorBase { + private $table, $tablePrefix, $indexTag, + $description, $descriptionWhat, $descriptionTargets, $descriptionLinking; + private $fieldTitle = 'title'; + private $dfltNamespace = NS_MAIN; + private $hasNamespace = true; + private $useIndex = null; + private $props = array(), $propHelp = array(); + public function __construct( $query, $moduleName ) { switch ( $moduleName ) { case 'alllinks': $prefix = 'al'; $this-table = 'pagelinks'; $this-tablePrefix = 'pl_'; - $this-fieldTitle = 'title'; - $this-dfltNamespace = NS_MAIN; - $this-hasNamespace = true; + $this-useIndex = 'pl_namespace'; $this-indexTag = 'l'; $this-description = 'Enumerate all links that point to a given namespace'; $this-descriptionWhat = 'link'; @@ -50,9 +56,8 @@ $prefix = 'at'; $this-table = 'templatelinks'; $this-tablePrefix = 'tl_'; - $this-fieldTitle = 'title'; $this-dfltNamespace = NS_TEMPLATE; -
[MediaWiki-commits] [Gerrit] API: Add prop=redirects and list=allredirects - change (mediawiki/core)
Anomie has uploaded a new change for review. https://gerrit.wikimedia.org/r/104764 Change subject: API: Add prop=redirects and list=allredirects .. API: Add prop=redirects and list=allredirects While redirects can be sort-of queried using list=backlinks with blfilterredir=redirects, we can get more accurate results with a module dedicated to this purpose. We can also get the fragment of the redirect without having to load the content of the redirect page and parse it. I'm a bit surprised I was able to put together a query for this that will work as a prop module. Or did I overlook something? And then we may as well add the corresponding list=allredirects, to work like alllinks, allfileusages, and alltransclusions. Change-Id: I81082aa9e4e3a3b2c66cc4f9970a97eed83a6a4f --- M RELEASE-NOTES-1.23 M includes/AutoLoader.php M includes/api/ApiQuery.php M includes/api/ApiQueryAllLinks.php A includes/api/ApiQueryRedirects.php 5 files changed, 323 insertions(+), 17 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/64/104764/1 diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23 index a43ab03..4f01cdc 100644 --- a/RELEASE-NOTES-1.23 +++ b/RELEASE-NOTES-1.23 @@ -92,6 +92,8 @@ properly for all parameters. * ApiQueryBase::titlePartToKey allows an extra parameter that indicates the namespace in order to properly capitalize the title part. +* prop=redirects is added, to return redirects to the pages in the query. +* list=allredirects is added, to list all redirects pointing to a namespace. === Languages updated in 1.23 === diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index 1f81249..b9cc324 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -359,6 +359,7 @@ 'ApiQueryRandom' = 'includes/api/ApiQueryRandom.php', 'ApiQueryRecentChanges' = 'includes/api/ApiQueryRecentChanges.php', 'ApiQueryFileRepoInfo' = 'includes/api/ApiQueryFileRepoInfo.php', + 'ApiQueryRedirects' = 'includes/api/ApiQueryRedirects.php', 'ApiQueryRevisions' = 'includes/api/ApiQueryRevisions.php', 'ApiQuerySearch' = 'includes/api/ApiQuerySearch.php', 'ApiQuerySiteinfo' = 'includes/api/ApiQuerySiteinfo.php', diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index cec1ca8..fbf04ab 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -53,6 +53,7 @@ 'iwlinks' = 'ApiQueryIWLinks', 'langlinks' = 'ApiQueryLangLinks', 'pageprops' = 'ApiQueryPageProps', + 'redirects' = 'ApiQueryRedirects', 'revisions' = 'ApiQueryRevisions', 'stashimageinfo' = 'ApiQueryStashImageInfo', 'templates' = 'ApiQueryLinks', @@ -68,6 +69,7 @@ 'allimages' = 'ApiQueryAllImages', 'alllinks' = 'ApiQueryAllLinks', 'allpages' = 'ApiQueryAllPages', + 'allredirects' = 'ApiQueryAllLinks', 'alltransclusions' = 'ApiQueryAllLinks', 'allusers' = 'ApiQueryAllUsers', 'backlinks' = 'ApiQueryBacklinks', diff --git a/includes/api/ApiQueryAllLinks.php b/includes/api/ApiQueryAllLinks.php index 5be304d..577d36a 100644 --- a/includes/api/ApiQueryAllLinks.php +++ b/includes/api/ApiQueryAllLinks.php @@ -31,15 +31,21 @@ */ class ApiQueryAllLinks extends ApiQueryGeneratorBase { + private $table, $tablePrefix, $indexTag, + $description, $descriptionWhat, $descriptionTargets, $descriptionLinking; + private $fieldTitle = 'title'; + private $dfltNamespace = NS_MAIN; + private $hasNamespace = true; + private $useIndex = null; + private $props = array(), $propHelp = array(); + public function __construct( $query, $moduleName ) { switch ( $moduleName ) { case 'alllinks': $prefix = 'al'; $this-table = 'pagelinks'; $this-tablePrefix = 'pl_'; - $this-fieldTitle = 'title'; - $this-dfltNamespace = NS_MAIN; - $this-hasNamespace = true; + $this-useIndex = 'pl_namespace'; $this-indexTag = 'l'; $this-description = 'Enumerate all links that point to a given namespace'; $this-descriptionWhat = 'link'; @@ -50,9 +56,8 @@ $prefix = 'at'; $this-table = 'templatelinks'; $this-tablePrefix = 'tl_'; - $this-fieldTitle = 'title'; $this-dfltNamespace = NS_TEMPLATE; - $this-hasNamespace