jenkins-bot has submitted this change and it was merged. Change subject: Fix loading for irregular Spoken Wikipedia sections ......................................................................
Fix loading for irregular Spoken Wikipedia sections This removes an assumption about the number of audio files present in a Spoken Wikipedia-([2-5]) section that occasionally led to a page load failure. Change-Id: I9df1f8efb6b8f43bee3ff8504b12a21a572e3694 --- M lib/parseProperty.js M test/features/mobile-sections/pagecontent.js 2 files changed, 10 insertions(+), 3 deletions(-) Approvals: BearND: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/parseProperty.js b/lib/parseProperty.js index e35f85b..171745d 100644 --- a/lib/parseProperty.js +++ b/lib/parseProperty.js @@ -86,7 +86,7 @@ * https://en.wikipedia.org/wiki/Wikipedia:WikiProject_Spoken_Wikipedia/Template_guidelines */ function parseSpokenWikipedia(doc, page) { - var dataMW, parsedData, firstPart, template, target, match, maxKey, key, fileName, + var dataMW, parsedData, firstPart, template, target, match, key, fileName, keyLength, spokenSectionDiv = doc.querySelector('div#section_SpokenWikipedia'); if (spokenSectionDiv) { @@ -104,11 +104,11 @@ } else { match = /Spoken Wikipedia-([2-5])/.exec(target.wt); if (match) { - maxKey = 2 + parseInt(match[1]); // multiple audio files: skip first param (recording date) page.spoken = {}; page.spoken.files = []; - for (key = 2; key < maxKey; key++) { + keyLength = Object.keys(template.params).length; + for (key = 2; key <= keyLength; key++) { fileName = 'File:' + template.params[key].wt; page.spoken.files.push(fileName); } diff --git a/test/features/mobile-sections/pagecontent.js b/test/features/mobile-sections/pagecontent.js index d881bed..f16084d 100644 --- a/test/features/mobile-sections/pagecontent.js +++ b/test/features/mobile-sections/pagecontent.js @@ -119,4 +119,11 @@ assert.deepEqual(res.status, 200); }); }); + it('Page with irregular Spoken Wikipedia template usage should load correctly', function() { + return preq.get({ uri: server.config.uri + 'en.wikipedia.org/v1/page/mobile-sections/Alliterative_verse' }) + .then(function(res) { + assert.deepEqual(res.status, 200); + assert.deepEqual(res.body.lead.spoken.files[0], 'File:En-Alliterative_verse-article.ogg'); + }); + }); }); -- To view, visit https://gerrit.wikimedia.org/r/279612 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9df1f8efb6b8f43bee3ff8504b12a21a572e3694 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/services/mobileapps Gerrit-Branch: master Gerrit-Owner: Mholloway <[email protected]> Gerrit-Reviewer: BearND <[email protected]> Gerrit-Reviewer: Dbrant <[email protected]> Gerrit-Reviewer: Fjalapeno <[email protected]> Gerrit-Reviewer: GWicke <[email protected]> Gerrit-Reviewer: Mhurd <[email protected]> Gerrit-Reviewer: Mobrovac <[email protected]> Gerrit-Reviewer: Niedzielski <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
