Show HTTP error (if any) when scary transclusion fails
authorAlex Monk <krenair@gmail.com>
Thu, 16 Aug 2012 21:48:46 +0000 (22:48 +0100)
committerSiebrand Mazeland <s.mazeland@xs4all.nl>
Mon, 27 Aug 2012 16:45:24 +0000 (18:45 +0200)
Also document all the scary transclusion messages.

Change-Id: I5ff473ed4bfccedbb5feb3f2ef469eec6eb2e57c

includes/parser/Parser.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc

index 5f211b1..ce4454a 100644 (file)
@@ -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();
                }
 
index 0828bbe..2f823a4 100644 (file)
@@ -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!",
index d89b36a..28d65db 100644 (file)
@@ -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
index 33c104b..5acad0c 100644 (file)
@@ -3342,6 +3342,7 @@ $wgMessageStructure = array(
        'scarytransclusion' => array(
                'scarytranscludedisabled',
                'scarytranscludefailed',
+               'scarytranscludefailed-httpstatus',
                'scarytranscludetoolong',
        ),
        'deleteconflict' => array(