jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/370233 )

Change subject: Remove redirect handling
......................................................................


Remove redirect handling

RESTBase handles redirects for us. So, there is no point in MCS having
its own redirect handling or testing it.

Bug: T172548
Change-Id: Icf8eca957e7bd320dedc98032332b7d0b8b24bd4
---
M lib/mwapi.js
M routes/mobile-sections.js
M test/features/mobile-sections/pagecontent.js
M test/features/mobile-sections/shared.js
4 files changed, 16 insertions(+), 65 deletions(-)

Approvals:
  Ppchelko: Looks good to me, but someone else must approve
  jenkins-bot: Verified
  Jdlrobson: Looks good to me, approved



diff --git a/lib/mwapi.js b/lib/mwapi.js
index ce3c6fc..796adeb 100644
--- a/lib/mwapi.js
+++ b/lib/mwapi.js
@@ -8,7 +8,6 @@
 const api = require('./api-util');
 const HTTPError = sUtil.HTTPError;
 const Title = require('mediawiki-title').Title;
-const anchorencode = require('./anchorencode');
 
 const mwapi = {};
 
@@ -171,7 +170,6 @@
         inprop: ['protection'].join('|'),
         rvprop: ['ids', 'timestamp', 'user', 'contentmodel'].join('|'),
         titles: req.params.title,
-        redirects: 1,
         prop: props.join('|')
     });
 
@@ -208,12 +206,7 @@
               && body.query.normalized && body.query.normalized[0]
               && body.query.normalized[0].to;
           const displayTitle = pageprops && pageprops.displaytitle;
-          const redirectInfo = body.query.redirects && body.query.redirects[0];
-          let redirected = redirectInfo && redirectInfo.to;
-          const title = redirected || page.title;
-          if (redirectInfo && redirectInfo.tofragment) {
-              redirected += `#${anchorencode(redirectInfo.tofragment)}`;
-          }
+          const title = page.title;
           const thumbUrl = page.thumbnail && page.thumbnail.source;
           const thumb = thumbUrl ? {
               url: thumbUrl.replace('https:', '')
@@ -234,7 +227,6 @@
               title: page.title,
               displaytitle: displayTitle || title,
               normalizedtitle: normalized || title,
-              redirected,
               pageprops,
               image,
               id: page.pageid,
diff --git a/routes/mobile-sections.js b/routes/mobile-sections.js
index 6110b35..645e927 100644
--- a/routes/mobile-sections.js
+++ b/routes/mobile-sections.js
@@ -124,7 +124,6 @@
         lastmodifier: input.meta.lastmodifier,
         displaytitle: input.meta.displaytitle,
         normalizedtitle: input.meta.normalizedtitle,
-        redirected: input.meta.redirected,
         wikibase_item: input.meta.pageprops && 
input.meta.pageprops.wikibase_item,
         disambiguation,
         description: input.meta.description,
diff --git a/test/features/mobile-sections/pagecontent.js 
b/test/features/mobile-sections/pagecontent.js
index 35d5ec0..01f9c07 100644
--- a/test/features/mobile-sections/pagecontent.js
+++ b/test/features/mobile-sections/pagecontent.js
@@ -129,61 +129,6 @@
             });
     });
 
