WebStart: Avoid DB or uselang for nonwrite-api-promise-error message
authorTimo Tijhof <krinklemail@gmail.com>
Sun, 25 Aug 2019 18:15:34 +0000 (19:15 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Sun, 25 Aug 2019 18:15:34 +0000 (19:15 +0100)
Make the code easier to reason about by not involving global state from
LBFactory, RequestContext, SessionManager, and User.

Bug: T189966
Change-Id: I88d2bf58ebd481009ce295335d730a34dbb277fb

includes/WebStart.php

index c83fdea..9573091 100644 (file)
@@ -91,17 +91,20 @@ if ( !defined( 'MW_API' ) &&
        header( 'Cache-Control: no-cache' );
        header( 'Content-Type: text/html; charset=utf-8' );
        HttpStatus::header( 400 );
-       $error = wfMessage( 'nonwrite-api-promise-error' )->escaped();
-       $content = <<<EOT
+       $errorHtml = wfMessage( 'nonwrite-api-promise-error' )
+               ->useDatabase( false )
+               ->inContentLanguage()
+               ->escaped();
+       $content = <<<HTML
 <!DOCTYPE html>
 <html>
 <head><meta charset="UTF-8" /></head>
 <body>
-$error
+$errorHtml
 </body>
 </html>
 
-EOT;
+HTML;
        header( 'Content-Length: ' . strlen( $content ) );
        echo $content;
        die();