r83855 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83854‎ | r83855 | r83856 >
Date:21:33, 13 March 2011
Author:happy-melon
Status:ok (Comments)
Tags:
Comment:
Further massive rewrite of the blocking frontend: spin out unblocking into a new SpecialUnblock.php. This leaves IPBlockList as, astonishingly enough, a list of blocks... :D
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/Block.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/LogEventsList.php (modified) (history)
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUnblock.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialBlock.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialIpblocklist.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUnblock.php (added) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -2080,6 +2080,7 @@
20812081 'unblockiptext',
20822082 'ipusubmit',
20832083 'unblocked',
 2084+ 'unblocked-range',
20842085 'unblocked-id',
20852086 'ipblocklist',
20862087 'ipblocklist-legend',
@@ -2127,6 +2128,7 @@
21282129 'ipb_already_blocked',
21292130 'ipb-needreblock',
21302131 'ipb-otherblocks-header',
 2132+ 'unblock-hideuser',
21312133 'ipb_cant_unblock',
21322134 'ipb_blocked_as_range',
21332135 'ip_range_invalid',
Index: trunk/phase3/includes/LogEventsList.php
@@ -424,13 +424,10 @@
425425 } else if( self::typeAction( $row, array( 'block', 'suppress' ), array( 'block', 'reblock' ), 'block' ) ) {
426426 $revert = '(' .
427427 $this->skin->link(
428 - SpecialPage::getTitleFor( 'Ipblocklist' ),
 428+ SpecialPage::getTitleFor( 'Unblock', $row->log_title ),
429429 $this->message['unblocklink'],
430430 array(),
431 - array(
432 - 'action' => 'unblock',
433 - 'ip' => $row->log_title
434 - ),
 431+ array(),
435432 'known'
436433 ) .
437434 $this->message['pipe-separator'] .
Index: trunk/phase3/includes/api/ApiUnblock.php
@@ -72,17 +72,19 @@
7373 }
7474 }
7575
76 - $id = $params['id'];
77 - $user = $params['user'];
78 - $reason = ( is_null( $params['reason'] ) ? '' : $params['reason'] );
79 - $retval = IPUnblockForm::doUnblock( $id, $user, $reason, $range );
80 - if ( $retval ) {
81 - $this->dieUsageMsg( $retval );
 76+ $data = array(
 77+ 'Target' => is_null( $params['id'] ) ? $params['user'] : "#{$params['id']}",
 78+ 'Reason' => is_null( $params['reason'] ) ? '' : $params['reason']
 79+ );
 80+ $block = Block::newFromTarget( $data['Target'] );
 81+ $retval = SpecialUnblock::processUnblock( $data );
 82+ if ( $retval !== true ) {
 83+ $this->dieUsageMsg( $retval[0] );
8284 }
8385
84 - $res['id'] = intval( $id );
85 - $res['user'] = $user;
86 - $res['reason'] = $reason;
 86+ $res['id'] = $block->mId;
 87+ $res['user'] = $block->getType() == Block::TYPE_AUTO ? '' : $block->getTarget();
 88+ $res['reason'] = $params['reason'];
8789 $this->getResult()->addValue( null, $this->getModuleName(), $res );
8890 }
8991
Index: trunk/phase3/includes/AutoLoader.php
@@ -674,6 +674,7 @@
675675 'SpecialSpecialpages' => 'includes/specials/SpecialSpecialpages.php',
676676 'SpecialStatistics' => 'includes/specials/SpecialStatistics.php',
677677 'SpecialTags' => 'includes/specials/SpecialTags.php',
 678+ 'SpecialUnblock' => 'includes/specials/SpecialUnblock.php',
678679 'SpecialUnlockdb' => 'includes/specials/SpecialUnlockdb.php',
679680 'SpecialUpload' => 'includes/specials/SpecialUpload.php',
680681 'SpecialUserlogout' => 'includes/specials/SpecialUserlogout.php',
Index: trunk/phase3/includes/DefaultSettings.php
@@ -4948,6 +4948,7 @@
49494949 'Listbots' => 'users',
49504950 'Userrights' => 'users',
49514951 'Block' => 'users',
 4952+ 'Unblock' => 'users',
