Bmansurov has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/350489 )

Change subject: Use modified action=templatedata response format
......................................................................

Use modified action=templatedata response format

The updated action=templatedata in formatversion=2 returns an array
rather than an object of pages. This patch treats the response format
as such.

Change-Id: Ifac45165cdf02e9071e00b08f28cef9fe53762bc
Depends-On: I004ca66aa5ee36f78af118967efd0f0a05054990
---
M lib/ve
M modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js
M modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js
3 files changed, 13 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/89/350489/1

diff --git a/lib/ve b/lib/ve
index 15d5124..6eba2e2 160000
--- a/lib/ve
+++ b/lib/ve
@@ -1 +1 @@
-Subproject commit 15d5124ee50a2010c2fa38ce99892bc5a89df570
+Subproject commit 6eba2e2f4c1eb3470ceea44e7313d37a84687acd
diff --git a/modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js 
b/modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js
index 13bdf9d..9484f2e 100644
--- a/modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js
+++ b/modules/ve-mw/dm/models/ve.dm.MWTransclusionModel.js
@@ -325,22 +325,20 @@
 
                if ( data && data.pages ) {
                        // Keep spec data on hand for future use
-                       for ( id in data.pages ) {
-                               title = data.pages[ id ].title;
-
-                               if ( data.pages[ id ].missing ) {
+                       data.pages.forEach( function ( page ) {
+                               if ( page.missing ) {
                                        // Remmeber templates that don't exist 
in the link cache
                                        // { title: { missing: true|false }
                                        missingTitle = {};
-                                       missingTitle[ title ] = { missing: true 
};
+                                       missingTitle[ page.title ] = { missing: 
true };
                                        ve.init.platform.linkCache.setMissing( 
missingTitle );
-                               } else if ( data.pages[ id ].notemplatedata ) {
+                               } else if ( page.notemplatedata ) {
                                        // Prevent asking again for templates 
that have no specs
-                                       specs[ title ] = null;
+                                       specs[ page.title ] = null;
                                } else {
-                                       specs[ title ] = data.pages[ id ];
+                                       specs[ page.title ] = page;
                                }
-                       }
+                       } );
                        // Follow redirects
                        if ( data.redirects ) {
                                aliasMap = data.redirects;
diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js 
b/modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js
index 2195eae..9c829ce 100644
--- a/modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js
+++ b/modules/ve-mw/ui/widgets/ve.ui.MWTemplateTitleInputWidget.js
@@ -101,10 +101,10 @@
                        } )
                        .then( function ( templateDataResponse ) {
                                var index, page, missingTitle,
-                                       pages = ( templateDataResponse && 
templateDataResponse.pages ) || {};
+                                       pages = ( templateDataResponse && 
templateDataResponse.pages ) || [];
+
                                // Look for descriptions and cache them
-                               for ( index in pages ) {
-                                       page = pages[ index ];
+                               pages.forEach( function ( page ) {
                                        if ( page.missing ) {
                                                // Remmeber templates that 
don't exist in the link cache
                                                // { title: { missing: 
true|false }
@@ -115,7 +115,8 @@
                                                // Cache descriptions
                                                widget.descriptions[ page.title 
] = page.description;
                                        }
-                               }
+                               } );
+
                                // Return the original response
                                return originalResponse;
                        } )

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifac45165cdf02e9071e00b08f28cef9fe53762bc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to