Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -2874,10 +2874,18 @@ |
2875 | 2875 | parent::__construct( $error ); |
2876 | 2876 | } |
2877 | 2877 | |
| 2878 | + protected function getContentMessage( $html ) { |
| 2879 | + if ( $html ) { |
| 2880 | + return nl2br( htmlspecialchars( $this->getMessage() ) ); |
| 2881 | + } else { |
| 2882 | + return $this->getMessage(); |
| 2883 | + } |
| 2884 | + } |
| 2885 | + |
2878 | 2886 | function getText() { |
2879 | 2887 | global $wgShowDBErrorBacktrace; |
2880 | 2888 | |
2881 | | - $s = $this->getMessage() . "\n"; |
| 2889 | + $s = $this->getContentMessage( false ) . "\n"; |
2882 | 2890 | |
2883 | 2891 | if ( $wgShowDBErrorBacktrace ) { |
2884 | 2892 | $s .= "Backtrace:\n" . $this->getTraceAsString() . "\n"; |
— | — | @@ -2885,6 +2893,18 @@ |
2886 | 2894 | |
2887 | 2895 | return $s; |
2888 | 2896 | } |
| 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 | + } |
2889 | 2909 | } |
2890 | 2910 | |
2891 | 2911 | /** |
— | — | @@ -3084,20 +3104,17 @@ |
3085 | 3105 | $this->fname = $fname; |
3086 | 3106 | } |
3087 | 3107 | |
3088 | | - function getText() { |
3089 | | - global $wgShowDBErrorBacktrace; |
3090 | | - |
| 3108 | + function getContentMessage( $html ) { |
3091 | 3109 | 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 ); |
3097 | 3115 | } |
3098 | | - |
3099 | | - return $s; |
| 3116 | + return $ret; |
3100 | 3117 | } else { |
3101 | | - return parent::getText(); |
| 3118 | + return parent::getContentMessage( $html ); |
3102 | 3119 | } |
3103 | 3120 | } |
3104 | 3121 | |
— | — | @@ -3119,23 +3136,6 @@ |
3120 | 3137 | function getPageTitle() { |
3121 | 3138 | return $this->msg( 'databaseerror', 'Database error' ); |
3122 | 3139 | } |
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 | | - } |
3140 | 3140 | } |
3141 | 3141 | |
3142 | 3142 | /** |