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

Change subject: Stop suppressing RESTBase redirect handling when requesting HTML
......................................................................

Stop suppressing RESTBase redirect handling when requesting HTML

Wiki pages occasionally move, and there's no reason not to let RESTBase
handle redirects for us when requesting page HTML. This will make the
service more resilient and improve the stability of our tests.

Updates getMetadataActionApi to return whether the page is a redirect,
so that the summary endpoint can continue to return 204s for redirect
pages per the spec. (Previously, we were relying on the redirect response
not having any results when querying for selector 'body > p'.)

Change-Id: Id42b6aa3c9fe751de74e6cafedfd622811b0c232
---
M lib/mobile-util.js
M lib/mwapi.js
M lib/parsoid-access.js
3 files changed, 12 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/93/395893/1

diff --git a/lib/mobile-util.js b/lib/mobile-util.js
index 46a6c66..087c63a 100644
--- a/lib/mobile-util.js
+++ b/lib/mobile-util.js
@@ -202,6 +202,7 @@
     const isContentModelWikitext = meta.contentmodel === 'wikitext';
     const isWhiteListedNamespace = 
mUtil.SUMMARY_NS_WHITELIST.includes(meta.ns);
     const isMainPage = meta.mainpage;
+    const isRedirect = meta.redirect;
 
     if (!isContentModelWikitext) {
         return { code: 204 };
@@ -215,6 +216,10 @@
         return { code: 204 };
     }
 
+    if (isRedirect) {
+        return { code: 204 };
+    }
+
     const leadText = domino.createDocument(page.sections[0].text);
     const intro = transforms.extractLeadIntroduction(leadText);
 
diff --git a/lib/mwapi.js b/lib/mwapi.js
index 80f7bcb..103cc01 100644
--- a/lib/mwapi.js
+++ b/lib/mwapi.js
@@ -168,7 +168,7 @@
         piprop: 'thumbnail|original|name',
         pithumbsize: mwapi.LEAD_IMAGE_XL,
         wbptterms: 'description',
-        inprop: ['protection'].join('|'),
+        inprop: 'protection',
         rvprop: ['ids', 'timestamp', 'user', 'contentmodel'].join('|'),
         titles: req.params.title,
         prop: props.join('|')
@@ -207,12 +207,8 @@
         const displayTitle = pageprops && pageprops.displaytitle;
         const title = page.title;
         const thumbUrl = page.thumbnail && page.thumbnail.source;
-        const thumb = thumbUrl ? {
-            url: thumbUrl.replace('https:', '')
-        } : undefined;
-        const image = page.pageimage ? {
-            file: page.pageimage
-        } : undefined;
+        const thumb = thumbUrl ? { url: thumbUrl.replace('https:', '') } : 
undefined;
+        const image = page.pageimage ? { file: page.pageimage } : undefined;
         const protection = page.protection && 
mwapi.simplifyProtectionObject(page.protection);
         const modifier = revision && revision.anon !== undefined ? { anon: 
true } : {};
         modifier.user = revision && revision.user;
@@ -222,6 +218,7 @@
         const talkNsText = page.ns % 2 === 0 ? res.siteinfo.namespaces[page.ns 
+ 1]
             && new Namespace(page.ns + 1, res.siteinfo).getNormalizedText() : 
undefined;
         const mobileHost = res.siteinfo.general.mobileserver;
+        const redirect = page.redirect;
 
         return {
             geo,
@@ -249,7 +246,8 @@
             mainpage,
             revision: revision && revision.revid,
             description: page.terms && page.terms.description[0],
-            mobileHost
+            mobileHost,
+            redirect
         };
     });
 }
diff --git a/lib/parsoid-access.js b/lib/parsoid-access.js
index 027a156..8f7aeaf 100644
--- a/lib/parsoid-access.js
+++ b/lib/parsoid-access.js
@@ -38,10 +38,7 @@
     return mwapi.getDbTitle(app, req, req.params.title)
     .then((title) => {
         const path = `page/html/${encodeURIComponent(title)}${suffix}`;
-        const restReq = {
-            query: { redirect: 'false' },
-            headers: { accept: PARSOID_ACCEPT_HEADER }
-        };
+        const restReq = { headers: { accept: PARSOID_ACCEPT_HEADER } };
 
         return api.restApiGet(app, domain, path, restReq);
     });

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id42b6aa3c9fe751de74e6cafedfd622811b0c232
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: Mholloway <mhollo...@wikimedia.org>

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

Reply via email to