-    it('Page with HTML entity in redirected page title should load', () => {
-        const title = `User:BSitzmann_%28WMF%29%2FMCS%2FTest%2FA%26B_redirect`;
-        const uri = localUri(title, 'test.wikipedia.org');
-        return preq.get({ uri })
-            .then((res) => {
-                const lead = res.body.lead;
-                const redirectTitle = 'User:BSitzmann (WMF)/MCS/Test/A&B 
redirect';
-                assert.equal(res.status, 200);
-                assert.equal(lead.normalizedtitle, redirectTitle);
-                assert.equal(lead.displaytitle, 'User:BSitzmann 
(WMF)/MCS/Test/A&B');
-                assert.equal(lead.redirected, 'User:BSitzmann 
(WMF)/MCS/Test/A&B');
-            });
-    });
-
-    it('Page with % in redirected page title should load [beta cluster]', () 
=> {
-        const title = `User:Pchelolo%2fRedirect_Test`;
-        const uri = localUri(title, 'en.wikipedia.beta.wmflabs.org');
-        return preq.get({ uri })
-            .then((res) => {
-                assert.equal(res.status, 200);
-                assert.equal(res.body.lead.normalizedtitle, 
'User:Pchelolo/Redirect Test');
-                assert.equal(res.body.lead.displaytitle, 
'User:Pchelolo/Redirect Target %');
-                assert.equal(res.body.lead.redirected, 'User:Pchelolo/Redirect 
Target %');
-            });
-    });
-
-    it('Page with % in redirected page title should load 2', () => {
-        const title = `User:BSitzmann_%28WMF%29%2FMCS%2FTest%2Fredirect_test2`;
-        const normalizedTitle = 'User:BSitzmann (WMF)/MCS/Test/redirect test2';
-        const displayTitle = 'User:BSitzmann (WMF)/MCS/Test/redirect test2 
target %';
-        const uri = localUri(title, 'test.wikipedia.org');
-        return preq.get({ uri })
-            .then((res) => {
-                assert.equal(res.status, 200);
-                assert.equal(res.body.lead.normalizedtitle, normalizedTitle);
-                assert.equal(res.body.lead.displaytitle, displayTitle);
-                assert.equal(res.body.lead.redirected, displayTitle);
-            });
-    });
-
-    it('Page with % in section header of redirected page title should load', 
() => {
-        const title = `User:BSitzmann_%28WMF%29%2FMCS%2FTest%2Fredirect_test3`;
-        const normalizedTitle = 'User:BSitzmann (WMF)/MCS/Test/redirect test3';
-        const displayTitle = 'User:BSitzmann (WMF)/MCS/Test/redirect test3 
target';
-        const titleWithFragment = 'User:BSitzmann (WMF)/MCS/Test/redirect 
test3 target#Section_.25';
-        const uri = localUri(title, 'test.wikipedia.org');
-        return preq.get({ uri })
-            .then((res) => {
-                assert.equal(res.status, 200);
-                assert.equal(res.body.lead.normalizedtitle, normalizedTitle);
-                assert.equal(res.body.lead.displaytitle, displayTitle);
-                assert.equal(res.body.lead.redirected, titleWithFragment);
-            });
-    });
-
     it('Internal links should have title attribute', () => {
         const title = 
`User:BSitzmann_%28WMF%29%2FMCS%2FTest%2FTitleLinkEncoding`;
         const uri = localUri(title);
diff --git a/test/features/mobile-sections/shared.js 
b/test/features/mobile-sections/shared.js
index b50737b..68e7ce9 100644
--- a/test/features/mobile-sections/shared.js
+++ b/test/features/mobile-sections/shared.js
@@ -93,4 +93,19 @@
             assert.equal(res.status, 404);
         });
     });
+
+    it('Redirects should not be followed in MCS', () => {
+         // The following page has a redirect but we don't want MCS to follow 
it
+         // since RESTBase already takes care of redirects.
+        const title = `User:BSitzmann_%28WMF%29%2FMCS%2FTest%2Fredirect_test2`;
+        const normalizedTitle = 'User:BSitzmann (WMF)/MCS/Test/redirect test2';
+        const uri = localUri(title, 'test.wikipedia.org');
+        return preq.get({ uri })
+        .then((res) => {
+            assert.equal(res.status, 200);
+            assert.equal(res.body.lead.normalizedtitle, normalizedTitle);
+            assert.equal(res.body.lead.displaytitle, normalizedTitle);
+            assert.ok(res.body.lead.redirected === undefined);
+        });
+    });
 };

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Icf8eca957e7bd320dedc98032332b7d0b8b24bd4
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND <bsitzm...@wikimedia.org>
Gerrit-Reviewer: BearND <bsitzm...@wikimedia.org>
Gerrit-Reviewer: Dbrant <dbr...@wikimedia.org>
Gerrit-Reviewer: Fjalapeno <cfl...@wikimedia.org>
Gerrit-Reviewer: GWicke <gwi...@wikimedia.org>
Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Jhernandez <jhernan...@wikimedia.org>
Gerrit-Reviewer: Mholloway <mhollo...@wikimedia.org>
Gerrit-Reviewer: Mhurd <mh...@wikimedia.org>
Gerrit-Reviewer: Mobrovac <mobro...@wikimedia.org>
Gerrit-Reviewer: Niedzielski <sniedziel...@wikimedia.org>
Gerrit-Reviewer: Ppchelko <ppche...@wikimedia.org>
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