49524953 'Preferences' => 'users',
49534954 'Resetpass' => 'users',
49544955 'DeletedContributions' => 'users',
Index: trunk/phase3/includes/specials/SpecialUnblock.php
@@ -0,0 +1,200 @@
 2+<?php
 3+/**
 4+ * This program is free software; you can redistribute it and/or modify
 5+ * it under the terms of the GNU General Public License as published by
 6+ * the Free Software Foundation; either version 2 of the License, or
 7+ * (at your option) any later version.
 8+ *
 9+ * This program is distributed in the hope that it will be useful,
 10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 12+ * GNU General Public License for more details.
 13+ *
 14+ * You should have received a copy of the GNU General Public License along
 15+ * with this program; if not, write to the Free Software Foundation, Inc.,
 16+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 17+ * http://www.gnu.org/copyleft/gpl.html
 18+ *
 19+ * @file
 20+ * @ingroup SpecialPage
 21+ */
 22+
 23+/**
 24+ * A special page for unblocking users
 25+ *
 26+ * @ingroup SpecialPage
 27+ */
 28+class SpecialUnblock extends SpecialPage {
 29+
 30+ protected $target;
 31+ protected $type;
 32+ protected $block;
 33+
 34+ public function __construct(){
 35+ parent::__construct( 'Unblock', 'block' );
 36+ }
 37+
 38+ public function execute( $par ){
 39+ global $wgUser, $wgOut, $wgRequest;
 40+
 41+ # Check permissions
 42+ if( !$wgUser->isAllowed( 'block' ) ) {
 43+ $wgOut->permissionRequired( 'block' );
 44+ return;
 45+ }
 46+ # Check for database lock
 47+ if( wfReadOnly() ) {
 48+ $wgOut->readOnlyPage();
 49+ return;
 50+ }
 51+
 52+ list( $this->target, $this->type ) = SpecialBlock::getTargetAndType( $par, $wgRequest );
 53+ $this->block = Block::newFromTargetAndType( $this->target, $this->type );
 54+
 55+ # bug 15810: blocked admins should have limited access here. This won't allow sysops
 56+ # to remove autoblocks on themselves, but they should have ipblock-exempt anyway
 57+ $status = SpecialBlock::checkUnblockSelf( $this->target );
 58+ if ( $status !== true ) {
 59+ throw new ErrorPageError( 'badaccess', $status );
 60+ }
 61+
 62+ $wgOut->setPageTitle( wfMsg( 'unblockip' ) );
 63+ $wgOut->addModules( 'mediawiki.special' );
 64+
 65+ $form = new HTMLForm( $this->getFields() );
 66+ $form->setTitle( $this->getTitle() );
 67+ $form->setWrapperLegend( wfMsg( 'unblockip' ) );
 68+ $form->setSubmitCallback( array( __CLASS__, 'processUnblock' ) );
 69+ $form->setSubmitText( wfMsg( 'ipusubmit' ) );
 70+ $form->addPreText( wfMsgExt( 'unblockiptext', 'parse' ) );
 71+
 72+ if( $form->show() ){
 73+ switch( $this->type ){
 74+ case Block::TYPE_USER:
 75+ case Block::TYPE_IP:
 76+ $wgOut->addWikiMsg( 'unblocked', $this->target );
 77+ break;
 78+ case Block::TYPE_RANGE:
 79+ $wgOut->addWikiMsg( 'unblocked-range', $this->target );
 80+ break;
 81+ case Block::TYPE_ID:
 82+ case Block::TYPE_AUTO:
 83+ $wgOut->addWikiMsg( 'unblocked-id', $this->target );
 84+ break;
 85+ }
 86+ }
 87+ }
 88+
 89+ protected function getFields(){
 90+ $fields = array(
 91+ 'Target' => array(
 92+ 'type' => 'text',
 93+ 'label-message' => 'ipadressorusername',
 94+ 'tabindex' => '1',
 95+ 'size' => '45',
 96+ 'required' => true,
 97+ ),
 98+ 'Name' => array(
 99+ 'type' => 'info',
 100+ 'label-message' => 'ipadressorusername',
 101+ ),
 102+ 'Reason' => array(
 103+ 'type' => 'text',
 104+ 'label-message' => 'ipbreason',
 105+ )
 106+ );
 107+
 108+ if( $this->block instanceof Block ){
 109+ list( $target, $type ) = $this->block->getTargetAndType();
 110+
 111+ # Autoblocks are logged as "autoblock #123 because the IP was recently used by
 112+ # User:Foo, and we've just got any block, auto or not, that applies to a target
 113+ # the user has specified. Someone could be fishing to connect IPs to autoblocks,
 114+ # so don't show any distinction between unblocked IPs and autoblocked IPs
 115+ if( $type == Block::TYPE_AUTO && $this->type == Block::TYPE_IP ){
 116+ $fields['Target']['default'] = $this->target;
 117+ unset( $fields['Name'] );
 118+
 119+ } else {
 120+ $fields['Target']['default'] = $target;
 121+ $fields['Target']['type'] = 'hidden';
 122+ switch( $type ){
 123+ case Block::TYPE_USER:
 124+ case Block::TYPE_IP:
 125+ global $wgUser;
 126+ $skin = $wgUser->getSkin();
 127+ $fields['Name']['default'] = $skin->link(
 128+ $target->getUserPage(),
 129+ $target->getName()
 130+ );
 131+ $fields['Name']['raw'] = true;
 132+ break;
 133+
 134+ case Block::TYPE_RANGE:
 135+ $fields['Name']['default'] = $target;
 136+ break;
 137+
 138+ case Block::TYPE_AUTO:
 139+ $fields['Name']['default'] = $this->block->getRedactedName();
 140+ $fields['Name']['raw'] = true;
 141+ # Don't expose the real target of the autoblock
 142+ $fields['Target']['default'] = "#{$this->target}";
 143+ break;
 144+ }
 145+ }
 146+
 147+ } else {
 148+ $fields['Target']['default'] = $this->target;
 149+ unset( $fields['Name'] );
 150+ }
 151+ return $fields;
 152+ }
 153+
 154+ /**
 155+ * Process the form
 156+ * @return Array( Array(message key, parameters) ) on failure, True on success
 157+ */
 158+ public static function processUnblock( array $data ){
 159+ global $wgUser;
 160+
 161+ $target = $data['Target'];
 162+ $block = Block::newFromTarget( $data['Target'] );
 163+
 164+ if( !$block instanceof Block ){
 165+ return array( array( 'ipb_cant_unblock', $target ) );
 166+ }
 167+
 168+ # If the specified IP is a single address, and the block is a range block, don't
 169+ # unblock the whole range.
 170+ list( $target, $type ) = SpecialBlock::getTargetAndType( $target );
 171+ if( $block->getType() == Block::TYPE_RANGE && $type == Block::TYPE_IP ) {
 172+ $range = $block->mAddress;
 173+ return array( array( 'ipb_blocked_as_range', $target, $range ) );
 174+ }
 175+
 176+ # If the name was hidden and the blocking user cannot hide
 177+ # names, then don't allow any block removals...
 178+ if( !$wgUser->isAllowed( 'hideuser' ) && $block->mHideName ) {
 179+ return array( 'unblock-hideuser' );
 180+ }
 181+
 182+ # Delete block
 183+ if ( !$block->delete() ) {
 184+ return array( 'ipb_cant_unblock', htmlspecialchars( $block->getTarget() ) );
 185+ }
 186+
 187+ # Unset _deleted fields as needed
 188+ if( $block->mHideName ) {
 189+ RevisionDeleteUser::unsuppressUserName( $block->mAddress, $block->mUser );
 190+ }
 191+
 192+ # Make log entry
 193+ $log = new LogPage( 'block' );
 194+ $page = $block->getTarget() instanceof User
 195+ ? $block->getTarget()->getUserpage()
 196+ : Title::makeTitle( NS_USER, $block->getTarget() );
 197+ $log->addEntry( 'unblock', $page, $data['Reason'] );
 198+
 199+ return true;
 200+ }
 201+}
