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.

Details

Reference
bz72958

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 3:45 AM
bzimport added a project: MediaWiki-API.
bzimport set Reference to bz72958.
bzimport added a subscriber: Unknown Object (MLST).
Anomie moved this task from Unsorted to Needs Code on the MediaWiki-API board.Feb 19 2015, 6:21 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 12 2015, 12:22 PM
Catrope removed a subscriber: Catrope.Jan 14 2016, 8:14 PM
TTO updated the task description. (Show Details)Jan 1 2017, 6:14 AM
TTO edited subscribers, added: TTO; removed: wikibugs-l-list.
TTO added a comment.Jan 1 2017, 6:50 AM

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).

Anomie added a comment.Jan 3 2017, 7:13 PM
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

MtDu added a subscriber: MtDu.Jan 4 2017, 3:29 AM

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

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

TTO closed this task as Resolved.Jan 5 2017, 3:29 AM
TTO assigned this task to MtDu.