Page MenuHomePhabricator

Add api action for Special:PageLanguage
Closed, ResolvedPublic

Description

Setting

$wgPageLanguageUseDB = true;
$wgGroupPermissions['sysop']['pagelang'] = true;

in the LocalSettings.php allows to specify another page language for a page over Special:PageLanguage.

I have not found a api action for this to allow doing this as bot or over ajax.

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 3:45 AM
bzimport set Reference to bz72958.
bzimport added a subscriber: Unknown Object (MLST).
TTO edited subscribers, added: TTO; removed: wikibugs-l-list.

A possible schema for doing this as a Google-Code-In-2016 student:

  • Start with the ApiDelete module as a template.
  • The general process:
  1. Check whether the user has the pagelang right (and applychangetags right if the tags parameter was specified)
  2. Set the page's language by calling a function on the SpecialPageLanguage class (you will need to refactor the logic there, so that the actual language-change logic is in a common function that can be called by both the special page and the API)
  3. Return output similar to the output of action=delete, which is as follows:
{
    "delete": {
        "title": "Main Page",
        "reason": "content was: 'content goes here' and the only contributor was Username",
        "logid": 1234567
    }
}

Parameters should be title, pageid (only one of those is allowed), lang (could be "default"), reason, tags (change tags for the log entry).

In T74958#2909573, @TTO wrote:
  1. Set the page's language by calling a function on the SpecialPageLanguage class (you will need to refactor the logic there, so that the actual language-change logic is in a common function that can be called by both the special page and the API)

The ideal would be to factor the logic out of SpecialPageLanguage entirely, into some "backend" class that both the special page and the API module use. The tricky part is in properly naming it and deciding exactly what its interface should look like.

Less good, but not too bad, would be to factor the logic to a static method on SpecialPageLanguage (or on ApiSetPageLanguage) that the other would call. It would be mixing UI and backend code in a weird way, but it can work if you do it right and there's plenty of precedent.

Bad would be to have ApiSetPageLanguage actually instantiating a SpecialPageLanguage to do the work, or vice versa. There's plenty of precedent here too, but it's horrible to really work with.

Change 330340 had a related patch set uploaded (by MtDu):
Add api 'setPageLanguage' action for Special:PageLanguage

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

Change 330340 merged by jenkins-bot:
Add API action to set the language of a page

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

TTO assigned this task to MtDu.