\ No newline at end of file
Property changes on: trunk/phase3/includes/specials/SpecialUnblock.php
___________________________________________________________________
Added: svn:eol-style
1202 + native
Index: trunk/phase3/includes/specials/SpecialIpblocklist.php
@@ -28,7 +28,7 @@
2929 * @ingroup SpecialPage
3030 */
3131 class IPUnblockForm extends SpecialPage {
32 - var $ip, $reason, $id;
 32+ var $ip;
3333 var $hideuserblocks, $hidetempblocks, $hideaddressblocks;
3434
3535 function __construct() {
@@ -48,223 +48,23 @@
4949
5050 $ip = $wgRequest->getVal( 'ip', $ip );
5151 $this->ip = trim( $wgRequest->getVal( 'wpUnblockAddress', $ip ) );
52 - $this->id = $wgRequest->getVal( 'id' );
53 - $this->reason = $wgRequest->getText( 'wpUnblockReason' );
5452 $this->hideuserblocks = $wgRequest->getBool( 'hideuserblocks' );
5553 $this->hidetempblocks = $wgRequest->getBool( 'hidetempblocks' );
5654 $this->hideaddressblocks = $wgRequest->getBool( 'hideaddressblocks' );
5755
5856 $action = $wgRequest->getText( 'action' );
59 - $successip = $wgRequest->getVal( 'successip' );
6057
6158 if( $action == 'unblock' || $action == 'submit' && $wgRequest->wasPosted() ) {
62 - # Check permissions
63 - if( !$wgUser->isAllowed( 'block' ) ) {
64 - $wgOut->permissionRequired( 'block' );
65 - return;
66 - }
67 - # Check for database lock
68 - if( wfReadOnly() ) {
69 - $wgOut->readOnlyPage();
70 - return;
71 - }
72 -
73 - # bug 15810: blocked admins should have limited access here
74 - if ( $wgUser->isBlocked() ) {
75 - if ( $this->id ) {
76 - # This doesn't pick up on autoblocks, but admins
77 - # should have the ipblock-exempt permission anyway
78 - $block = Block::newFromID( $this->id );
79 - $user = User::newFromName( $block->mAddress );
80 - } else {
81 - $user = User::newFromName( $ip );
82 - }
83 - $status = SpecialBlock::checkUnblockSelf( $user );
84 - if ( $status !== true ) {
85 - throw new ErrorPageError( 'badaccess', $status );
86 - }
87 - }
88 -
89 - if( $action == 'unblock' ){
90 - # Show unblock form
91 - $this->showForm();
92 - } elseif( $action == 'submit'
93 - && $wgRequest->wasPosted()
94 - && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) )
95 - {
96 - # Remove blocks and redirect user to success page
97 - $this->doSubmit();
98 - }
99 -
100 - } elseif( $action == 'success' ) {
101 - # Inform the user of a successful unblock
102 - # (No need to check permissions or locks here,
103 - # if something was done, then it's too late!)
104 - if ( substr( $successip, 0, 1) == '#' ) {
105 - // A block ID was unblocked
106 - $this->showList( $wgOut->parse( wfMsg( 'unblocked-id', $successip ) ) );
107 - } else {
108 - // A username/IP was unblocked
109 - $this->showList( $wgOut->parse( wfMsg( 'unblocked', $successip ) ) );
110 - }
 59+ # B/C @since 1.18: Unblock interface is now at Special:Unblock
 60+ $title = SpecialPage::getTitleFor( 'Unblock', $this->ip );
 61+ $wgOut->redirect( $title->getFullUrl() );
 62+ return;
11163 } else {
11264 # Just show the block list
11365 $this->showList( '' );
11466 }
11567 }
11668
117 - /**
118 - * Generates the unblock form
119 - *
120 - * @param $err String, Array or null: error message name or an array if
121 - * there are parameters. Null indicates no error.
122 - * @return $out string: HTML form
123 - */
124 - function showForm( $err = null ) {
125 - global $wgOut, $wgUser;
126 -
127 - $wgOut->addWikiMsg( 'unblockiptext' );
128 -
129 - $action = $this->getTitle()->getLocalURL( 'action=submit' );
130 -
131 - if ( $err !== null ) {
132 - $wgOut->setSubtitle( wfMsg( 'formerror' ) );
133 - $wgOut->wrapWikiMsg( "<span class='error'>$1</span>\n", $err );
134 - }
135 -
136 - $addressPart = false;
137 - if ( $this->id ) {
138 - $block = Block::newFromID( $this->id );
139 - if ( $block ) {
140 - $encName = htmlspecialchars( $block->getRedactedName() );
141 - $encId = $this->id;
142 - $addressPart = $encName . Html::hidden( 'id', $encId );
143 - $ipa = wfMsgHtml( 'ipadressorusername' );
144 - }
145 - }
146 - if ( !$addressPart ) {
147 - $addressPart = Xml::input( 'wpUnblockAddress', 40, $this->ip, array( 'type' => 'text', 'tabindex' => '1' ) );
148 - $ipa = Xml::label( wfMsg( 'ipadressorusername' ), 'wpUnblockAddress' );
149 - }
150 -
151 - $wgOut->addHTML(
152 - Html::openElement( 'form', array( 'method' => 'post', 'action' => $action, 'id' => 'unblockip' ) ) .
153 - Html::openElement( 'fieldset' ) .
154 - Html::element( 'legend', null, wfMsg( 'ipb-unblock' ) ) .
155 - Html::openElement( 'table', array( 'id' => 'mw-unblock-table' ) ).
156 - "<tr>
157 - <td class='mw-label'>
158 - {$ipa}
159 - </td>
160 - <td class='mw-input'>
161 - {$addressPart}
162 - </td>
163 - </tr>
164 - <tr>
165 - <td class='mw-label'>" .
166 - Xml::label( wfMsg( 'ipbreason' ), 'wpUnblockReason' ) .
167 - "</td>
168 - <td class='mw-input'>" .
169 - Xml::input( 'wpUnblockReason', 40, $this->reason, array( 'type' => 'text', 'tabindex' => '2' ) ) .
170 - "</td>
171 - </tr>
172 - <tr>
173 - <td>&#160;</td>
174 - <td class='mw-submit'>" .
175 - Xml::submitButton( wfMsg( 'ipusubmit' ), array( 'name' => 'wpBlock', 'tabindex' => '3' ) ) .
176 - "</td>
177 - </tr>" .
178 - Html::closeElement( 'table' ) .
179 - Html::closeElement( 'fieldset' ) .
180 - Html::hidden( 'wpEditToken', $wgUser->editToken() ) .
181 - Html::closeElement( 'form' ) . "\n"
182 - );
183 -
184 - }
185 -
186 - const UNBLOCK_SUCCESS = 0; // Success
187 - const UNBLOCK_NO_SUCH_ID = 1; // No such block ID
188 - const UNBLOCK_USER_NOT_BLOCKED = 2; // IP wasn't blocked
189 - const UNBLOCK_BLOCKED_AS_RANGE = 3; // IP is part of a range block
190 - const UNBLOCK_UNKNOWNERR = 4; // Unknown error
191 -
192 - /**
193 - * Backend code for unblocking. doSubmit() wraps around this.
194 - * $range is only used when UNBLOCK_BLOCKED_AS_RANGE is returned, in which
195 - * case it contains the range $ip is part of.
196 - * @return array array(message key, parameters) on failure, empty array on success
197 - */
198 - public static function doUnblock( &$id, &$ip, &$reason, &$range = null, $blocker = null ) {
199 - if ( $id ) {
200 - $block = Block::newFromID( $id );
201 - if ( !$block ) {
202 - return array( 'ipb_cant_unblock', htmlspecialchars( $id ) );
203 - }
204 - $ip = $block->getRedactedName();
205 - } else {
206 - $ip = trim( $ip );
207 - if ( substr( $ip, 0, 1 ) == "#" ) {
208 - $id = substr( $ip, 1 );
209 - $block = Block::newFromID( $id );
210 - if( !$block ) {
211 - return array( 'ipb_cant_unblock', htmlspecialchars( $id ) );
212 - }
213 - $ip = $block->getRedactedName();
214 - } else {
215 - # FIXME: do proper sanitisation/cleanup here
216 - $ip = str_replace( '_', ' ', $ip );
217 -
218 - $block = Block::newFromDB( $ip );
219 - if ( !$block ) {
220 - return array( 'ipb_cant_unblock', htmlspecialchars( $id ) );
221 - }
222 - if( $block->mRangeStart != $block->mRangeEnd && !strstr( $ip, "/" ) ) {
223 - /* If the specified IP is a single address, and the block is
224 - * a range block, don't unblock the range. */
225 - $range = $block->mAddress;
226 - return array( 'ipb_blocked_as_range', $ip, $range );
227 - }
228 - }
229 - }
230 - // Yes, this is really necessary
231 - $id = $block->mId;
232 -
233 - # If the name was hidden and the blocking user cannot hide
234 - # names, then don't allow any block removals...
235 - if( $blocker && $block->mHideName && !$blocker->isAllowed( 'hideuser' ) ) {
236 - return array( 'ipb_cant_unblock', htmlspecialchars( $id ) );
237 - }
238 -
239 - # Delete block
240 - if ( !$block->delete() ) {
241 - return array( 'ipb_cant_unblock', htmlspecialchars( $id ) );
242 - }
243 -
244 - # Unset _deleted fields as needed
245 - if( $block->mHideName ) {
246 - RevisionDeleteUser::unsuppressUserName( $block->mAddress, $block->mUser );
247 - }
248 -
249 - # Make log entry
250 - $log = new LogPage( 'block' );
251 - $log->addEntry( 'unblock', Title::makeTitle( NS_USER, $ip ), $reason );
252 - return array();
253 - }
254 -
255 - function doSubmit() {
256 - global $wgOut, $wgUser;
257 -
258 - $retval = self::doUnblock( $this->id, $this->ip, $this->reason, $range, $wgUser );
259 - if ( count( $retval ) ) {
260 - $this->showForm( $retval );
261 - return;
262 - }
263 -
264 - # Report to the user
265 - $success = $this->getTitle()->getFullURL( 'action=success&successip=' . urlencode( $this->ip ) );
266 - $wgOut->redirect( $success );
267 - }
268 -
26969 function showList( $msg ) {
27070 global $wgOut, $wgUser;
27171
Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -256,13 +256,8 @@
257257 wfMsgHtml( 'change-blocklink' )
258258 );
259259 $tools[] = $sk->linkKnown( # Unblock link
260 - SpecialPage::getTitleFor( 'Ipblocklist' ),
261 - wfMsgHtml( 'unblocklink' ),
262 - array(),
263 - array(
264 - 'action' => 'unblock',
265 - 'ip' => $username
266 - )
 260+ SpecialPage::getTitleFor( 'Unblock', $username ),
 261+ wfMsgHtml( 'unblocklink' )
267262 );
268263 } else { # User is not blocked
269264 $tools[] = $sk->linkKnown( # Block link
Index: trunk/phase3/includes/specials/SpecialBlock.php
@@ -297,15 +297,14 @@
298298 }
299299
300300 # Link to unblock the specified user, or to a blank unblock form
301 - $list = SpecialPage::getTitleFor( 'Ipblocklist' );
302 - $query = array( 'action' => 'unblock' );
303301 if( $this->target instanceof User ) {
304302 $message = wfMsgExt( 'ipb-unblock-addr', array( 'parseinline' ), $this->target->getName() );
305 - $query['ip'] = $this->target->getName();
 303+ $list = SpecialPage::getTitleFor( 'Unblock', $this->target->getName() );
306304 } else {
307305 $message = wfMsgExt( 'ipb-unblock', array( 'parseinline' ) );
 306+ $list = SpecialPage::getTitleFor( 'Unblock' );
308307 }
309 - $links[] = $skin->linkKnown( $list, $message, array(), $query );
 308+ $links[] = $skin->linkKnown( $list, $message, array() );
310309
311310 # Link to the block list
312311 $links[] = $skin->linkKnown(
@@ -492,7 +491,7 @@
493492 $userId = 0;
494493 } else {
495494 # This should have been caught in the form field validation
496 - return wfMessage( 'badipaddress' );
 495+ return array( 'badipaddress' );
497496 }
498497
499498 if( ( strlen( $data['Expiry'] ) == 0) || ( strlen( $data['Expiry'] ) > 50 )
Index: trunk/phase3/includes/Block.php
@@ -920,7 +920,11 @@
921921 # FIXME: everything above here is a mess, needs much cleaning up
922922
923923 /**
924 - * Given a target and the target's type, get a Block object if possible
 924+ * Given a target and the target's type, get an existing Block object if possible.
 925+ * Note that passing an IP address will get an applicable rangeblock if the IP is
 926+ * not individually blocked but falls within that range
 927+ * TODO: check that that fallback handles nested rangeblocks nicely (should return
 928+ * smallest one)
925929 * @param $target String|User|Int a block target, which may be one of several types:
926930 * * A user to block, in which case $target will be a User
927931 * * An IP to block, in which case $target will be a User generated by using
@@ -942,7 +946,7 @@
943947 }
944948
945949 } elseif( $type == Block::TYPE_RANGE ){
946 - return Block::newFromDB( '', $target );
 950+ return Block::newFromDB( $target, 0 );
947951
948952 } elseif( $type == Block::TYPE_ID || $type == Block::TYPE_AUTO ){
949953 return Block::newFromID( $target );
@@ -1009,4 +1013,14 @@
10101014
10111015 return array( $target, $type );
10121016 }
 1017+
 1018+ public function getType(){
 1019+ list( $target, $type ) = $this->getTargetAndType();
 1020+ return $type;
 1021+ }
 1022+
 1023+ public function getTarget(){
 1024+ list( $target, $type ) = $this->getTargetAndType();
 1025+ return $target;
 1026+ }
10131027 }
Index: trunk/phase3/includes/SpecialPage.php
@@ -137,8 +137,8 @@
138138
139139 # Users and rights
140140 'Block' => 'SpecialBlock',
 141+ 'Unblock' => 'SpecialUnblock',
141142 'Ipblocklist' => 'IPUnblockForm',
142 - 'Unblock' => array( 'SpecialRedirectToSpecial', 'Unblock', 'Ipblocklist', false, array( 'uselang', 'ip', 'id' ), array( 'action' => 'unblock' ) ),
143143 'Resetpass' => 'SpecialResetpass',
144144 'DeletedContributions' => 'DeletedContributionsPage',
145145 'Preferences' => 'SpecialPreferences',
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -3066,6 +3066,7 @@
30673067 'unblockiptext' => 'Use the form below to restore write access to a previously blocked IP address or username.',
30683068 'ipusubmit' => 'Remove this block',
30693069 'unblocked' => '[[User:$1|$1]] has been unblocked',
 3070+'unblocked-range' => '$1 has been unblocked',
30703071 'unblocked-id' => 'Block $1 has been removed',
30713072 'ipblocklist' => 'Blocked IP addresses and usernames',
30723073 'ipblocklist-legend' => 'Find a blocked user',
@@ -3120,6 +3121,7 @@
31213122 $1 is already blocked.
31223123 Do you want to change the settings?',
31233124 'ipb-otherblocks-header' => 'Other {{PLURAL:$1|block|blocks}}',
 3125+'unblock-hideuser' => 'You cannot unblock this user, as their username has been hidden.',
31243126 'ipb_cant_unblock' => 'Error: Block ID $1 not found.
31253127 It may have been unblocked already.',
31263128 'ipb_blocked_as_range' => 'Error: The IP address $1 is not blocked directly and cannot be unblocked.

Follow-up revisions

RevisionCommit summaryAuthorDate
r83882Follow-up r83855: MessagesQqq documentationhappy-melon11:07, 14 March 2011
r83888Fix for r83855: Add new messages to avoid lt;block&gt; &lt;unblock&gt; on Spe...raymond12:20, 14 March 2011
r84006Fix exception on TWN raised in r83855 CR.happy-melon11:20, 15 March 2011

Comments

#Comment by Nikerabbit (talk | contribs)   07:36, 14 March 2011

Could you add documentation to qqq for unblocked-range about the variable and context?

#Comment by Raymond (talk | contribs)   08:14, 15 March 2011

Try to change to an existing block, like http://translatewiki.net/wiki/Special:Block/Automobile11 :

[15-Mar-2011 08:04:31] PHP Notice: Undefined variable: class in /www/w/includes/HTMLForm.php on line 179 [15-Mar-2011 08:04:31] /wiki/Special:Block/Webhost-Direkt: Exception: Descriptor with no class: Array (

   [default] => 0

)

  1. 0 /www/w/includes/HTMLForm.php(134): HTMLForm::loadInputFromParameters('HideUser', Array)
  2. 1 /www/w/includes/specials/SpecialBlock.php(86): HTMLForm->__construct(Array)
  3. 2 /www/w/includes/SpecialPage.php(607): SpecialBlock->execute('Webhost-Direkt')
  4. 3 /www/w/includes/Wiki.php(245): SpecialPage::executePath(Object(Title))
  5. 4 /www/w/includes/Wiki.php(63): MediaWiki->handleSpecialCases(Object(Title), Object(OutputPage), Object(WebRequest))
  6. 5 /www/w/index.php(104): MediaWiki->performRequestForTitle(Object(Title), NULL, Object(OutputPage), Object(User), Object(WebRequest))
  7. 6 {main}
#Comment by Happy-melon (talk | contribs)   11:20, 15 March 2011

Should be fixed in r84006.

#Comment by Aaron Schulz (talk | contribs)   19:37, 16 June 2011

+ $res['id'] = $block->mId;

Are there accessors for this stuff?

Status & tagging log