private static function msg( $key, $fallback /*[, params...] */ ) {
global $wgSitename;
$args = array_slice( func_get_args(), 2 );
+
+ // FIXME: Keep logic in sync with MWException::msg.
try {
$res = wfMessage( $key, $args )->text();
} catch ( Exception $e ) {
$res = wfMsgReplaceArgs( $fallback, $args );
// If an exception happens inside message rendering,
// {{SITENAME}} sometimes won't be replaced.
- $res = preg_replace( '/\{\{SITENAME\}\}/', $wgSitename, $res );
+ $res = strtr( $res, [
+ '{{SITENAME}}' => $wgSitename,
+ ] );
}
return $res;
}
*/
private static function printError( $message ) {
// NOTE: STDERR may not be available, especially if php-cgi is used from the
- // command line (bug #15602). Try to produce meaningful output anyway. Using
+ // command line (T17602). Try to produce meaningful output anyway. Using
// echo may corrupt output to STDOUT though.
if ( defined( 'STDERR' ) ) {
fwrite( STDERR, $message );
htmlspecialchars( $e->getTraceAsString() ) . '</pre>';
}
- $html .= '<hr />';
- $html .= self::googleSearchForm();
$html .= '</body></html>';
echo $html;
}
-
- /**
- * @return string
- */
- private static function googleSearchForm() {
- global $wgSitename, $wgCanonicalServer, $wgRequest;
-
- $usegoogle = htmlspecialchars( self::msg(
- 'dberr-usegoogle',
- 'You can try searching via Google in the meantime.'
- ) );
- $outofdate = htmlspecialchars( self::msg(
- 'dberr-outofdate',
- 'Note that their indexes of our content may be out of date.'
- ) );
- $googlesearch = htmlspecialchars( self::msg( 'searchbutton', 'Search' ) );
- $search = htmlspecialchars( $wgRequest->getVal( 'search' ) );
- $server = htmlspecialchars( $wgCanonicalServer );
- $sitename = htmlspecialchars( $wgSitename );
- $trygoogle = <<<EOT
-<div style="margin: 1.5em">$usegoogle<br />
-<small>$outofdate</small>
-</div>
-<form method="get" action="//www.google.com/search" id="googlesearch">
- <input type="hidden" name="domains" value="$server" />
- <input type="hidden" name="num" value="50" />
- <input type="hidden" name="ie" value="UTF-8" />
- <input type="hidden" name="oe" value="UTF-8" />
- <input type="text" name="q" size="31" maxlength="255" value="$search" />
- <input type="submit" name="btnG" value="$googlesearch" />
- <p>
- <label><input type="radio" name="sitesearch" value="$server" checked="checked" />$sitename</label>
- <label><input type="radio" name="sitesearch" value="" />WWW</label>
- </p>
-</form>
-EOT;
- return $trygoogle;
- }
}