Index: branches/wmf/1.18wmf1/includes/specials/SpecialUserlogin.php |
— | — | @@ -907,7 +907,7 @@ |
908 | 908 | 'cantcreateaccount-text', |
909 | 909 | $block->getTarget(), |
910 | 910 | $block_reason, |
911 | | - $block->getBlocker()->getName() |
| 911 | + $block->getByName() |
912 | 912 | ); |
913 | 913 | |
914 | 914 | $wgOut->returnToMain( false ); |
Index: branches/wmf/1.18wmf1/includes/Block.php |
— | — | @@ -59,7 +59,7 @@ |
60 | 60 | */ |
61 | 61 | function __construct( $address = '', $user = 0, $by = 0, $reason = '', |
62 | 62 | $timestamp = 0, $auto = 0, $expiry = '', $anonOnly = 0, $createAccount = 0, $enableAutoblock = 0, |
63 | | - $hideName = 0, $blockEmail = 0, $allowUsertalk = 0 ) |
| 63 | + $hideName = 0, $blockEmail = 0, $allowUsertalk = 0, $byText = '' ) |
64 | 64 | { |
65 | 65 | if( $timestamp === 0 ){ |
66 | 66 | $timestamp = wfTimestampNow(); |
— | — | @@ -71,7 +71,11 @@ |
72 | 72 | } |
73 | 73 | |
74 | 74 | $this->setTarget( $address ); |
75 | | - $this->setBlocker( User::newFromID( $by ) ); |
| 75 | + if ( $by ) { // local user |
| 76 | + $this->setBlocker( User::newFromID( $by ) ); |
| 77 | + } else { // foreign user |
| 78 | + $this->setBlocker( $byText ); |
| 79 | + } |
76 | 80 | $this->mReason = $reason; |
77 | 81 | $this->mTimestamp = wfTimestamp( TS_MW, $timestamp ); |
78 | 82 | $this->mAuto = $auto; |
— | — | @@ -345,7 +349,11 @@ |
346 | 350 | */ |
347 | 351 | protected function initFromRow( $row ) { |
348 | 352 | $this->setTarget( $row->ipb_address ); |
349 | | - $this->setBlocker( User::newFromId( $row->ipb_by ) ); |
| 353 | + if ( $row->ipb_by ) { // local user |
| 354 | + $this->setBlocker( User::newFromID( $row->ipb_by ) ); |
| 355 | + } else { // foreign user |
| 356 | + $this->setBlocker( $row->ipb_by_text ); |
| 357 | + } |
350 | 358 | |
351 | 359 | $this->mReason = $row->ipb_reason; |
352 | 360 | $this->mTimestamp = wfTimestamp( TS_MW, $row->ipb_timestamp ); |
— | — | @@ -471,8 +479,8 @@ |
472 | 480 | $a = array( |
473 | 481 | 'ipb_address' => (string)$this->target, |
474 | 482 | 'ipb_user' => $this->target instanceof User ? $this->target->getID() : 0, |
475 | | - 'ipb_by' => $this->getBlocker()->getId(), |
476 | | - 'ipb_by_text' => $this->getBlocker()->getName(), |
| 483 | + 'ipb_by' => $this->getBy(), |
| 484 | + 'ipb_by_text' => $this->getByName(), |
477 | 485 | 'ipb_reason' => $this->mReason, |
478 | 486 | 'ipb_timestamp' => $db->timestamp( $this->mTimestamp ), |
479 | 487 | 'ipb_auto' => $this->mAuto, |
— | — | @@ -761,11 +769,12 @@ |
762 | 770 | /** |
763 | 771 | * Get the user id of the blocking sysop |
764 | 772 | * |
765 | | - * @return Integer |
| 773 | + * @return Integer (0 for foreign users) |
766 | 774 | */ |
767 | 775 | public function getBy() { |
768 | | - return $this->getBlocker() instanceof User |
769 | | - ? $this->getBlocker()->getId() |
| 776 | + $blocker = $this->getBlocker(); |
| 777 | + return ( $blocker instanceof User ) |
| 778 | + ? $blocker->getId() |
770 | 779 | : 0; |
771 | 780 | } |
772 | 781 | |
— | — | @@ -775,9 +784,10 @@ |
776 | 785 | * @return String |
777 | 786 | */ |
778 | 787 | public function getByName() { |
779 | | - return $this->getBlocker() instanceof User |
780 | | - ? $this->getBlocker()->getName() |
781 | | - : null; |
| 788 | + $blocker = $this->getBlocker(); |
| 789 | + return ( $blocker instanceof User ) |
| 790 | + ? $blocker->getName() |
| 791 | + : (string)$blocker; // username |
782 | 792 | } |
783 | 793 | |
784 | 794 | /** |
— | — | @@ -927,7 +937,8 @@ |
928 | 938 | */ |
929 | 939 | public static function purgeExpired() { |
930 | 940 | $dbw = wfGetDB( DB_MASTER ); |
931 | | - $dbw->delete( 'ipblocks', array( 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), __METHOD__ ); |
| 941 | + $dbw->delete( 'ipblocks', |
| 942 | + array( 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), __METHOD__ ); |
932 | 943 | } |
933 | 944 | |
934 | 945 | /** |
— | — | @@ -1136,7 +1147,7 @@ |
1137 | 1148 | |
1138 | 1149 | /** |
1139 | 1150 | * Get the user who implemented this block |
1140 | | - * @return User |
| 1151 | + * @return User|string Local User object or string for a foreign user |
1141 | 1152 | */ |
1142 | 1153 | public function getBlocker(){ |
1143 | 1154 | return $this->blocker; |
— | — | @@ -1144,9 +1155,9 @@ |
1145 | 1156 | |
1146 | 1157 | /** |
1147 | 1158 | * Set the user who implemented (or will implement) this block |
1148 | | - * @param $user User |
| 1159 | + * @param $user User|string Local User object or username string for foriegn users |
1149 | 1160 | */ |
1150 | | - public function setBlocker( User $user ){ |
| 1161 | + public function setBlocker( $user ){ |
1151 | 1162 | $this->blocker = $user; |
1152 | 1163 | } |
1153 | 1164 | } |
Index: branches/wmf/1.18wmf1/includes/Exception.php |
— | — | @@ -337,8 +337,13 @@ |
338 | 338 | public function __construct( Block $block ){ |
339 | 339 | global $wgLang; |
340 | 340 | |
341 | | - $blockerUserpage = $block->getBlocker()->getUserPage(); |
342 | | - $link = "[[{$blockerUserpage->getPrefixedText()}|{$blockerUserpage->getText()}]]"; |
| 341 | + $blocker = $block->getBlocker(); |
| 342 | + if ( $blocker instanceof User ) { // local user |
| 343 | + $blockerUserpage = $block->getBlocker()->getUserPage(); |
| 344 | + $link = "[[{$blockerUserpage->getPrefixedText()}|{$blockerUserpage->getText()}]]"; |
| 345 | + } else { // foreign user |
| 346 | + $link = $blocker; |
| 347 | + } |
343 | 348 | |
344 | 349 | $reason = $block->mReason; |
345 | 350 | if( $reason == '' ) { |
— | — | @@ -356,7 +361,7 @@ |
357 | 362 | $link, |
358 | 363 | $reason, |
359 | 364 | wfGetIP(), |
360 | | - $block->getBlocker()->getName(), |
| 365 | + $block->getByName(), |
361 | 366 | $block->getId(), |
362 | 367 | $wgLang->formatExpiry( $block->mExpiry ), |
363 | 368 | $intended, |