Index: trunk/phase3/includes/SpecialEmailuser.php |
— | — | @@ -14,13 +14,13 @@ |
15 | 15 | global $wgUser, $wgOut, $wgRequest, $wgEnableEmail, $wgEnableUserEmail; |
16 | 16 | |
17 | 17 | if( !( $wgEnableEmail && $wgEnableUserEmail ) ) { |
18 | | - $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" ); |
| 18 | + $wgOut->showErrorPage( "nosuchspecialpage", "nospecialpagetext" ); |
19 | 19 | return; |
20 | 20 | } |
21 | 21 | |
22 | 22 | if( !$wgUser->canSendEmail() ) { |
23 | 23 | wfDebug( "User can't send.\n" ); |
24 | | - $wgOut->errorpage( "mailnologin", "mailnologintext" ); |
| 24 | + $wgOut->showErrorPage( "mailnologin", "mailnologintext" ); |
25 | 25 | return; |
26 | 26 | } |
27 | 27 | |
— | — | @@ -28,21 +28,21 @@ |
29 | 29 | $target = isset($par) ? $par : $wgRequest->getVal( 'target' ); |
30 | 30 | if ( "" == $target ) { |
31 | 31 | wfDebug( "Target is empty.\n" ); |
32 | | - $wgOut->errorpage( "notargettitle", "notargettext" ); |
| 32 | + $wgOut->showErrorPage( "notargettitle", "notargettext" ); |
33 | 33 | return; |
34 | 34 | } |
35 | 35 | |
36 | 36 | $nt = Title::newFromURL( $target ); |
37 | 37 | if ( is_null( $nt ) ) { |
38 | 38 | wfDebug( "Target is invalid title.\n" ); |
39 | | - $wgOut->errorpage( "notargettitle", "notargettext" ); |
| 39 | + $wgOut->showErrorPage( "notargettitle", "notargettext" ); |
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $nu = User::newFromName( $nt->getText() ); |
44 | 44 | if( is_null( $nu ) || !$nu->canReceiveEmail() ) { |
45 | 45 | wfDebug( "Target is invalid user or can't receive.\n" ); |
46 | | - $wgOut->errorpage( "noemailtitle", "noemailtext" ); |
| 46 | + $wgOut->showErrorPage( "noemailtitle", "noemailtext" ); |
47 | 47 | return; |
48 | 48 | } |
49 | 49 | |
Index: trunk/phase3/includes/Parser.php |
— | — | @@ -471,7 +471,7 @@ |
472 | 472 | $output = call_user_func_array( $this->mTagHooks[$tagName], |
473 | 473 | array( $content, $params, $this ) ); |
474 | 474 | } else { |
475 | | - wfDebugDieBacktrace( "Invalid call hook $element" ); |
| 475 | + throw new MWException( "Invalid call hook $element" ); |
476 | 476 | } |
477 | 477 | } |
478 | 478 | } else { |
— | — | @@ -1329,7 +1329,7 @@ |
1330 | 1330 | $useLinkPrefixExtension = $wgContLang->linkPrefixExtension(); |
1331 | 1331 | |
1332 | 1332 | if( is_null( $this->mTitle ) ) { |
1333 | | - wfDebugDieBacktrace( 'nooo' ); |
| 1333 | + throw new MWException( 'nooo' ); |
1334 | 1334 | } |
1335 | 1335 | $nottalk = !$this->mTitle->isTalkPage(); |
1336 | 1336 | |
— | — | @@ -2119,7 +2119,7 @@ |
2120 | 2120 | } |
2121 | 2121 | break; |
2122 | 2122 | default: |
2123 | | - wfDebugDieBacktrace( "State machine error in $fname" ); |
| 2123 | + throw new MWException( "State machine error in $fname" ); |
2124 | 2124 | } |
2125 | 2125 | } |
2126 | 2126 | if( $stack > 0 ) { |
Index: trunk/phase3/includes/Revision.php |
— | — | @@ -284,7 +284,7 @@ |
285 | 285 | $this->mTitle = null; # Load on demand if needed |
286 | 286 | $this->mCurrent = false; |
287 | 287 | } else { |
288 | | - wfDebugDieBacktrace( 'Revision constructor passed invalid row format.' ); |
| 288 | + throw new MWException( 'Revision constructor passed invalid row format.' ); |
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
— | — | @@ -606,7 +606,7 @@ |
607 | 607 | $data = ExternalStore::insert( $store, $data ); |
608 | 608 | if ( !$data ) { |
609 | 609 | # This should only happen in the case of a configuration error, where the external store is not valid |
610 | | - wfDebugDieBacktrace( "Unable to store text to external storage $store" ); |
| 610 | + throw new MWException( "Unable to store text to external storage $store" ); |
611 | 611 | } |
612 | 612 | if ( $flags ) { |
613 | 613 | $flags .= ','; |
Index: trunk/phase3/includes/User.php |
— | — | @@ -1192,7 +1192,7 @@ |
1193 | 1193 | * @deprecated |
1194 | 1194 | */ |
1195 | 1195 | function isSysop() { |
1196 | | - wfDebugDieBacktrace( "Call to deprecated (v1.7) User::isSysop() method\n" ); |
| 1196 | + throw new MWException( "Call to deprecated (v1.7) User::isSysop() method\n" ); |
1197 | 1197 | #return $this->isAllowed( 'protect' ); |
1198 | 1198 | } |
1199 | 1199 | |
— | — | @@ -1201,7 +1201,7 @@ |
1202 | 1202 | * @deprecated |
1203 | 1203 | */ |
1204 | 1204 | function isDeveloper() { |
1205 | | - wfDebugDieBacktrace( "Call to deprecated (v1.7) User::isDeveloper() method\n" ); |
| 1205 | + throw new MWException( "Call to deprecated (v1.7) User::isDeveloper() method\n" ); |
1206 | 1206 | #return $this->isAllowed( 'siteadmin' ); |
1207 | 1207 | } |
1208 | 1208 | |
— | — | @@ -1210,7 +1210,7 @@ |
1211 | 1211 | * @deprecated |
1212 | 1212 | */ |
1213 | 1213 | function isBureaucrat() { |
1214 | | - wfDebugDieBacktrace( "Call to deprecated (v1.7) User::isBureaucrat() method\n" ); |
| 1214 | + throw new MWException( "Call to deprecated (v1.7) User::isBureaucrat() method\n" ); |
1215 | 1215 | #return $this->isAllowed( 'makesysop' ); |
1216 | 1216 | } |
1217 | 1217 | |
Index: trunk/phase3/includes/ImagePage.php |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | * |
9 | 9 | */ |
10 | 10 | if( !defined( 'MEDIAWIKI' ) ) |
11 | | - die( -1 ); |
| 11 | + die( 1 ); |
12 | 12 | |
13 | 13 | require_once( 'Image.php' ); |
14 | 14 | |
— | — | @@ -453,7 +453,7 @@ |
454 | 454 | $wgOut->setPagetitle( wfMsg( 'confirmdelete' ) ); |
455 | 455 | if ( ( !is_null( $image ) ) |
456 | 456 | && ( '' == trim( $image ) ) ) { |
457 | | - $wgOut->fatalError( wfMsg( 'cannotdelete' ) ); |
| 457 | + $wgOut->showFatalError( wfMsg( 'cannotdelete' ) ); |
458 | 458 | return; |
459 | 459 | } |
460 | 460 | |
— | — | @@ -464,7 +464,7 @@ |
465 | 465 | if( $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) { |
466 | 466 | $this->doDelete(); |
467 | 467 | } else { |
468 | | - $wgOut->fatalError( wfMsg( 'sessionfailure' ) ); |
| 468 | + $wgOut->showFatalError( wfMsg( 'sessionfailure' ) ); |
469 | 469 | } |
470 | 470 | return; |
471 | 471 | } |
— | — | @@ -492,11 +492,11 @@ |
493 | 493 | |
494 | 494 | if ( !is_null( $oldimage ) ) { |
495 | 495 | if ( strlen( $oldimage ) < 16 ) { |
496 | | - $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) ); |
| 496 | + $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) ); |
497 | 497 | return; |
498 | 498 | } |
499 | 499 | if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) { |
500 | | - $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) ); |
| 500 | + $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) ); |
501 | 501 | return; |
502 | 502 | } |
503 | 503 | |
— | — | @@ -511,7 +511,9 @@ |
512 | 512 | ); |
513 | 513 | wfPurgeSquidServers($urlArr); |
514 | 514 | } |
515 | | - $this->doDeleteOldImage( $oldimage ); |
| 515 | + if ( !$this->doDeleteOldImage( $oldimage ) ) { |
| 516 | + return; |
| 517 | + } |
516 | 518 | $dbw->delete( 'oldimage', array( 'oi_archive_name' => $oldimage ) ); |
517 | 519 | $deleted = $oldimage; |
518 | 520 | } else { |
— | — | @@ -524,7 +526,7 @@ |
525 | 527 | $targetFile = "{$dest}/{$image}"; |
526 | 528 | if( file_exists( $targetFile ) && ! @unlink( $targetFile ) ) { |
527 | 529 | # If the deletion operation actually failed, bug out: |
528 | | - $wgOut->fileDeleteError( $targetFile ); |
| 530 | + $wgOut->showFileDeleteError( $targetFile ); |
529 | 531 | return; |
530 | 532 | } |
531 | 533 | $dbw->delete( 'image', array( 'img_name' => $image ) ); |
— | — | @@ -541,7 +543,9 @@ |
542 | 544 | # Purge archive URLs from the squid |
543 | 545 | $urlArr = Array(); |
544 | 546 | while ( $s = $dbw->fetchObject( $res ) ) { |
545 | | - $this->doDeleteOldImage( $s->oi_archive_name ); |
| 547 | + if ( !$this->doDeleteOldImage( $s->oi_archive_name ) ) { |
| 548 | + return; |
| 549 | + } |
546 | 550 | $urlArr[] = wfImageArchiveUrl( $s->oi_archive_name ); |
547 | 551 | } |
548 | 552 | |
— | — | @@ -581,6 +585,9 @@ |
582 | 586 | $wgOut->returnToMain( false, $this->mTitle->getPrefixedText() ); |
583 | 587 | } |
584 | 588 | |
| 589 | + /** |
| 590 | + * @return success |
| 591 | + */ |
585 | 592 | function doDeleteOldImage( $oldimage ) |
586 | 593 | { |
587 | 594 | global $wgOut; |
— | — | @@ -598,11 +605,13 @@ |
599 | 606 | $targetFile = "{$archive}/{$oldimage}"; |
600 | 607 | if( $oldimage != '' && file_exists( $targetFile ) && !@unlink( $targetFile ) ) { |
601 | 608 | # If we actually have a file and can't delete it, throw an error. |
602 | | - $wgOut->fileDeleteError( "{$archive}/{$oldimage}" ); |
| 609 | + $wgOut->showFileDeleteError( "{$archive}/{$oldimage}" ); |
| 610 | + return false; |
603 | 611 | } else { |
604 | 612 | # Log the deletion |
605 | 613 | $log = new LogPage( 'delete' ); |
606 | 614 | $log->addEntry( 'delete', $this->mTitle, wfMsg('deletedrevision',$oldimage) ); |
| 615 | + return true; |
607 | 616 | } |
608 | 617 | } |
609 | 618 | |
— | — | @@ -611,11 +620,11 @@ |
612 | 621 | |
613 | 622 | $oldimage = $wgRequest->getText( 'oldimage' ); |
614 | 623 | if ( strlen( $oldimage ) < 16 ) { |
615 | | - $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) ); |
| 624 | + $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) ); |
616 | 625 | return; |
617 | 626 | } |
618 | 627 | if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) { |
619 | | - $wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) ); |
| 628 | + $wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) ); |
620 | 629 | return; |
621 | 630 | } |
622 | 631 | |
— | — | @@ -624,7 +633,7 @@ |
625 | 634 | return; |
626 | 635 | } |
627 | 636 | if( $wgUser->isAnon() ) { |
628 | | - $wgOut->errorpage( 'uploadnologin', 'uploadnologintext' ); |
| 637 | + $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' ); |
629 | 638 | return; |
630 | 639 | } |
631 | 640 | if ( ! $this->mTitle->userCanEdit() ) { |
— | — | @@ -635,7 +644,7 @@ |
636 | 645 | return $this->blockedIPpage(); |
637 | 646 | } |
638 | 647 | if( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) { |
639 | | - $wgOut->errorpage( 'internalerror', 'sessionfailure' ); |
| 648 | + $wgOut->showErrorPage( 'internalerror', 'sessionfailure' ); |
640 | 649 | return; |
641 | 650 | } |
642 | 651 | $name = substr( $oldimage, 15 ); |
— | — | @@ -645,7 +654,7 @@ |
646 | 655 | $curfile = "{$dest}/{$name}"; |
647 | 656 | |
648 | 657 | if ( ! is_file( $curfile ) ) { |
649 | | - $wgOut->fileNotFoundError( htmlspecialchars( $curfile ) ); |
| 658 | + $wgOut->showFileNotFoundError( htmlspecialchars( $curfile ) ); |
650 | 659 | return; |
651 | 660 | } |
652 | 661 | $oldver = wfTimestampNow() . "!{$name}"; |
— | — | @@ -654,11 +663,12 @@ |
655 | 664 | $size = $dbr->selectField( 'oldimage', 'oi_size', array( 'oi_archive_name' => $oldimage ) ); |
656 | 665 | |
657 | 666 | if ( ! rename( $curfile, "${archive}/{$oldver}" ) ) { |
658 | | - $wgOut->fileRenameError( $curfile, "${archive}/{$oldver}" ); |
| 667 | + $wgOut->showFileRenameError( $curfile, "${archive}/{$oldver}" ); |
659 | 668 | return; |
660 | 669 | } |
661 | 670 | if ( ! copy( "{$archive}/{$oldimage}", $curfile ) ) { |
662 | | - $wgOut->fileCopyError( "${archive}/{$oldimage}", $curfile ); |
| 671 | + $wgOut->showFileCopyError( "${archive}/{$oldimage}", $curfile ); |
| 672 | + return; |
663 | 673 | } |
664 | 674 | |
665 | 675 | # Record upload and update metadata cache |
Index: trunk/phase3/includes/Export.php |
— | — | @@ -634,7 +634,7 @@ |
635 | 635 | $ns = intval( $key ); |
636 | 636 | $this->namespaces[$ns] = true; |
637 | 637 | } else { |
638 | | - wfDie( "Unrecognized namespace key '$key'\n" ); |
| 638 | + throw new MWException( "Unrecognized namespace key '$key'\n" ); |
639 | 639 | } |
640 | 640 | } |
641 | 641 | } |
Index: trunk/phase3/includes/LinksUpdate.php |
— | — | @@ -44,7 +44,7 @@ |
45 | 45 | $this->mDb =& wfGetDB( DB_MASTER ); |
46 | 46 | |
47 | 47 | if ( !is_object( $title ) ) { |
48 | | - wfDebugDieBacktrace( "The calling convention to LinksUpdate::LinksUpdate() has changed. " . |
| 48 | + throw new MWException( "The calling convention to LinksUpdate::LinksUpdate() has changed. " . |
49 | 49 | "Please see Article::editUpdates() for an invocation example.\n" ); |
50 | 50 | } |
51 | 51 | $this->mTitle = $title; |
Index: trunk/phase3/includes/MessageCache.php |
— | — | @@ -291,7 +291,7 @@ |
292 | 292 | $fname = 'MessageCache::loadFromDB'; |
293 | 293 | $dbr =& wfGetDB( DB_SLAVE ); |
294 | 294 | if ( !$dbr ) { |
295 | | - wfDebugDieBacktrace( 'Invalid database object' ); |
| 295 | + throw new MWException( 'Invalid database object' ); |
296 | 296 | } |
297 | 297 | $conditions = array( 'page_is_redirect' => 0, |
298 | 298 | 'page_namespace' => NS_MEDIAWIKI); |
Index: trunk/phase3/includes/SpecialWhatlinkshere.php |
— | — | @@ -43,13 +43,13 @@ |
44 | 44 | $targetString = isset($this->par) ? $this->par : $this->request->getVal( 'target' ); |
45 | 45 | |
46 | 46 | if (is_null($targetString)) { |
47 | | - $wgOut->errorpage( 'notargettitle', 'notargettext' ); |
| 47 | + $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); |
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
51 | 51 | $this->target = Title::newFromURL( $targetString ); |
52 | 52 | if( !$this->target ) { |
53 | | - $wgOut->errorpage( 'notargettitle', 'notargettext' ); |
| 53 | + $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); |
54 | 54 | return; |
55 | 55 | } |
56 | 56 | $this->selfTitle = Title::makeTitleSafe( NS_SPECIAL, |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -1464,7 +1464,7 @@ |
1465 | 1465 | $wgOut->returnToMain( false, $rcTitle->getPrefixedText() ); |
1466 | 1466 | } |
1467 | 1467 | else { |
1468 | | - $wgOut->errorpage( 'markedaspatrollederror', 'markedaspatrollederrortext' ); |
| 1468 | + $wgOut->showErrorPage( 'markedaspatrollederror', 'markedaspatrollederrortext' ); |
1469 | 1469 | } |
1470 | 1470 | } |
1471 | 1471 | |
— | — | @@ -1477,7 +1477,7 @@ |
1478 | 1478 | global $wgUser, $wgOut; |
1479 | 1479 | |
1480 | 1480 | if ( $wgUser->isAnon() ) { |
1481 | | - $wgOut->errorpage( 'watchnologin', 'watchnologintext' ); |
| 1481 | + $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' ); |
1482 | 1482 | return; |
1483 | 1483 | } |
1484 | 1484 | if ( wfReadOnly() ) { |
— | — | @@ -1525,7 +1525,7 @@ |
1526 | 1526 | global $wgUser, $wgOut; |
1527 | 1527 | |
1528 | 1528 | if ( $wgUser->isAnon() ) { |
1529 | | - $wgOut->errorpage( 'watchnologin', 'watchnologintext' ); |
| 1529 | + $wgOut->showErrorPage( 'watchnologin', 'watchnologintext' ); |
1530 | 1530 | return; |
1531 | 1531 | } |
1532 | 1532 | if ( wfReadOnly() ) { |
— | — | @@ -1658,7 +1658,7 @@ |
1659 | 1659 | */ |
1660 | 1660 | function flattenRestrictions( $limit ) { |
1661 | 1661 | if( !is_array( $limit ) ) { |
1662 | | - wfDebugDieBacktrace( 'Article::flattenRestrictions given non-array restriction set' ); |
| 1662 | + throw new MWException( 'Article::flattenRestrictions given non-array restriction set' ); |
1663 | 1663 | } |
1664 | 1664 | $bits = array(); |
1665 | 1665 | ksort( $limit ); |
— | — | @@ -1705,7 +1705,7 @@ |
1706 | 1706 | $conds = $this->mTitle->pageCond(); |
1707 | 1707 | $latest = $dbw->selectField( 'page', 'page_latest', $conds, $fname ); |
1708 | 1708 | if ( $latest === false ) { |
1709 | | - $wgOut->fatalError( wfMsg( 'cannotdelete' ) ); |
| 1709 | + $wgOut->showFatalError( wfMsg( 'cannotdelete' ) ); |
1710 | 1710 | return; |
1711 | 1711 | } |
1712 | 1712 | |
— | — | @@ -1899,7 +1899,7 @@ |
1900 | 1900 | $wgOut->returnToMain( false ); |
1901 | 1901 | wfRunHooks('ArticleDeleteComplete', array(&$this, &$wgUser, $reason)); |
1902 | 1902 | } else { |
1903 | | - $wgOut->fatalError( wfMsg( 'cannotdelete' ) ); |
| 1903 | + $wgOut->showFatalError( wfMsg( 'cannotdelete' ) ); |
1904 | 1904 | } |
1905 | 1905 | } |
1906 | 1906 | } |
— | — | @@ -2522,7 +2522,7 @@ |
2523 | 2523 | $fname = 'Article::info'; |
2524 | 2524 | |
2525 | 2525 | if ( !$wgAllowPageInfo ) { |
2526 | | - $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' ); |
| 2526 | + $wgOut->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); |
2527 | 2527 | return; |
2528 | 2528 | } |
2529 | 2529 | |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -642,7 +642,7 @@ |
643 | 643 | */ |
644 | 644 | function wfDie( $msg='' ) { |
645 | 645 | echo $msg; |
646 | | - die( -1 ); |
| 646 | + die( 1 ); |
647 | 647 | } |
648 | 648 | |
649 | 649 | /** |
— | — | @@ -665,7 +665,7 @@ |
666 | 666 | } |
667 | 667 | echo $msg; |
668 | 668 | echo wfReportTime()."\n"; |
669 | | - die( -1 ); |
| 669 | + die( 1 ); |
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
— | — | @@ -1364,7 +1364,7 @@ |
1365 | 1365 | case TS_ORACLE: |
1366 | 1366 | return gmdate( 'd-M-y h.i.s A', $uts) . ' +00:00'; |
1367 | 1367 | default: |
1368 | | - wfDebugDieBacktrace( 'wfTimestamp() called with illegal output type.'); |
| 1368 | + throw new MWException( 'wfTimestamp() called with illegal output type.'); |
1369 | 1369 | } |
1370 | 1370 | } |
1371 | 1371 | |
— | — | @@ -1605,7 +1605,7 @@ |
1606 | 1606 | */ |
1607 | 1607 | function wfAppendToArrayIfNotDefault( $key, $value, $default, &$changed ) { |
1608 | 1608 | if ( is_null( $changed ) ) { |
1609 | | - wfDebugDieBacktrace('GlobalFunctions::wfAppendToArrayIfNotDefault got null'); |
| 1609 | + throw new MWException('GlobalFunctions::wfAppendToArrayIfNotDefault got null'); |
1610 | 1610 | } |
1611 | 1611 | if ( $default[$key] !== $value ) { |
1612 | 1612 | $changed[$key] = $value; |
— | — | @@ -1726,7 +1726,7 @@ |
1727 | 1727 | $php_ver = PHP_VERSION; |
1728 | 1728 | |
1729 | 1729 | if ( version_compare( $php_ver, (string)$req_ver, '<' ) ) |
1730 | | - wfDebugDieBacktrace( "PHP $req_ver required--this is only $php_ver" ); |
| 1730 | + throw new MWException( "PHP $req_ver required--this is only $php_ver" ); |
1731 | 1731 | } |
1732 | 1732 | |
1733 | 1733 | /** |
— | — | @@ -1746,7 +1746,7 @@ |
1747 | 1747 | global $wgVersion; |
1748 | 1748 | |
1749 | 1749 | if ( version_compare( $wgVersion, (string)$req_ver, '<' ) ) |
1750 | | - wfDebugDieBacktrace( "MediaWiki $req_ver required--this is only $wgVersion" ); |
| 1750 | + throw new MWException( "MediaWiki $req_ver required--this is only $wgVersion" ); |
1751 | 1751 | } |
1752 | 1752 | |
1753 | 1753 | /** |
Index: trunk/phase3/includes/Group.php |
— | — | @@ -90,7 +90,7 @@ |
91 | 91 | /** Initialise a new row in the database */ |
92 | 92 | function addToDatabase() { |
93 | 93 | if ( Group::getStaticGroups() ) { |
94 | | - wfDebugDieBacktrace( "Can't modify groups in static mode" ); |
| 94 | + throw new MWException( "Can't modify groups in static mode" ); |
95 | 95 | } |
96 | 96 | |
97 | 97 | $fname = 'Group::addToDatabase'; |
— | — | @@ -110,7 +110,7 @@ |
111 | 111 | global $wgMemc; |
112 | 112 | |
113 | 113 | if ( Group::getStaticGroups() ) { |
114 | | - wfDebugDieBacktrace( "Can't modify groups in static mode" ); |
| 114 | + throw new MWException( "Can't modify groups in static mode" ); |
115 | 115 | } |
116 | 116 | if($this->id == 0) { return; } |
117 | 117 | |
— | — | @@ -136,7 +136,7 @@ |
137 | 137 | global $wgMemc; |
138 | 138 | |
139 | 139 | if ( Group::getStaticGroups() ) { |
140 | | - wfDebugDieBacktrace( "Can't modify groups in static mode" ); |
| 140 | + throw new MWException( "Can't modify groups in static mode" ); |
141 | 141 | } |
142 | 142 | if($this->id == 0) { return; } |
143 | 143 | |
Index: trunk/phase3/includes/DatabaseFunctions.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | global $wgOut; |
20 | 20 | if ( !is_numeric( $db ) ) { |
21 | 21 | # Someone has tried to call this the old way |
22 | | - $wgOut->fatalError( wfMsgNoDB( 'wrong_wfQuery_params', $db, $sql ) ); |
| 22 | + throw new FatalError( wfMsgNoDB( 'wrong_wfQuery_params', $db, $sql ) ); |
23 | 23 | } |
24 | 24 | $c =& wfGetDB( $db ); |
25 | 25 | if ( $c !== false ) { |
Index: trunk/phase3/includes/SpecialContributions.php |
— | — | @@ -157,13 +157,13 @@ |
158 | 158 | |
159 | 159 | $target = isset($par) ? $par : $wgRequest->getVal( 'target' ); |
160 | 160 | if (!strlen($target)) { |
161 | | - $wgOut->errorpage('notargettitle', 'notargettext'); |
| 161 | + $wgOut->showErrorPage('notargettitle', 'notargettext'); |
162 | 162 | return; |
163 | 163 | } |
164 | 164 | |
165 | 165 | $nt = Title::newFromURL( $target ); |
166 | 166 | if (!$nt) { |
167 | | - $wgOut->errorpage( 'notargettitle', 'notargettext' ); |
| 167 | + $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); |
168 | 168 | return; |
169 | 169 | } |
170 | 170 | |
Index: trunk/phase3/includes/Sanitizer.php |
— | — | @@ -742,7 +742,7 @@ |
743 | 743 | # For 'reduced' form, return explicitly the attribute name here. |
744 | 744 | return $set[1]; |
745 | 745 | } else { |
746 | | - wfDebugDieBacktrace( "Tag conditions not met. This should never happen and is a bug." ); |
| 746 | + throw new MWException( "Tag conditions not met. This should never happen and is a bug." ); |
747 | 747 | } |
748 | 748 | } |
749 | 749 | |
Index: trunk/phase3/includes/SpecialUploadMogile.php |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | if( $mfs->getPaths( $this->mSavedFile )) { |
44 | 44 | $this->mUploadOldVersion = gmdate( 'YmdHis' ) . "!{$saveName}"; |
45 | 45 | if( !$mfs->rename( $this->mSavedFile, "archive!{$this->mUploadOldVersion}" ) ) { |
46 | | - $wgOut->fileRenameError( $this->mSavedFile, |
| 46 | + $wgOut->showFileRenameError( $this->mSavedFile, |
47 | 47 | "archive!{$this->mUploadOldVersion}" ); |
48 | 48 | return false; |
49 | 49 | } |
— | — | @@ -52,12 +52,12 @@ |
53 | 53 | |
54 | 54 | if ( $this->mStashed ) { |
55 | 55 | if (!$mfs->rename($tempName,$this->mSavedFile)) { |
56 | | - $wgOut->fileRenameError($tempName, $this->mSavedFile ); |
| 56 | + $wgOut->showFileRenameError($tempName, $this->mSavedFile ); |
57 | 57 | return false; |
58 | 58 | } |
59 | 59 | } else { |
60 | 60 | if ( !$mfs->saveFile($this->mSavedFile,'normal',$tempName )) { |
61 | | - $wgOut->fileCopyError( $tempName, $this->mSavedFile ); |
| 61 | + $wgOut->showFileCopyError( $tempName, $this->mSavedFile ); |
62 | 62 | return false; |
63 | 63 | } |
64 | 64 | unlink($tempName); |
— | — | @@ -83,7 +83,7 @@ |
84 | 84 | $stash = 'stash!' . gmdate( "YmdHis" ) . '!' . $saveName; |
85 | 85 | $mfs = MogileFS::NewMogileFS(); |
86 | 86 | if ( !$mfs->saveFile( $stash, 'normal', $tempName ) ) { |
87 | | - $wgOut->fileCopyError( $tempName, $stash ); |
| 87 | + $wgOut->showFileCopyError( $tempName, $stash ); |
88 | 88 | return false; |
89 | 89 | } |
90 | 90 | unlink($tempName); |
— | — | @@ -119,12 +119,16 @@ |
120 | 120 | /** |
121 | 121 | * Remove a temporarily kept file stashed by saveTempUploadedFile(). |
122 | 122 | * @access private |
| 123 | + * @return success |
123 | 124 | */ |
124 | 125 | function unsaveUploadedFile() { |
125 | 126 | global $wgOut; |
126 | 127 | $mfs = MogileFS::NewMogileFS(); |
127 | 128 | if ( ! $mfs->delete( $this->mUploadTempName ) ) { |
128 | | - $wgOut->fileDeleteError( $this->mUploadTempName ); |
| 129 | + $wgOut->showFileDeleteError( $this->mUploadTempName ); |
| 130 | + return false; |
| 131 | + } else { |
| 132 | + return true; |
129 | 133 | } |
130 | 134 | } |
131 | 135 | } |
Index: trunk/phase3/includes/MagicWord.php |
— | — | @@ -192,7 +192,7 @@ |
193 | 193 | global $wgMagicWords; |
194 | 194 | |
195 | 195 | if ( !is_array( $wgMagicWords ) ) { |
196 | | - wfDebugDieBacktrace( "Incorrect initialisation order, \$wgMagicWords does not exist\n" ); |
| 196 | + throw new MWException( "Incorrect initialisation order, \$wgMagicWords does not exist\n" ); |
197 | 197 | } |
198 | 198 | if (!array_key_exists( $id, $wgMagicWords ) ) { |
199 | 199 | $mw = new MagicWord(); |
Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -293,7 +293,7 @@ |
294 | 294 | $wgOut->setArticleRelated( false ); |
295 | 295 | $wgOut->setRobotpolicy( 'noindex,nofollow' ); |
296 | 296 | $wgOut->setStatusCode( 404 ); |
297 | | - $wgOut->errorpage( 'nosuchspecialpage', 'nospecialpagetext' ); |
| 297 | + $wgOut->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' ); |
298 | 298 | $retVal = false; |
299 | 299 | } |
300 | 300 | } |
Index: trunk/phase3/includes/SpecialLockdb.php |
— | — | @@ -94,7 +94,7 @@ |
95 | 95 | $fp = fopen( $wgReadOnlyFile, 'w' ); |
96 | 96 | |
97 | 97 | if ( false === $fp ) { |
98 | | - $wgOut->fileNotFoundError( $wgReadOnlyFile ); |
| 98 | + $wgOut->showFileNotFoundError( $wgReadOnlyFile ); |
99 | 99 | return; |
100 | 100 | } |
101 | 101 | fwrite( $fp, $this->reason ); |
Index: trunk/phase3/includes/HistoryBlob.php |
— | — | @@ -59,7 +59,7 @@ |
60 | 60 | |
61 | 61 | function ConcatenatedGzipHistoryBlob() { |
62 | 62 | if ( !function_exists( 'gzdeflate' ) ) { |
63 | | - wfDie( "Need zlib support to read or write this kind of history object (ConcatenatedGzipHistoryBlob)\n" ); |
| 63 | + throw new MWException( "Need zlib support to read or write this kind of history object (ConcatenatedGzipHistoryBlob)\n" ); |
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -51,7 +51,7 @@ |
52 | 52 | } elseif( is_string( $article ) ) { |
53 | 53 | $output->redirect( $article ); |
54 | 54 | } else { |
55 | | - wfDebugDieBacktrace( "Shouldn't happen: MediaWiki::initializeArticle() returned neither an object nor a URL" ); |
| 55 | + throw new MWException( "Shouldn't happen: MediaWiki::initializeArticle() returned neither an object nor a URL" ); |
56 | 56 | } |
57 | 57 | } |
58 | 58 | wfProfileOut( 'MediaWiki::initialize' ); |
— | — | @@ -129,7 +129,8 @@ |
130 | 130 | wfSpecialSearch(); |
131 | 131 | } else if( !$title or $title->getDBkey() == '' ) { |
132 | 132 | $title = Title::newFromText( wfMsgForContent( 'badtitle' ) ); |
133 | | - $output->errorpage( 'badtitle', 'badtitletext' ); |
| 133 | + # Die now before we mess up $wgArticle and the skin stops working |
| 134 | + throw new ErrorPageError( 'badtitle', 'badtitletext' ); |
134 | 135 | } else if ( $title->getInterwiki() != '' ) { |
135 | 136 | if( $rdfrom = $request->getVal( 'rdfrom' ) ) { |
136 | 137 | $url = $title->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) ); |
— | — | @@ -141,7 +142,7 @@ |
142 | 143 | $output->redirect( $url ); |
143 | 144 | } else { |
144 | 145 | $title = Title::newFromText( wfMsgForContent( 'badtitle' ) ); |
145 | | - $output->errorpage( 'badtitle', 'badtitletext' ); |
| 146 | + throw new ErrorPageError( 'badtitle', 'badtitletext' ); |
146 | 147 | } |
147 | 148 | } else if ( ( $action == 'view' ) && |
148 | 149 | (!isset( $this->GET['title'] ) || $title->getPrefixedDBKey() != $this->GET['title'] ) && |
— | — | @@ -392,7 +393,7 @@ |
393 | 394 | break; |
394 | 395 | default: |
395 | 396 | if( wfRunHooks( 'UnknownAction', array( $action, $article ) ) ) { |
396 | | - $output->errorpage( 'nosuchaction', 'nosuchactiontext' ); |
| 397 | + $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); |
397 | 398 | } |
398 | 399 | } |
399 | 400 | wfProfileOut( 'MediaWiki::performAction' ); |
Index: trunk/phase3/includes/SpecialMovepage.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | |
15 | 15 | # check rights. We don't want newbies to move pages to prevents possible attack |
16 | 16 | if ( !$wgUser->isAllowed( 'move' ) or $wgUser->isBlocked() or ($wgOnlySysopMayMove and $wgUser->isNewbie())) { |
17 | | - $wgOut->errorpage( "movenologin", "movenologintext" ); |
| 17 | + $wgOut->showErrorPage( "movenologin", "movenologintext" ); |
18 | 18 | return; |
19 | 19 | } |
20 | 20 | # We don't move protected pages |
— | — | @@ -60,7 +60,7 @@ |
61 | 61 | |
62 | 62 | $ot = Title::newFromURL( $this->oldTitle ); |
63 | 63 | if( is_null( $ot ) ) { |
64 | | - $wgOut->errorpage( 'notargettitle', 'notargettext' ); |
| 64 | + $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); |
65 | 65 | return; |
66 | 66 | } |
67 | 67 | $oldTitle = $ot->getPrefixedText(); |
Index: trunk/phase3/includes/SpecialRevisiondelete.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | $page = Title::newFromUrl( $target ); |
21 | 21 | |
22 | 22 | if( is_null( $page ) ) { |
23 | | - $wgOut->errorpage( 'notargettitle', 'notargettext' ); |
| 23 | + $wgOut->showErrorPage( 'notargettitle', 'notargettext' ); |
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | if ( ! defined( 'MEDIAWIKI' ) ) |
4 | | - die( -1 ); |
| 4 | + die( 1 ); |
5 | 5 | /** |
6 | 6 | * @package MediaWiki |
7 | 7 | */ |
— | — | @@ -666,7 +666,7 @@ |
667 | 667 | /** |
668 | 668 | * Note: these arguments are keys into wfMsg(), not text! |
669 | 669 | */ |
670 | | - function errorpage( $title, $msg ) { |
| 670 | + function showErrorPage( $title, $msg ) { |
671 | 671 | global $wgTitle; |
672 | 672 | |
673 | 673 | $this->mDebugtext .= 'Original title: ' . |
— | — | @@ -681,11 +681,13 @@ |
682 | 682 | $this->mBodytext = ''; |
683 | 683 | $this->addWikiText( wfMsg( $msg ) ); |
684 | 684 | $this->returnToMain( false ); |
| 685 | + } |
685 | 686 | |
686 | | - $this->output(); |
687 | | - wfErrorExit(); |
| 687 | + /** @obsolete */ |
| 688 | + function errorpage( $title, $msg ) { |
| 689 | + throw new ErrorPageError( $title, $msg ); |
688 | 690 | } |
689 | | - |
| 691 | + |
690 | 692 | /** |
691 | 693 | * Display an error page indicating that a given version of MediaWiki is |
692 | 694 | * required to use it |
— | — | @@ -779,34 +781,9 @@ |
780 | 782 | $this->returnToMain(); |
781 | 783 | } |
782 | 784 | |
| 785 | + /** @obsolete */ |
783 | 786 | function databaseError( $fname, $sql, $error, $errno ) { |
784 | | - global $wgUser, $wgCommandLineMode, $wgShowSQLErrors; |
785 | | - |
786 | | - $this->setPageTitle( wfMsgNoDB( 'databaseerror' ) ); |
787 | | - $this->setRobotpolicy( 'noindex,nofollow' ); |
788 | | - $this->setArticleRelated( false ); |
789 | | - $this->enableClientCache( false ); |
790 | | - $this->mRedirect = ''; |
791 | | - |
792 | | - if( !$wgShowSQLErrors ) { |
793 | | - $sql = wfMsg( 'sqlhidden' ); |
794 | | - } |
795 | | - |
796 | | - if ( $wgCommandLineMode ) { |
797 | | - $msg = wfMsgNoDB( 'dberrortextcl', htmlspecialchars( $sql ), |
798 | | - htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) ); |
799 | | - } else { |
800 | | - $msg = wfMsgNoDB( 'dberrortext', htmlspecialchars( $sql ), |
801 | | - htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) ); |
802 | | - } |
803 | | - |
804 | | - if ( $wgCommandLineMode || !is_object( $wgUser )) { |
805 | | - print $msg."\n"; |
806 | | - wfErrorExit(); |
807 | | - } |
808 | | - $this->mBodytext = $msg; |
809 | | - $this->output(); |
810 | | - wfErrorExit(); |
| 787 | + throw new MWException( "OutputPage::databaseError is obsolete\n" ); |
811 | 788 | } |
812 | 789 | |
813 | 790 | function readOnlyPage( $source = null, $protected = false ) { |
— | — | @@ -857,36 +834,63 @@ |
858 | 835 | $this->returnToMain( false ); |
859 | 836 | } |
860 | 837 | |
861 | | - function fatalError( $message ) { |
| 838 | + /** @obsolete */ |
| 839 | + function fatalError( $message ) { |
| 840 | + throw new FatalError( $message ); |
| 841 | + } |
| 842 | + |
| 843 | + /** @obsolete */ |
| 844 | + function unexpectedValueError( $name, $val ) { |
| 845 | + throw new FatalError( wfMsg( 'unexpected', $name, $val ) ); |
| 846 | + } |
| 847 | + |
| 848 | + /** @obsolete */ |
| 849 | + function fileCopyError( $old, $new ) { |
| 850 | + throw new FatalError( wfMsg( 'filecopyerror', $old, $new ) ); |
| 851 | + } |
| 852 | + |
| 853 | + /** @obsolete */ |
| 854 | + function fileRenameError( $old, $new ) { |
| 855 | + throw new FatalError( wfMsg( 'filerenameerror', $old, $new ) ); |
| 856 | + } |
| 857 | + |
| 858 | + /** @obsolete */ |
| 859 | + function fileDeleteError( $name ) { |
| 860 | + throw new FatalError( wfMsg( 'filedeleteerror', $name ) ); |
| 861 | + } |
| 862 | + |
| 863 | + /** @obsolete */ |
| 864 | + function fileNotFoundError( $name ) { |
| 865 | + throw new FatalError( wfMsg( 'filenotfound', $name ) ); |
| 866 | + } |
| 867 | + |
| 868 | + function showFatalError( $message ) { |
862 | 869 | $this->setPageTitle( wfMsg( "internalerror" ) ); |
863 | 870 | $this->setRobotpolicy( "noindex,nofollow" ); |
864 | 871 | $this->setArticleRelated( false ); |
865 | 872 | $this->enableClientCache( false ); |
866 | 873 | $this->mRedirect = ''; |
867 | | - |
868 | 874 | $this->mBodytext = $message; |
869 | | - $this->output(); |
870 | | - wfErrorExit(); |
871 | 875 | } |
872 | 876 | |
873 | | - function unexpectedValueError( $name, $val ) { |
874 | | - $this->fatalError( wfMsg( 'unexpected', $name, $val ) ); |
| 877 | + function showUnexpectedValueError( $name, $val ) { |
| 878 | + $this->showFatalError( wfMsg( 'unexpected', $name, $val ) ); |
875 | 879 | } |
876 | 880 | |
877 | | - function fileCopyError( $old, $new ) { |
878 | | - $this->fatalError( wfMsg( 'filecopyerror', $old, $new ) ); |
| 881 | + function showFileCopyError( $old, $new ) { |
| 882 | + $this->showFatalError( wfMsg( 'filecopyerror', $old, $new ) ); |
879 | 883 | } |
880 | 884 | |
881 | | - function fileRenameError( $old, $new ) { |
882 | | - $this->fatalError( wfMsg( 'filerenameerror', $old, $new ) ); |
| 885 | + function showFileRenameError( $old, $new ) { |
| 886 | + $this->showFatalError( wfMsg( 'filerenameerror', $old, $new ) ); |
883 | 887 | } |
884 | 888 | |
885 | | - function fileDeleteError( $name ) { |
886 | | - $this->fatalError( wfMsg( 'filedeleteerror', $name ) ); |
| 889 | + function showFileDeleteError( $name ) { |
| 890 | + $this->showFatalError( wfMsg( 'filedeleteerror', $name ) ); |
887 | 891 | } |
888 | 892 | |
889 | | - function fileNotFoundError( $name ) { |
890 | | - $this->fatalError( wfMsg( 'filenotfound', $name ) ); |
| 893 | + function showFileNotFoundError( $name ) { |
| 894 | + $this->showFatalError( wfMsg( 'filenotfound', $name ) ); |
891 | 895 | } |
892 | 896 | |
893 | 897 | /** |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | // Check to see if we are at the file scope |
21 | 21 | if ( !isset( $wgVersion ) ) { |
22 | 22 | echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n"; |
23 | | - die( -1 ); |
| 23 | + die( 1 ); |
24 | 24 | } |
25 | 25 | |
26 | 26 | if( !isset( $wgProfiling ) ) |
Index: trunk/phase3/includes/SpecialUndelete.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | |
30 | 30 | function PageArchive( &$title ) { |
31 | 31 | if( is_null( $title ) ) { |
32 | | - wfDebugDieBacktrace( 'Archiver() given a null title.'); |
| 32 | + throw new MWException( 'Archiver() given a null title.'); |
33 | 33 | } |
34 | 34 | $this->title =& $title; |
35 | 35 | } |
— | — | @@ -566,7 +566,7 @@ |
567 | 567 | return true; |
568 | 568 | } |
569 | 569 | } |
570 | | - $wgOut->fatalError( wfMsg( "cannotundelete" ) ); |
| 570 | + $wgOut->showFatalError( wfMsg( "cannotundelete" ) ); |
571 | 571 | return false; |
572 | 572 | } |
573 | 573 | } |
Index: trunk/phase3/includes/FakeTitle.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * Fake title class that triggers an error if any members are called |
6 | 6 | */ |
7 | 7 | class FakeTitle { |
8 | | - function error() { wfDebugDieBacktrace( "Attempt to call member function of FakeTitle\n" ); } |
| 8 | + function error() { throw new MWException( "Attempt to call member function of FakeTitle\n" ); } |
9 | 9 | |
10 | 10 | // PHP 5.1 method overload |
11 | 11 | function __call( $name, $args ) { $this->error(); } |
Index: trunk/phase3/includes/SpecialUpload.php |
— | — | @@ -99,7 +99,7 @@ |
100 | 100 | |
101 | 101 | # Check uploading enabled |
102 | 102 | if( !$wgEnableUploads ) { |
103 | | - $wgOut->errorPage( 'uploaddisabled', 'uploaddisabledtext' ); |
| 103 | + $wgOut->showErrorPage( 'uploaddisabled', 'uploaddisabledtext' ); |
104 | 104 | return; |
105 | 105 | } |
106 | 106 | |
— | — | @@ -110,7 +110,7 @@ |
111 | 111 | return; |
112 | 112 | } |
113 | 113 | } else { |
114 | | - $wgOut->errorPage( 'uploadnologin', 'uploadnologintext' ); |
| 114 | + $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' ); |
115 | 115 | return; |
116 | 116 | } |
117 | 117 | |
— | — | @@ -132,7 +132,9 @@ |
133 | 133 | } |
134 | 134 | |
135 | 135 | if( $this->mReUpload ) { |
136 | | - $this->unsaveUploadedFile(); |
| 136 | + if ( !$this->unsaveUploadedFile() ) { |
| 137 | + return; |
| 138 | + } |
137 | 139 | $this->mainUploadForm(); |
138 | 140 | } else if ( 'submit' == $this->mAction || $this->mUpload ) { |
139 | 141 | $this->processUpload(); |
— | — | @@ -343,7 +345,7 @@ |
344 | 346 | } else { |
345 | 347 | // Image::recordUpload() fails if the image went missing, which is |
346 | 348 | // unlikely, hence the lack of a specialised message |
347 | | - $wgOut->fileNotFoundError( $this->mUploadSaveName ); |
| 349 | + $wgOut->showFileNotFoundError( $this->mUploadSaveName ); |
348 | 350 | } |
349 | 351 | } |
350 | 352 | } |
— | — | @@ -376,7 +378,7 @@ |
377 | 379 | wfRestoreWarnings(); |
378 | 380 | |
379 | 381 | if( ! $success ) { |
380 | | - $wgOut->fileRenameError( $this->mSavedFile, |
| 382 | + $wgOut->showFileRenameError( $this->mSavedFile, |
381 | 383 | "${archive}/{$this->mUploadOldVersion}" ); |
382 | 384 | return false; |
383 | 385 | } |
— | — | @@ -393,7 +395,7 @@ |
394 | 396 | wfRestoreWarnings(); |
395 | 397 | |
396 | 398 | if( ! $success ) { |
397 | | - $wgOut->fileCopyError( $tempName, $this->mSavedFile ); |
| 399 | + $wgOut->showFileCopyError( $tempName, $this->mSavedFile ); |
398 | 400 | return false; |
399 | 401 | } else { |
400 | 402 | wfDebug("$fname: wrote tempfile $tempName to ".$this->mSavedFile."\n"); |
— | — | @@ -424,7 +426,7 @@ |
425 | 427 | ? rename( $tempName, $stash ) |
426 | 428 | : move_uploaded_file( $tempName, $stash ); |
427 | 429 | if ( !$success ) { |
428 | | - $wgOut->fileCopyError( $tempName, $stash ); |
| 430 | + $wgOut->showFileCopyError( $tempName, $stash ); |
429 | 431 | return false; |
430 | 432 | } |
431 | 433 | |
— | — | @@ -460,6 +462,7 @@ |
461 | 463 | /** |
462 | 464 | * Remove a temporarily kept file stashed by saveTempUploadedFile(). |
463 | 465 | * @access private |
| 466 | + * @return success |
464 | 467 | */ |
465 | 468 | function unsaveUploadedFile() { |
466 | 469 | global $wgOut; |
— | — | @@ -467,7 +470,10 @@ |
468 | 471 | $success = unlink( $this->mUploadTempName ); |
469 | 472 | wfRestoreWarnings(); |
470 | 473 | if ( ! $success ) { |
471 | | - $wgOut->fileDeleteError( $this->mUploadTempName ); |
| 474 | + $wgOut->showFileDeleteError( $this->mUploadTempName ); |
| 475 | + return false; |
| 476 | + } else { |
| 477 | + return true; |
472 | 478 | } |
473 | 479 | } |
474 | 480 | |
Index: trunk/phase3/includes/WebRequest.php |
— | — | @@ -452,7 +452,7 @@ |
453 | 453 | if( is_array( $data ) ) { |
454 | 454 | $this->data = $data; |
455 | 455 | } else { |
456 | | - wfDebugDieBacktrace( "FauxRequest() got bogus data" ); |
| 456 | + throw new MWException( "FauxRequest() got bogus data" ); |
457 | 457 | } |
458 | 458 | $this->wasPosted = $wasPosted; |
459 | 459 | } |
— | — | @@ -479,11 +479,11 @@ |
480 | 480 | } |
481 | 481 | |
482 | 482 | function getRequestURL() { |
483 | | - wfDebugDieBacktrace( 'FauxRequest::getRequestURL() not implemented' ); |
| 483 | + throw new MWException( 'FauxRequest::getRequestURL() not implemented' ); |
484 | 484 | } |
485 | 485 | |
486 | 486 | function appendQuery( $query ) { |
487 | | - wfDebugDieBacktrace( 'FauxRequest::appendQuery() not implemented' ); |
| 487 | + throw new MWException( 'FauxRequest::appendQuery() not implemented' ); |
488 | 488 | } |
489 | 489 | |
490 | 490 | } |
Index: trunk/phase3/includes/Exception.php |
— | — | @@ -1,172 +1,193 @@ |
2 | | -<?php
|
3 | | -
|
4 | | -class MWException extends Exception
|
5 | | -{
|
6 | | - function useOutputPage() {
|
7 | | - return !empty( $GLOBALS['wgFullyInitialised'] );
|
8 | | - }
|
9 | | -
|
10 | | - function useMessageCache() {
|
11 | | - global $wgLang;
|
12 | | - return is_object( $wgLang );
|
13 | | - }
|
14 | | -
|
15 | | - function msg( $key, $fallback /*[, params...] */ ) {
|
16 | | - $args = array_slice( func_get_args(), 2 );
|
17 | | - if ( $this->useMessageCache() ) {
|
18 | | - return wfMsgReal( $key, $args );
|
19 | | - } else {
|
20 | | - return wfMsgReplaceArgs( $fallback, $args );
|
21 | | - }
|
22 | | - }
|
23 | | -
|
24 | | - function getHTML() {
|
25 | | - return '<p>' . htmlspecialchars( $this->getMessage() ) .
|
26 | | - '</p><p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ) .
|
27 | | - "</p>\n";
|
28 | | - }
|
29 | | -
|
30 | | - function getText() {
|
31 | | - return $this->getMessage() .
|
32 | | - "\nBacktrace:\n" . $this->getTraceAsString() . "\n";
|
33 | | - }
|
34 | | -
|
35 | | - function getPageTitle() {
|
36 | | - if ( $this->useMessageCache() ) {
|
37 | | - return wfMsg( 'internalerror' );
|
38 | | - } else {
|
39 | | - global $wgSitename;
|
40 | | - return "$wgSitename error";
|
41 | | - }
|
42 | | - }
|
43 | | -
|
44 | | - function reportHTML() {
|
45 | | - global $wgOut;
|
46 | | - if ( $this->useOutputPage() ) {
|
47 | | - $wgOut->setPageTitle( $this->getPageTitle() );
|
48 | | - $wgOut->setRobotpolicy( "noindex,nofollow" );
|
49 | | - $wgOut->setArticleRelated( false );
|
50 | | - $wgOut->enableClientCache( false );
|
51 | | - $wgOut->redirect( '' );
|
52 | | - $wgOut->clearHTML();
|
53 | | - $wgOut->addHTML( $this->getHTML() );
|
54 | | - $wgOut->output();
|
55 | | - } else {
|
56 | | - echo $this->htmlHeader();
|
57 | | - echo $this->getHTML();
|
58 | | - echo $this->htmlFooter();
|
59 | | - }
|
60 | | - }
|
61 | | -
|
62 | | - function reportText() {
|
63 | | - echo $this->getText();
|
64 | | - }
|
65 | | -
|
66 | | - function report() {
|
67 | | - global $wgCommandLineMode;
|
68 | | - if ( $wgCommandLineMode ) {
|
69 | | - $this->reportText();
|
70 | | - } else {
|
71 | | - $this->reportHTML();
|
72 | | - }
|
73 | | - }
|
74 | | -
|
75 | | - function htmlHeader() {
|
76 | | - global $wgLogo, $wgSitename, $wgOutputEncoding;
|
77 | | -
|
78 | | - if ( !headers_sent() ) {
|
79 | | - header( 'HTTP/1.0 500 Internal Server Error' );
|
80 | | - header( 'Content-type: text/html; charset='.$wgOutputEncoding );
|
81 | | - /* Don't cache error pages! They cause no end of trouble... */
|
82 | | - header( 'Cache-control: none' );
|
83 | | - header( 'Pragma: nocache' );
|
84 | | - }
|
85 | | - $title = $this->getPageTitle();
|
86 | | - echo "<html>
|
87 | | - <head>
|
88 | | - <title>$title</title>
|
89 | | - </head>
|
90 | | - <body>
|
91 | | - <h1><img src='$wgLogo' style='float:left;margin-right:1em' alt=''>$title</h1>
|
92 | | - ";
|
93 | | - }
|
94 | | -
|
95 | | - function htmlFooter() {
|
96 | | - echo "</body></html>";
|
97 | | - }
|
98 | | -}
|
99 | | -
|
100 | | -/**
|
101 | | - * Exception class which takes an HTML error message, and does not
|
102 | | - * produce a backtrace. Replacement for OutputPage::fatalError().
|
103 | | - */
|
104 | | -class FatalError extends MWException {
|
105 | | - function getHTML() {
|
106 | | - return $this->getMessage();
|
107 | | - }
|
108 | | -
|
109 | | - function getText() {
|
110 | | - return $this->getMessage();
|
111 | | - }
|
112 | | -}
|
113 | | -
|
114 | | -/**
|
115 | | - * Install an exception handler for MediaWiki exception types.
|
116 | | - */
|
117 | | -function wfInstallExceptionHandler() {
|
118 | | - set_exception_handler( 'wfExceptionHandler' );
|
119 | | -}
|
120 | | -
|
121 | | -/**
|
122 | | - * Report an exception to the user
|
123 | | - */
|
124 | | -function wfReportException( Exception $e ) {
|
125 | | - if ( is_a( $e, 'MWException' ) ) {
|
126 | | - try {
|
127 | | - $e->report();
|
128 | | - } catch ( Exception $e2 ) {
|
129 | | - // Exception occurred from within exception handler
|
130 | | - // Show a simpler error message for the original exception,
|
131 | | - // don't try to invoke report()
|
132 | | - $message = "MediaWiki internal error.\n\n" .
|
133 | | - "Original exception: " . $e->__toString() .
|
134 | | - "\n\nException caught inside exception handler: " .
|
135 | | - $e2->__toString() . "\n";
|
136 | | -
|
137 | | - if ( !empty( $GLOBALS['wgCommandLineMode'] ) ) {
|
138 | | - echo $message;
|
139 | | - } else {
|
140 | | - echo nl2br( htmlspecialchars( $message ) ). "\n";
|
141 | | - }
|
142 | | - }
|
143 | | - } else {
|
144 | | - echo $e->__toString();
|
145 | | - }
|
146 | | -}
|
147 | | -
|
148 | | -/**
|
149 | | - * Exception handler which simulates the appropriate catch() handling:
|
150 | | - *
|
151 | | - * try {
|
152 | | - * ...
|
153 | | - * } catch ( MWException $e ) {
|
154 | | - *
|
155 | | - * $e->report();
|
156 | | - * } catch ( Exception $e ) {
|
157 | | - * echo $e->__toString();
|
158 | | - * }
|
159 | | - */
|
160 | | -function wfExceptionHandler( $e ) {
|
161 | | - wfReportException( $e );
|
162 | | -
|
163 | | - // Final cleanup, similar to wfErrorExit()
|
164 | | - try {
|
165 | | - wfProfileClose();
|
166 | | - logProfilingData();
|
167 | | - } catch ( Exception $e ) {}
|
168 | | -
|
169 | | - // Exit value should be nonzero for the benefit of shell jobs
|
170 | | - exit( 1 );
|
171 | | -}
|
172 | | -
|
173 | | -?>
|
| 2 | +<?php |
| 3 | + |
| 4 | +class MWException extends Exception |
| 5 | +{ |
| 6 | + function useOutputPage() { |
| 7 | + return !empty( $GLOBALS['wgFullyInitialised'] ); |
| 8 | + } |
| 9 | + |
| 10 | + function useMessageCache() { |
| 11 | + global $wgLang; |
| 12 | + return is_object( $wgLang ); |
| 13 | + } |
| 14 | + |
| 15 | + function msg( $key, $fallback /*[, params...] */ ) { |
| 16 | + $args = array_slice( func_get_args(), 2 ); |
| 17 | + if ( $this->useMessageCache() ) { |
| 18 | + return wfMsgReal( $key, $args ); |
| 19 | + } else { |
| 20 | + return wfMsgReplaceArgs( $fallback, $args ); |
| 21 | + } |
| 22 | + } |
| 23 | + |
| 24 | + function getHTML() { |
| 25 | + return '<p>' . htmlspecialchars( $this->getMessage() ) . |
| 26 | + '</p><p>Backtrace:</p><p>' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ) . |
| 27 | + "</p>\n"; |
| 28 | + } |
| 29 | + |
| 30 | + function getText() { |
| 31 | + return $this->getMessage() . |
| 32 | + "\nBacktrace:\n" . $this->getTraceAsString() . "\n"; |
| 33 | + } |
| 34 | + |
| 35 | + function getPageTitle() { |
| 36 | + if ( $this->useMessageCache() ) { |
| 37 | + return wfMsg( 'internalerror' ); |
| 38 | + } else { |
| 39 | + global $wgSitename; |
| 40 | + return "$wgSitename error"; |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + function reportHTML() { |
| 45 | + global $wgOut; |
| 46 | + if ( $this->useOutputPage() ) { |
| 47 | + $wgOut->setPageTitle( $this->getPageTitle() ); |
| 48 | + $wgOut->setRobotpolicy( "noindex,nofollow" ); |
| 49 | + $wgOut->setArticleRelated( false ); |
| 50 | + $wgOut->enableClientCache( false ); |
| 51 | + $wgOut->redirect( '' ); |
| 52 | + $wgOut->clearHTML(); |
| 53 | + $wgOut->addHTML( $this->getHTML() ); |
| 54 | + $wgOut->output(); |
| 55 | + } else { |
| 56 | + echo $this->htmlHeader(); |
| 57 | + echo $this->getHTML(); |
| 58 | + echo $this->htmlFooter(); |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | + function reportText() { |
| 63 | + echo $this->getText(); |
| 64 | + } |
| 65 | + |
| 66 | + function report() { |
| 67 | + global $wgCommandLineMode; |
| 68 | + if ( $wgCommandLineMode ) { |
| 69 | + $this->reportText(); |
| 70 | + } else { |
| 71 | + $this->reportHTML(); |
| 72 | + } |
| 73 | + } |
| 74 | + |
| 75 | + function htmlHeader() { |
| 76 | + global $wgLogo, $wgSitename, $wgOutputEncoding; |
| 77 | + |
| 78 | + if ( !headers_sent() ) { |
| 79 | + header( 'HTTP/1.0 500 Internal Server Error' ); |
| 80 | + header( 'Content-type: text/html; charset='.$wgOutputEncoding ); |
| 81 | + /* Don't cache error pages! They cause no end of trouble... */ |
| 82 | + header( 'Cache-control: none' ); |
| 83 | + header( 'Pragma: nocache' ); |
| 84 | + } |
| 85 | + $title = $this->getPageTitle(); |
| 86 | + echo "<html> |
| 87 | + <head> |
| 88 | + <title>$title</title> |
| 89 | + </head> |
| 90 | + <body> |
| 91 | + <h1><img src='$wgLogo' style='float:left;margin-right:1em' alt=''>$title</h1> |
| 92 | + "; |
| 93 | + } |
| 94 | + |
| 95 | + function htmlFooter() { |
| 96 | + echo "</body></html>"; |
| 97 | + } |
| 98 | +} |
| 99 | + |
| 100 | +/** |
| 101 | + * Exception class which takes an HTML error message, and does not |
| 102 | + * produce a backtrace. Replacement for OutputPage::fatalError(). |
| 103 | + */ |
| 104 | +class FatalError extends MWException { |
| 105 | + function getHTML() { |
| 106 | + return $this->getMessage(); |
| 107 | + } |
| 108 | + |
| 109 | + function getText() { |
| 110 | + return $this->getMessage(); |
| 111 | + } |
| 112 | +} |
| 113 | + |
| 114 | +class ErrorPageError extends MWException { |
| 115 | + public $title, $msg; |
| 116 | + |
| 117 | + /** |
| 118 | + * Note: these arguments are keys into wfMsg(), not text! |
| 119 | + */ |
| 120 | + function __construct( $title, $msg ) { |
| 121 | + $this->title = $title; |
| 122 | + $this->msg = $msg; |
| 123 | + parent::__construct( wfMsg( $msg ) ); |
| 124 | + } |
| 125 | + |
| 126 | + function report() { |
| 127 | + global $wgOut; |
| 128 | + $wgOut->showErrorPage( $this->title, $this->msg ); |
| 129 | + $wgOut->output(); |
| 130 | + } |
| 131 | +} |
| 132 | + |
| 133 | +/** |
| 134 | + * Install an exception handler for MediaWiki exception types. |
| 135 | + */ |
| 136 | +function wfInstallExceptionHandler() { |
| 137 | + set_exception_handler( 'wfExceptionHandler' ); |
| 138 | +} |
| 139 | + |
| 140 | +/** |
| 141 | + * Report an exception to the user |
| 142 | + */ |
| 143 | +function wfReportException( Exception $e ) { |
| 144 | + if ( is_a( $e, 'MWException' ) ) { |
| 145 | + try { |
| 146 | + $e->report(); |
| 147 | + } catch ( Exception $e2 ) { |
| 148 | + // Exception occurred from within exception handler |
| 149 | + // Show a simpler error message for the original exception, |
| 150 | + // don't try to invoke report() |
| 151 | + $message = "MediaWiki internal error.\n\n" . |
| 152 | + "Original exception: " . $e->__toString() . |
| 153 | + "\n\nException caught inside exception handler: " . |
| 154 | + $e2->__toString() . "\n"; |
| 155 | + |
| 156 | + if ( !empty( $GLOBALS['wgCommandLineMode'] ) ) { |
| 157 | + echo $message; |
| 158 | + } else { |
| 159 | + echo nl2br( htmlspecialchars( $message ) ). "\n"; |
| 160 | + } |
| 161 | + } |
| 162 | + } else { |
| 163 | + echo $e->__toString(); |
| 164 | + } |
| 165 | +} |
| 166 | + |
| 167 | +/** |
| 168 | + * Exception handler which simulates the appropriate catch() handling: |
| 169 | + * |
| 170 | + * try { |
| 171 | + * ... |
| 172 | + * } catch ( MWException $e ) { |
| 173 | + * $e->report(); |
| 174 | + * } catch ( Exception $e ) { |
| 175 | + * echo $e->__toString(); |
| 176 | + * } |
| 177 | + */ |
| 178 | +function wfExceptionHandler( $e ) { |
| 179 | + global $wgFullyInitialised; |
| 180 | + wfReportException( $e ); |
| 181 | + |
| 182 | + // Final cleanup, similar to wfErrorExit() |
| 183 | + if ( $wgFullyInitialised ) { |
| 184 | + try { |
| 185 | + wfProfileClose(); |
| 186 | + logProfilingData(); // uses $wgRequest, hence the $wgFullyInitialised condition |
| 187 | + } catch ( Exception $e ) {} |
| 188 | + } |
| 189 | + |
| 190 | + // Exit value should be nonzero for the benefit of shell jobs |
| 191 | + exit( 1 ); |
| 192 | +} |
| 193 | + |
| 194 | +?> |
Property changes on: trunk/phase3/includes/Exception.php |
___________________________________________________________________ |
Added: svn:eol-style |
174 | 195 | + native |
Index: trunk/phase3/includes/SpecialUnlockdb.php |
— | — | @@ -84,7 +84,7 @@ |
85 | 85 | return; |
86 | 86 | } |
87 | 87 | if ( @! unlink( $wgReadOnlyFile ) ) { |
88 | | - $wgOut->fileDeleteError( $wgReadOnlyFile ); |
| 88 | + $wgOut->showFileDeleteError( $wgReadOnlyFile ); |
89 | 89 | return; |
90 | 90 | } |
91 | 91 | $titleObj = Title::makeTitle( NS_SPECIAL, "Unlockdb" ); |
Index: trunk/phase3/includes/Skin.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | if ( ! defined( 'MEDIAWIKI' ) ) |
4 | | - die( -1 ); |
| 4 | + die( 1 ); |
5 | 5 | |
6 | 6 | /** |
7 | 7 | * |
Index: trunk/phase3/includes/ProtectionForm.php |
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | if( is_null( $this->mTitle ) || |
67 | 67 | !$this->mTitle->exists() || |
68 | 68 | $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
69 | | - $wgOut->fatalError( wfMsg( 'badarticleerror' ) ); |
| 69 | + $wgOut->showFatalError( wfMsg( 'badarticleerror' ) ); |
70 | 70 | return; |
71 | 71 | } |
72 | 72 | |
— | — | @@ -98,13 +98,12 @@ |
99 | 99 | |
100 | 100 | $token = $wgRequest->getVal( 'wpEditToken' ); |
101 | 101 | if( !$wgUser->matchEditToken( $token ) ) { |
102 | | - $wgOut->fatalError( wfMsg( 'sessionfailure' ) ); |
103 | | - return false; |
| 102 | + throw new FatalError( wfMsg( 'sessionfailure' ) ); |
104 | 103 | } |
105 | 104 | |
106 | 105 | $ok = $this->mArticle->updateRestrictions( $this->mRestrictions, $this->mReason ); |
107 | 106 | if( !$ok ) { |
108 | | - $wgOut->fatalError( "Unknown error at restriction save time." ); |
| 107 | + throw new FatalError( "Unknown error at restriction save time." ); |
109 | 108 | } |
110 | 109 | return $ok; |
111 | 110 | } |
Index: trunk/phase3/includes/Hooks.php |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | $fname = 'wfRunHooks'; |
36 | 36 | |
37 | 37 | if (!is_array($wgHooks)) { |
38 | | - wfDebugDieBacktrace("Global hooks array is not an array!\n"); |
| 38 | + throw new MWException("Global hooks array is not an array!\n"); |
39 | 39 | return false; |
40 | 40 | } |
41 | 41 | |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | } |
45 | 45 | |
46 | 46 | if (!is_array($wgHooks[$event])) { |
47 | | - wfDebugDieBacktrace("Hooks array for event '$event' is not an array!\n"); |
| 47 | + throw new MWException("Hooks array for event '$event' is not an array!\n"); |
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | |
— | — | @@ -62,7 +62,7 @@ |
63 | 63 | |
64 | 64 | if (is_array($hook)) { |
65 | 65 | if (count($hook) < 1) { |
66 | | - wfDebugDieBacktrace("Empty array in hooks for " . $event . "\n"); |
| 66 | + throw new MWException("Empty array in hooks for " . $event . "\n"); |
67 | 67 | } else if (is_object($hook[0])) { |
68 | 68 | $object =& $wgHooks[$event][$index][0]; |
69 | 69 | if (count($hook) < 2) { |
— | — | @@ -82,7 +82,7 @@ |
83 | 83 | } |
84 | 84 | } else { |
85 | 85 | var_dump( $wgHooks ); |
86 | | - wfDebugDieBacktrace("Unknown datatype in hooks for " . $event . "\n"); |
| 86 | + throw new MWException("Unknown datatype in hooks for " . $event . "\n"); |
87 | 87 | } |
88 | 88 | } else if (is_string($hook)) { # functions look like strings, too |
89 | 89 | $func = $hook; |
— | — | @@ -90,7 +90,7 @@ |
91 | 91 | $object =& $wgHooks[$event][$index]; |
92 | 92 | $method = "on" . $event; |
93 | 93 | } else { |
94 | | - wfDebugDieBacktrace("Unknown datatype in hooks for " . $event . "\n"); |
| 94 | + throw new MWException("Unknown datatype in hooks for " . $event . "\n"); |
95 | 95 | } |
96 | 96 | |
97 | 97 | /* We put the first data element on, if needed. */ |
— | — | @@ -119,7 +119,7 @@ |
120 | 120 | |
121 | 121 | if (is_string($retval)) { |
122 | 122 | global $wgOut; |
123 | | - $wgOut->fatalError($retval); |
| 123 | + $wgOut->showFatalError($retval); |
124 | 124 | return false; |
125 | 125 | } else if (!$retval) { |
126 | 126 | return false; |
Index: trunk/phase3/includes/ImageGallery.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | if ( ! defined( 'MEDIAWIKI' ) ) |
4 | | - die( -1 ); |
| 4 | + die( 1 ); |
5 | 5 | |
6 | 6 | /** |
7 | 7 | * @package MediaWiki |
Index: trunk/phase3/includes/SpecialPreferences.php |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | global $wgUser, $wgOut; |
106 | 106 | |
107 | 107 | if ( $wgUser->isAnon() ) { |
108 | | - $wgOut->errorpage( 'prefsnologin', 'prefsnologintext' ); |
| 108 | + $wgOut->showErrorPage( 'prefsnologin', 'prefsnologintext' ); |
109 | 109 | return; |
110 | 110 | } |
111 | 111 | if ( wfReadOnly() ) { |
Index: trunk/phase3/includes/BagOStuff.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | * @package MediaWiki |
37 | 37 | * @abstract |
38 | 38 | */ |
39 | | -class BagOStuff { |
| 39 | +abstract class BagOStuff { |
40 | 40 | var $debugmode; |
41 | 41 | |
42 | 42 | function BagOStuff() { |
— | — | @@ -212,7 +212,7 @@ |
213 | 213 | * @abstract |
214 | 214 | * @package MediaWiki |
215 | 215 | */ |
216 | | -class SqlBagOStuff extends BagOStuff { |
| 216 | +abstract class SqlBagOStuff extends BagOStuff { |
217 | 217 | var $table; |
218 | 218 | var $lastexpireall = 0; |
219 | 219 | |
— | — | @@ -292,16 +292,9 @@ |
293 | 293 | function _blobencode($str) { |
294 | 294 | return $str; |
295 | 295 | } |
296 | | - function _doinsert($table, $vals) { |
297 | | - wfDie( 'abstract function SqlBagOStuff::_doinsert() must be defined' ); |
298 | | - } |
299 | | - function _doquery($sql) { |
300 | | - wfDie( 'abstract function SqlBagOStuff::_doquery() must be defined' ); |
301 | | - } |
302 | 296 | |
303 | | - function _fetchrow($res) { |
304 | | - wfDie( 'abstract function SqlBagOStuff::_fetchrow() must be defined' ); |
305 | | - } |
| 297 | + abstract function _doinsert($table, $vals); |
| 298 | + abstract function _doquery($sql); |
306 | 299 | |
307 | 300 | function _freeresult($result) { |
308 | 301 | /* stub */ |
— | — | @@ -313,14 +306,9 @@ |
314 | 307 | return 'unknown error'; |
315 | 308 | } |
316 | 309 | |
317 | | - function _maxdatetime() { |
318 | | - wfDie( 'abstract function SqlBagOStuff::_maxdatetime() must be defined' ); |
319 | | - } |
| 310 | + abstract function _maxdatetime(); |
| 311 | + abstract function _fromunixtime($ts); |
320 | 312 | |
321 | | - function _fromunixtime() { |
322 | | - wfDie( 'abstract function SqlBagOStuff::_fromunixtime() must be defined' ); |
323 | | - } |
324 | | - |
325 | 313 | function garbageCollect() { |
326 | 314 | /* Ignore 99% of requests */ |
327 | 315 | if ( !mt_rand( 0, 100 ) ) { |
— | — | @@ -427,7 +415,7 @@ |
428 | 416 | /* This is actually a hack, we should be able |
429 | 417 | to use Language classes here... or not */ |
430 | 418 | if (!$dbw) |
431 | | - wfDie("Could not connect to database"); |
| 419 | + throw new MWException("Could not connect to database"); |
432 | 420 | $this->table = $dbw->tableName( $this->table ); |
433 | 421 | $this->tableInitialised = true; |
434 | 422 | } |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -109,7 +109,7 @@ |
110 | 110 | $fname = 'Title::newFromText'; |
111 | 111 | |
112 | 112 | if( is_object( $text ) ) { |
113 | | - wfDebugDieBacktrace( 'Title::newFromText given an object' ); |
| 113 | + throw new MWException( 'Title::newFromText given an object' ); |
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
Index: trunk/phase3/includes/Image.php |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | |
77 | 77 | function Image( $title ) { |
78 | 78 | if( !is_object( $title ) ) { |
79 | | - wfDebugDieBacktrace( 'Image constructor given bogus title.' ); |
| 79 | + throw new MWException( 'Image constructor given bogus title.' ); |
80 | 80 | } |
81 | 81 | $this->title =& $title; |
82 | 82 | $this->name = $title->getDBkey(); |
— | — | @@ -994,7 +994,7 @@ |
995 | 995 | unlink( $thumbPath ); |
996 | 996 | } else { |
997 | 997 | // This should have been dealt with already |
998 | | - wfDebugDieBacktrace( "Directory where image should be: $thumbPath" ); |
| 998 | + throw new MWException( "Directory where image should be: $thumbPath" ); |
999 | 999 | } |
1000 | 1000 | } |
1001 | 1001 | // Rename the old image into the new location |
— | — | @@ -1270,16 +1270,24 @@ |
1271 | 1271 | } |
1272 | 1272 | # img_name must be unique |
1273 | 1273 | if ( !$db->indexUnique( 'image', 'img_name' ) && !$db->indexExists('image','PRIMARY') ) { |
1274 | | - wfDebugDieBacktrace( 'Database schema not up to date, please run maintenance/archives/patch-image_name_unique.sql' ); |
| 1274 | + throw new MWException( 'Database schema not up to date, please run maintenance/archives/patch-image_name_unique.sql' ); |
1275 | 1275 | } |
1276 | 1276 | |
1277 | | - #new fields must exist |
| 1277 | + # new fields must exist |
| 1278 | + # |
| 1279 | + # Not really, there's hundreds of checks like this that we could do and they're all pointless, because |
| 1280 | + # if the fields are missing, the database will loudly report a query error, the first time you try to do |
| 1281 | + # something. The only reason I put the above schema check in was because the absence of that particular |
| 1282 | + # index would lead to an annoying subtle bug. No error message, just some very odd behaviour on duplicate |
| 1283 | + # uploads. -- TS |
| 1284 | + /* |
1278 | 1285 | if ( !$db->fieldExists( 'image', 'img_media_type' ) |
1279 | 1286 | || !$db->fieldExists( 'image', 'img_metadata' ) |
1280 | 1287 | || !$db->fieldExists( 'image', 'img_width' ) ) { |
1281 | 1288 | |
1282 | | - wfDebugDieBacktrace( 'Database schema not up to date, please run maintenance/update.php' ); |
1283 | | - } |
| 1289 | + throw new MWException( 'Database schema not up to date, please run maintenance/update.php' ); |
| 1290 | + } |
| 1291 | + */ |
1284 | 1292 | } |
1285 | 1293 | |
1286 | 1294 | /** |
Index: trunk/phase3/includes/Linker.php |
— | — | @@ -194,7 +194,7 @@ |
195 | 195 | |
196 | 196 | # Fail gracefully |
197 | 197 | if ( ! is_object($nt) ) { |
198 | | - # wfDebugDieBacktrace(); |
| 198 | + # throw new MWException(); |
199 | 199 | wfProfileOut( $fname ); |
200 | 200 | return "<!-- ERROR -->{$prefix}{$text}{$trail}"; |
201 | 201 | } |
— | — | @@ -343,7 +343,7 @@ |
344 | 344 | function makeBrokenLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { |
345 | 345 | # Fail gracefully |
346 | 346 | if ( ! isset($nt) ) { |
347 | | - # wfDebugDieBacktrace(); |
| 347 | + # throw new MWException(); |
348 | 348 | return "<!-- ERROR -->{$prefix}{$text}{$trail}"; |
349 | 349 | } |
350 | 350 | |
— | — | @@ -658,7 +658,7 @@ |
659 | 659 | function makeBrokenImageLinkObj( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { |
660 | 660 | # Fail gracefully |
661 | 661 | if ( ! isset($nt) ) { |
662 | | - # wfDebugDieBacktrace(); |
| 662 | + # throw new MWException(); |
663 | 663 | return "<!-- ERROR -->{$prefix}{$text}{$trail}"; |
664 | 664 | } |
665 | 665 | |