Brion VIBBER has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/214124

Change subject: Workaround for crash caused by bad 'on this day' feed on enwiki
......................................................................

Workaround for crash caused by bad 'on this day' feed on enwiki

Change-Id: Id509b668f264b8157369f19f17eff23221e7b1a8
---
M WikipediaMetro/WikipediaMetroTest/js/default.js
1 file changed, 19 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/apps/win8/wikipedia 
refs/changes/24/214124/1

diff --git a/WikipediaMetro/WikipediaMetroTest/js/default.js 
b/WikipediaMetro/WikipediaMetroTest/js/default.js
index c746d83..d6d53f7 100644
--- a/WikipediaMetro/WikipediaMetroTest/js/default.js
+++ b/WikipediaMetro/WikipediaMetroTest/js/default.js
@@ -1181,27 +1181,31 @@
                 // Filter for safety
                 var html = toStaticHTML(htmlList[0]),
                     $html = $('<div>').html(html),
-                    $lis = $html.find('li');
+                    $lis = $($html.find('ul').get(0)).find('li');
                 $lis.each(function () {
                     var $li = $(this),
                         txt = stripHtmlTags($li.html()),
                         $link = $li.find('b a');
                     if ($link.size()) {
                         // enwiki-style
-                        var title = extractWikiTitle($link.attr('href') + '');
-                        var bits = txt.split(' – '),
-                            year = bits[0],
-                            detail = bits[1];
-                        nItems++;
-                        list.push({
-                            title: title,
-                            heading: year,
-                            snippet: detail,
-                            image: '',
-                            group: 'On this day',
-                            groupText: 
mediaWiki.message('section-onthisday').plain(),
-                            style: 'onthisday-item'
-                        });
+                        try {
+                            var title = extractWikiTitle($link.attr('href') + 
'');
+                            var bits = txt.split(' – '),
+                                year = bits[0],
+                                detail = bits[1];
+                            nItems++;
+                            list.push({
+                                title: title,
+                                heading: year,
+                                snippet: detail,
+                                image: '',
+                                group: 'On this day',
+                                groupText: 
mediaWiki.message('section-onthisday').plain(),
+                                style: 'onthisday-item'
+                            });
+                        } catch (e) {
+                            console.log("Unexpected on-this-day link format: " 
+ $li.attr('href'));
+                        }
                     } else {
                         console.log("Unexpected on-this-day format: " + 
$li.html());
                     }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id509b668f264b8157369f19f17eff23221e7b1a8
Gerrit-PatchSet: 1
Gerrit-Project: apps/win8/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Brion VIBBER <br...@wikimedia.org>

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

Reply via email to