r86722 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86721‎ | r86722 | r86723 >
Date:18:57, 22 April 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
Added DBError::getContentMessage() to factorise common code; DBUnexpectedError now displays shows like a DB error for consistency with CLI mode
Modified paths:
  • /trunk/phase3/includes/db/Database.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/Database.php
@@ -2874,10 +2874,18 @@
28752875 parent::__construct( $error );
28762876 }
28772877
 2878+ protected function getContentMessage( $html ) {
 2879+ if ( $html ) {
 2880+ return nl2br( htmlspecialchars( $this->getMessage() ) );
 2881+ } else {
 2882+ return $this->getMessage();
 2883+ }
 2884+ }
 2885+
28782886 function getText() {
28792887 global $wgShowDBErrorBacktrace;
28802888
2881 - $s = $this->getMessage() . "\n";
 2889+ $s = $this->getContentMessage( false ) . "\n";
28822890
28832891 if ( $wgShowDBErrorBacktrace ) {
28842892 $s .= "Backtrace:\n" . $this->getTraceAsString() . "\n";
@@ -2885,6 +2893,18 @@
28862894
28872895 return $s;
28882896 }
 2897+
 2898+ function getHTML() {
 2899+ global $wgShowDBErrorBacktrace;
 2900+
 2901+ $s = $this->getContentMessage( true );
 2902+
 2903+ if ( $wgShowDBErrorBacktrace ) {
 2904+ $s .= '<p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) );
 2905+ }
 2906+
 2907+ return $s;
 2908+ }
28892909 }
28902910
28912911 /**
@@ -3084,20 +3104,17 @@
30853105 $this->fname = $fname;
30863106 }
30873107
3088 - function getText() {
3089 - global $wgShowDBErrorBacktrace;
3090 -
 3108+ function getContentMessage( $html ) {
30913109 if ( $this->useMessageCache() ) {
3092 - $s = wfMsg( 'dberrortextcl', htmlspecialchars( $this->getSQL() ),
3093 - htmlspecialchars( $this->fname ), $this->errno, htmlspecialchars( $this->error ) ) . "\n";
3094 -
3095 - if ( $wgShowDBErrorBacktrace ) {
3096 - $s .= "Backtrace:\n" . $this->getTraceAsString() . "\n";
 3110+ $msg = $html ? 'dberrortext' : 'dberrortextcl';
 3111+ $ret = wfMsg( $msg, $this->getSQL(),
 3112+ $this->fname, $this->errno, $this->error );
 3113+ if ( $html ) {
 3114+ $ret = htmlspecialchars( $ret );
30973115 }
3098 -
3099 - return $s;
 3116+ return $ret;
31003117 } else {
3101 - return parent::getText();
 3118+ return parent::getContentMessage( $html );
31023119 }
31033120 }
31043121
@@ -3119,23 +3136,6 @@
31203137 function getPageTitle() {
31213138 return $this->msg( 'databaseerror', 'Database error' );
31223139 }
3123 -
3124 - function getHTML() {
3125 - global $wgShowDBErrorBacktrace;
3126 -
3127 - if ( $this->useMessageCache() ) {
3128 - $s = wfMsgNoDB( 'dberrortext', htmlspecialchars( $this->getSQL() ),
3129 - htmlspecialchars( $this->fname ), $this->errno, htmlspecialchars( $this->error ) );
3130 - } else {
3131 - $s = nl2br( htmlspecialchars( $this->getMessage() ) );
3132 - }
3133 -
3134 - if ( $wgShowDBErrorBacktrace ) {
3135 - $s .= '<p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) );
3136 - }
3137 -
3138 - return $s;
3139 - }
31403140 }
31413141
31423142 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r90668Fix for r86722: pass the message 'dberrortext' unescaped to the output since ...ialex18:42, 23 June 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   00:16, 15 June 2011

Seems ok.

#Comment by Raymond (talk | contribs)   13:07, 23 June 2011

The errormessage 'dberrortext' is not longer rendered but shown as plain wiki text.

#Comment by Raymond (talk | contribs)   19:24, 23 June 2011

Fixed with r86722. Thanks :-)

Status & tagging log