jenkins-bot has submitted this change and it was merged.

Change subject: Use formatversion=2 for all API calls
......................................................................


Use formatversion=2 for all API calls

Bug: T145454
Change-Id: I45d0e54ad27273adad7abf6fb8a8cbb73d6997ad
---
M ApiFileAnnotations.php
M resources/src/fileannotations.js
2 files changed, 15 insertions(+), 13 deletions(-)

Approvals:
  Bartosz Dziewoński: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/ApiFileAnnotations.php b/ApiFileAnnotations.php
index c21f397..ad4b379 100644
--- a/ApiFileAnnotations.php
+++ b/ApiFileAnnotations.php
@@ -109,6 +109,7 @@
                                                'iiprop' => 'url',
                                                'iiurlwidth' => 100,
                                                'iiurlheight' => 100,
+                                               'formatversion' => 2,
                                                'format' => 'json',
                                        ],
                                ] );
@@ -125,7 +126,7 @@
                                $imagesHtml = '<div class="category-members">';
 
                                $href = null;
-                               foreach ( $pages as $id => $page ) {
+                               foreach ( $pages as $page ) {
                                        $info = $page['imageinfo'][0];
                                        $href = $info['descriptionurl'];
                                        $src = $info['thumburl'];
@@ -186,6 +187,7 @@
                                                'piprop' => 'thumbnail|name',
                                                'pithumbsize' => 250,
                                                'exsentences' => 4,
+                                               'formatversion' => 2,
                                                'format' => 'json',
                                        ],
                                ] );
@@ -199,8 +201,7 @@
                                        $ttl = $cache::TTL_UNCACHEABLE;
                                }
 
-                               $page = reset( $pages );
-                               // There's only one page, so just do it here
+                               $page = $pages[0];
                                $html =
                                        '<div 
class="wikipedia-article-annotation">' .
                                                $page['extract'] .
@@ -251,6 +252,7 @@
                                                'ids' => $entityId,
                                                'languages' => 'en|' . 
$currentLang,
                                                'props' => 
'labels|descriptions|claims',
+                                               'formatversion' => 2,
                                                'format' => 'json',
                                        ],
                                ] );
@@ -353,6 +355,7 @@
                                'iiprop' => 'url',
                                'iiurlwidth' => 200,
                                'iiurlheight' => 200,
+                               'formatversion' => 2,
                                'format' => 'json',
                        ]
                ] );
@@ -362,7 +365,7 @@
                $pages = $imageApiData['query']['pages'];
                $imageLink = null;
 
-               $page = reset( $pages );
+               $page = $pages[0];
                // There's only one page. Add HTML here.
                $info = $page['imageinfo'][0];
                return
diff --git a/resources/src/fileannotations.js b/resources/src/fileannotations.js
index 1fb0ec4..3897989 100644
--- a/resources/src/fileannotations.js
+++ b/resources/src/fileannotations.js
@@ -60,8 +60,7 @@
 
                if ( this.editing ) {
                        this.getAnnotationsHTML().then( function ( data ) {
-                               var pageId = data.query.pageids[ 0 ],
-                                       page = data.query.pages[ pageId ],
+                               var page = data.query.pages[ 0 ],
                                        imageInfo = page.imageinfo[ 0 ],
                                        fullw = imageInfo.width,
                                        fullh = imageInfo.height,
@@ -146,18 +145,18 @@
                        action: 'query',
                        prop: 'revisions',
                        rvprop: 'content',
-                       indexpageids: true,
+                       formatversion: 2,
+                       format: 'json',
                        titles: this.annotationsTitle.getPrefixedDb()
                } ).then( function ( data ) {
                        var rv, text, annotations,
                                pages = data.query.pages,
-                               pageid = data.query.pageids[ 0 ],
-                               page = pages[ pageid ],
+                               page = pages[ 0 ],
                                revisions = page.revisions;
 
                        if ( revisions ) {
                                rv = revisions[ 0 ];
-                               text = rv[ '*' ];
+                               text = rv.content;
                                annotations = JSON.parse( text );
                        } else {
                                // Fake it, give the rest of the code an empty 
list
@@ -196,7 +195,8 @@
                if ( this.annotationsCache === undefined ) {
                        this.annotationsCache = this.api.get( {
                                action: 'query',
-                               indexpageids: true,
+                               formatversion: 2,
+                               format: 'json',
                                prop: [ 'fileannotations', 'imageinfo' ],
                                titles: this.fileTitle.getPrefixedDb(),
                                faparse: true,
@@ -482,8 +482,7 @@
                return this.getAnnotationsHTML( this.fileTitle )
                        .then( function ( data ) {
                                var i,
-                                       pageId = data.query.pageids[ 0 ],
-                                       page = data.query.pages[ pageId ],
+                                       page = data.query.pages[ 0 ],
                                        imageInfo = page.imageinfo[ 0 ],
                                        annotations = page.fileannotations[ 0 ],
                                        fullw = imageInfo.width,

-- 
To view, visit https://gerrit.wikimedia.org/r/310355
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I45d0e54ad27273adad7abf6fb8a8cbb73d6997ad
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/FileAnnotations
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <mholmqu...@wikimedia.org>
Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to