| Index: trunk/phase3/includes/db/Database.php |
| — | — | @@ -2420,6 +2420,15 @@ |
| 2421 | 2421 | $this->db =& $db; |
| 2422 | 2422 | parent::__construct( $error ); |
| 2423 | 2423 | } |
| | 2424 | + |
| | 2425 | + function getText() { |
| | 2426 | + global $wgShowDBErrorBacktrace; |
| | 2427 | + $s = $this->getMessage() . "\n"; |
| | 2428 | + if ( $wgShowDBErrorBacktrace ) { |
| | 2429 | + $s .= "Backtrace:\n" . $this->getTraceAsString() . "\n"; |
| | 2430 | + } |
| | 2431 | + return $s; |
| | 2432 | + } |
| 2424 | 2433 | } |
| 2425 | 2434 | |
| 2426 | 2435 | /** |
| — | — | @@ -2447,10 +2456,6 @@ |
| 2448 | 2457 | return false; |
| 2449 | 2458 | } |
| 2450 | 2459 | |
| 2451 | | - function getText() { |
| 2452 | | - return $this->getMessage() . "\n"; |
| 2453 | | - } |
| 2454 | | - |
| 2455 | 2460 | function getLogMessage() { |
| 2456 | 2461 | # Don't send to the exception log |
| 2457 | 2462 | return false; |
| — | — | @@ -2467,7 +2472,7 @@ |
| 2468 | 2473 | } |
| 2469 | 2474 | |
| 2470 | 2475 | function getHTML() { |
| 2471 | | - global $wgLang, $wgMessageCache, $wgUseFileCache; |
| | 2476 | + global $wgLang, $wgMessageCache, $wgUseFileCache, $wgShowDBErrorBacktrace; |
| 2472 | 2477 | |
| 2473 | 2478 | $sorry = 'Sorry! This site is experiencing technical difficulties.'; |
| 2474 | 2479 | $again = 'Try waiting a few minutes and reloading.'; |
| — | — | @@ -2491,12 +2496,9 @@ |
| 2492 | 2497 | $noconnect = "<p><strong>$sorry</strong><br />$again</p><p><small>$info</small></p>"; |
| 2493 | 2498 | $text = str_replace( '$1', $this->error, $noconnect ); |
| 2494 | 2499 | |
| 2495 | | - /* |
| 2496 | | - if ( $GLOBALS['wgShowExceptionDetails'] ) { |
| 2497 | | - $text .= '</p><p>Backtrace:</p><p>' . |
| 2498 | | - nl2br( htmlspecialchars( $this->getTraceAsString() ) ) . |
| 2499 | | - "</p>\n"; |
| 2500 | | - }*/ |
| | 2500 | + if ( $wgShowDBErrorBacktrace ) { |
| | 2501 | + $text .= '<p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ); |
| | 2502 | + } |
| 2501 | 2503 | |
| 2502 | 2504 | $extra = $this->searchForm(); |
| 2503 | 2505 | |
| — | — | @@ -2613,11 +2615,16 @@ |
| 2614 | 2616 | } |
| 2615 | 2617 | |
| 2616 | 2618 | function getText() { |
| | 2619 | + global $wgShowDBErrorBacktrace; |
| 2617 | 2620 | if ( $this->useMessageCache() ) { |
| 2618 | | - return wfMsg( 'dberrortextcl', htmlspecialchars( $this->getSQL() ), |
| 2619 | | - htmlspecialchars( $this->fname ), $this->errno, htmlspecialchars( $this->error ) ) . "\n"; |
| | 2621 | + $s = wfMsg( 'dberrortextcl', htmlspecialchars( $this->getSQL() ), |
| | 2622 | + htmlspecialchars( $this->fname ), $this->errno, htmlspecialchars( $this->error ) ) . "\n"; |
| | 2623 | + if ( $wgShowDBErrorBacktrace ) { |
| | 2624 | + $s .= "Backtrace:\n" . $this->getTraceAsString() . "\n"; |
| | 2625 | + } |
| | 2626 | + return $s; |
| 2620 | 2627 | } else { |
| 2621 | | - return $this->getMessage(); |
| | 2628 | + return parent::getText(); |
| 2622 | 2629 | } |
| 2623 | 2630 | } |
| 2624 | 2631 | |
| — | — | @@ -2640,12 +2647,17 @@ |
| 2641 | 2648 | } |
| 2642 | 2649 | |
| 2643 | 2650 | function getHTML() { |
| | 2651 | + global $wgShowDBErrorBacktrace; |
| 2644 | 2652 | if ( $this->useMessageCache() ) { |
| 2645 | | - return wfMsgNoDB( 'dberrortext', htmlspecialchars( $this->getSQL() ), |
| | 2653 | + $s = wfMsgNoDB( 'dberrortext', htmlspecialchars( $this->getSQL() ), |
| 2646 | 2654 | htmlspecialchars( $this->fname ), $this->errno, htmlspecialchars( $this->error ) ); |
| 2647 | 2655 | } else { |
| 2648 | | - return nl2br( htmlspecialchars( $this->getMessage() ) ); |
| | 2656 | + $s = nl2br( htmlspecialchars( $this->getMessage() ) ); |
| 2649 | 2657 | } |
| | 2658 | + if ( $wgShowDBErrorBacktrace ) { |
| | 2659 | + $s .= '<p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ); |
| | 2660 | + } |
| | 2661 | + return $s; |
| 2650 | 2662 | } |
| 2651 | 2663 | } |
| 2652 | 2664 | |
| Index: trunk/phase3/includes/DefaultSettings.php |
| — | — | @@ -1173,6 +1173,11 @@ |
| 1174 | 1174 | $wgShowExceptionDetails = false; |
| 1175 | 1175 | |
| 1176 | 1176 | /** |
| | 1177 | + * If true, show a backtrace for database errors |
| | 1178 | + */ |
| | 1179 | +$wgShowDBErrorBacktrace = false; |
| | 1180 | + |
| | 1181 | +/** |
| 1177 | 1182 | * Expose backend server host names through the API and various HTML comments |
| 1178 | 1183 | */ |
| 1179 | 1184 | $wgShowHostnames = false; |
| Index: trunk/phase3/RELEASE-NOTES |
| — | — | @@ -201,6 +201,8 @@ |
| 202 | 202 | display-in-limit-form. |
| 203 | 203 | * (bug 18880) LogEventsList::showLogExtract() can now take a string-by-reference |
| 204 | 204 | and add its HTML to it, rather than having to go straight to $wgOut. |
| | 205 | +* Added $wgShowDBErrorBacktrace, to allow users to easily gather backtraces for |
| | 206 | + database connection and query errors. |
| 205 | 207 | |
| 206 | 208 | === Bug fixes in 1.16 === |
| 207 | 209 | |