Merge "Show HTTP error (if any) when scary transclusion fails"
[lhc/web/wiklou.git] / includes / parser / Parser.php
index e778ca8..9a094c8 100644 (file)
@@ -3699,8 +3699,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();
                }