Page MenuHomePhabricator

Add the created page id to API action=upload output (instead of just the title)
Open, Needs TriagePublic

Description

I noticed that the MediaWiki's action=upload actually returns lot of interesting things (like my userid, image width/height, ..) but I'm somehow surprised to do not see the pageid. This would be expected during a page creation via an upload.

In theory it should be easy to expand the API response to eventually provide it - if known. Pratically, I think that the pageid is lost during some underlying calls and this may need a refactor.

To give an eye on the current implementation of ApiUpload#performUpload() see here:

https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/api/ApiUpload.php;abdc94a3da1009984cbbd00957f746ffb87b4a2c$804-901

At the time of writing this is what the action=upload returns when creating a page like I have done in https://commons.wikimedia.org/wiki/Special:PermaLink/521509832 with action=upload, comment=.., text=.. and filename=..:

1{
2 "upload": {
3 "result": "Success",
4 "filename": "Berna._Veduta_del_centro_storico_(DOI_21471).jpg",
5 "imageinfo": {
6 "timestamp": "2020-12-27T00:20:38Z",
7 "user": "Valerio Bozzolan bot",
8 "userid": 6711894,
9 "size": 1337746,
10 "width": 3000,
11 "height": 2525,
12 "parsedcomment": "Bot: <a href=\"\\/wiki\\/Commons:Bots\\/Requests\\/Valerio_Bozzolan_bot_(6)\" title=\"Commons:Bots\\/Requests\\/Valerio Bozzolan bot (6)\">authorized import from Academy of architecture Library of Mendrisio<\\/a>",
13 "comment": "Bot: [[Commons:Bots\\/Requests\\/Valerio Bozzolan bot (6)|authorized import from Academy of architecture Library of Mendrisio]]",
14 "html": "<div>\n<div class=\"thumb tright\"><div class=\"thumbinner\" style=\"width:182px;\"><a href=\"\\/w\\/index.php?title=Special:Upload&amp;wpDestFile=Berna._Veduta_del_centro_storico_(DOI_21471).jpg\" class=\"new\" title=\"File:Berna. Veduta del centro storico (DOI 21471).jpg\">File:Berna. Veduta del centro storico (DOI 21471).jpg<\\/a> <div class=\"thumbcaption\">Existing file<\\/div><\\/div><\\/div>\n<p><span id=\"wpUploadWarningFileexists\">A file with this name already exists; please check <b><a class=\"mw-selflink selflink\">the existing file<\\/a><\\/b> if you are not sure whether you want to change it. Please choose another filename, unless you are uploading a technically improved version of the same file. <br \\/>Do not overwrite an image with a different one of the same topic (see <a href=\"\\/wiki\\/Commons:File_naming\" title=\"Commons:File naming\">file naming<\\/a>).<\\/span>\n<\\/p>\n<div style=\"clear:both;\"><\\/div>\n<\\/div>",
15 "canonicaltitle": "File:Berna. Veduta del centro storico (DOI 21471).jpg",
16 "url": "https:\\/\\/upload.wikimedia.org\\/wikipedia\\/commons\\/e\\/ef\\/Berna._Veduta_del_centro_storico_%28DOI_21471%29.jpg",
17 "descriptionurl": "https:\\/\\/commons.wikimedia.org\\/wiki\\/File:Berna._Veduta_del_centro_storico_(DOI_21471).jpg",
18 "sha1": "1d63427f073455b9557c6232bf4e86e87db1650e",
19 "metadata": [
20 {
21 "name": "MEDIAWIKI_EXIF_VERSION",
22 "value": 2
23 }
24 ],
25 "commonmetadata": [],
26 "extmetadata": {
27 "DateTime": {
28 "value": "2020-12-27 00:20:38",
29 "source": "mediawiki-metadata",
30 "hidden": ""
31 },
32 "ObjectName": {
33 "value": "Berna. Veduta del centro storico (DOI 21471)",
34 "source": "mediawiki-metadata",
35 "hidden": ""
36 },
37 "CommonsMetadataExtension": {
38 "value": 1.2,
39 "source": "extension",
40 "hidden": ""
41 },
42 "Categories": {
43 "value": "",
44 "source": "commons-categories",
45 "hidden": ""
46 },
47 "Assessments": {
48 "value": "",
49 "source": "commons-categories",
50 "hidden": ""
51 }
52 },
53 "mime": "image\\/jpeg",
54 "mediatype": "BITMAP",
55 "bitdepth": 8
56 }
57 }
58}

Well, intuitively someone may expect the pageid exposed as upload->pageid as well as we are exposing the filename as upload->filename but it would be nice to request some comments about this.

Event Timeline

Reedy renamed this task from The API action=upload may return the created pageid (instead of just the title) to Add the created page id to API action=upload output (instead of just the title).Dec 27 2020, 1:02 AM