From 780a9ee2db3cd19026bebcad22ca6e0362a9f89c Mon Sep 17 00:00:00 2001 From: Alex Monk Date: Thu, 16 Aug 2012 22:48:46 +0100 Subject: [PATCH] Show HTTP error (if any) when scary transclusion fails Also document all the scary transclusion messages. Change-Id: I5ff473ed4bfccedbb5feb3f2ef469eec6eb2e57c --- includes/parser/Parser.php | 9 +++++++-- languages/messages/MessagesEn.php | 7 ++++--- languages/messages/MessagesQqq.php | 12 +++++++++--- maintenance/language/messages.inc | 1 + 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 5f211b183b..ce4454ae04 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3692,8 +3692,13 @@ class Parser { return $obj->tc_contents; } - $text = Http::get( $url ); - if ( !$text ) { + $req = MWHttpRequest::factory( $url ); + $status = $req->execute(); // Status object + if ( $status->isOK() ) { + $text = $req->getContent(); + } elseif ( $req->getStatus() != 200 ) { // Though we failed to fetch the content, this status is useless. + return wfMessage( 'scarytranscludefailed-httpstatus', $url, $req->getStatus() /* HTTP status */ )->inContentLanguage()->text(); + } else { return wfMessage( 'scarytranscludefailed', $url )->inContentLanguage()->text(); } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 0828bbec0d..2f823a45eb 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -4458,9 +4458,10 @@ This confirmation code will expire at $4.', 'invalidateemail' => 'Cancel e-mail confirmation', # Scary transclusion -'scarytranscludedisabled' => '[Interwiki transcluding is disabled]', -'scarytranscludefailed' => '[Template fetch failed for $1]', -'scarytranscludetoolong' => '[URL is too long]', +'scarytranscludedisabled' => '[Interwiki transcluding is disabled]', +'scarytranscludefailed' => '[Template fetch failed for $1]', +'scarytranscludefailed-httpstatus' => '[Template fetch failed for $1: HTTP $2]', +'scarytranscludetoolong' => '[URL is too long]', # Delete conflict 'deletedwhileediting' => "'''Warning''': This page was deleted after you started editing!", diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index d89b36a9dd..28d65dbf4c 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -551,9 +551,9 @@ The format is: "{{int:youhavenewmessages| [[MediaWiki:Newmessageslink/{{SUBPAGEN {{Identical|New messages}}', 'newmessagesdifflink' => 'This is the second link displayed in an orange rectangle when a user gets a message on his talk page. Used in message {{msg-mw|youhavenewmessages}} (as parameter $2).', 'youhavenewmessagesfromusers' => 'New talk indicator message: the message appearing when someone edited your user talk page. -The message takes three parameters; -*$1 {{msg-mw|newmessageslinkplural}}, -*$2 {{msg-mw|newmessagesdifflinkplural}}, and +The message takes three parameters; +*$1 {{msg-mw|newmessageslinkplural}}, +*$2 {{msg-mw|newmessagesdifflinkplural}}, and *$3 the number of authors who have edited the talk page since the owning user last viewed it.', 'youhavenewmessagesmanyusers' => 'New talk indicator message: the message appearing when someone edited your user talk page. Used when more than 10 users edited the user talk page since the owning user last viewed it, similar to{{msg-mw|youhavenewmessages}}. Parameters: * $1 is {{msg-mw|newmessageslinkplural}}, @@ -4333,6 +4333,12 @@ See also [[MediaWiki:Confirmemail_body_changed]]. 'confirmemail_invalidated' => 'This is the text of the special page [[Special:InvalidateEmail|InvalidateEmail]] (with the title in {{msg-mw|Invalidateemail}}) where user goes if he chooses the cancel e-mail confirmation link from the confirmation e-mail.', 'invalidateemail' => "This is the '''name of the special page''' where user goes if he chooses the cancel e-mail confirmation link from the confirmation e-mail.", +# Scary transclusion +'scarytranscludedisabled' => 'Shown when scary transclusion is disabled.', +'scarytranscludefailed' => 'Shown when the HTTP request for the template failed.', +'scarytranscludefailed-httpstatus' => 'Identical to scarytranscludefailed, but shows the HTTP error which was received.', +'scarytranscludetoolong' => 'The URL was too long.', + 'unit-pixel' => '{{optional}}', # action=purge diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 33c104b1fb..5acad0c081 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -3342,6 +3342,7 @@ $wgMessageStructure = array( 'scarytransclusion' => array( 'scarytranscludedisabled', 'scarytranscludefailed', + 'scarytranscludefailed-httpstatus', 'scarytranscludetoolong', ), 'deleteconflict' => array( -- 2.20.1