r36076 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36075‎ | r36076 | r36077 >
Date:13:03, 9 June 2008
Author:demon
Status:old
Tags:
Comment:
Bug 10080 - Finally fixed. No longer mis-detects an individual IP as blocked when the range is. Also, introduced new msg called ipb_tweak_block (per request of Siebrand) as opposed to repurposing ipb_already_blocked.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialBlockip.php (modified) (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
@@ -1618,6 +1618,7 @@
16191619 'ipb_expiry_invalid',
16201620 'ipb_expiry_temp',
16211621 'ipb_already_blocked',
 1622+ 'ipb_tweak_block',
16221623 'ipb_modifying_block',
16231624 'ipb_cant_unblock',
16241625 'ipb_blocked_as_range',
Index: trunk/phase3/includes/SpecialBlockip.php
@@ -32,8 +32,10 @@
3333 } else if ( $wgRequest->wasPosted() && 'submit' == $action &&
3434 $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
3535 $ipb->doSubmit();
 36+ } else if ( $ipb->AlreadyBlocked ) {
 37+ $ipb->showForm( wfMsg('ipb_tweak_block', $ipb->BlockAddress ) );
3638 } else {
37 - $ipb->showForm( '' );
 39+ $ipb->showForm('');
3840 }
3941 }
4042
@@ -47,10 +49,32 @@
4850 # var $BlockEmail;
4951
5052 function IPBlockForm( $par ) {
51 - global $wgRequest, $wgUser;
 53+ global $wgRequest, $wgUser, $wgLang;
5254
5355 $this->BlockAddress = $wgRequest->getVal( 'wpBlockAddress', $wgRequest->getVal( 'ip', $par ) );
5456 $this->BlockAddress = strtr( $this->BlockAddress, '_', ' ' );
 57+ $this->AlreadyBlocked = false;
 58+
 59+ if( $this->BlockAddress && !$wgRequest->wasPosted() ){
 60+ $this->mBlock = new Block();
 61+ if( $this->mBlock->load($this->BlockAddress) && $this->BlockAddress == $this->mBlock->mAddress ) {
 62+ $this->AlreadyBlocked = true;
 63+ $this->BlockReason = wfMsgForContent( 'ipb_modifying_block' );
 64+ $this->BlockReasonList = $wgRequest->getText( 'wpBlockReasonList' );
 65+ $this->BlockExpiry = wfMsg('ipbotheroption');
 66+ $this->BlockOther = $wgLang->timeanddate( $this->mBlock->mExpiry );
 67+ $this->BlockAnonOnly = $wgRequest->getBool( 'wpAnonOnly', true );
 68+ $this->BlockCreateAccount = $wgRequest->getBool( 'wpCreateAccount', true );
 69+ $this->BlockEnableAutoblock = $wgRequest->getBool( 'wpEnableAutoblock', true );
 70+ $this->BlockEmail = $wgRequest->getBool( 'wpEmailBan', false );
 71+ $this->BlockEmail = $this->mBlock->mBlockEmail;
 72+ $this->BlockWatchUser = $wgRequest->getBool( 'wpWatchUser', false );
 73+ # Re-check user's rights to hide names, very serious, defaults to 0
 74+ $this->BlockHideName = ( $this->mBlock->mHideName && $wgUser->isAllowed( 'hideuser' ) ) ? 1 : 0;
 75+ return true;
 76+ }
 77+ }
 78+
5579 $this->BlockReason = $wgRequest->getText( 'wpBlockReason' );
5680 $this->BlockReasonList = $wgRequest->getText( 'wpBlockReasonList' );
5781 $this->BlockExpiry = $wgRequest->getVal( 'wpBlockExpiry', wfMsg('ipbotheroption') );
@@ -69,7 +93,7 @@
7094 }
7195
7296 function showForm( $err ) {
73 - global $wgOut, $wgUser, $wgSysopUserBans;
 97+ global $wgOut, $wgUser, $wgSysopUserBans, $wgRequest;
7498
7599 $wgOut->setPagetitle( wfMsg( 'blockip' ) );
76100 $wgOut->addWikiMsg( 'blockiptext' );
@@ -86,8 +110,10 @@
87111
88112 $titleObj = SpecialPage::getTitleFor( 'Blockip' );
89113
 114+ if ( $wgRequest->wasPosted() ) {
 115+ $wgOut->setSubtitle( wfMsgHtml( 'formerror' ) );
 116+ }
90117 if ( "" != $err ) {
91 - $wgOut->setSubtitle( wfMsgHtml( 'formerror' ) );
92118 $wgOut->addHTML( Xml::tags( 'p', array( 'class' => 'error' ), $err ) );
93119 }
94120
@@ -363,7 +389,10 @@
364390 if ( wfRunHooks('BlockIp', array(&$block, &$wgUser)) ) {
365391
366392 if ( !$block->insert() ) {
367 - return array('ipb_already_blocked', htmlspecialchars($this->BlockAddress));
 393+ // Block already exists. Silently delete the existing block and insert it again
 394+ $oldblock = Block::newFromDB( $this->BlockAddress );
 395+ $oldblock->delete();
 396+ $block->insert();
368397 }
369398
370399 wfRunHooks('BlockIpComplete', array($block, $wgUser));
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2363,6 +2363,9 @@
23642364 'ipb_expiry_invalid' => 'Expiry time invalid.',
23652365 'ipb_expiry_temp' => 'Hidden username blocks should be permanent.',
23662366 'ipb_already_blocked' => '"$1" is already blocked',
 2367+'ipb_modifying_block' => 'Modifying existing block:',
 2368+'ipb_tweak_block' => 'Caution: This user ($1) is already blocked.
 2369+You can use this form to change the block settings.',
23672370 'ipb_cant_unblock' => 'Error: Block ID $1 not found. It may have been unblocked already.',
23682371 'ipb_blocked_as_range' => 'Error: The IP $1 is not blocked directly and cannot be unblocked.
23692372 It is, however, blocked as part of the range $2, which can be unblocked.',
Index: trunk/phase3/RELEASE-NOTES
@@ -342,6 +342,7 @@
343343 * (bug 14385) "Move subpages" option no longer tries to move to invalid titles
344344 * (bug 14386) Fix subpage namespace oddity when moving a talk page
345345 * (bug 11771) Signup form now not shown if in read-only mode.
 346+* (bug 10080) Users can now modify an existing block without unblocking first.
346347 * (bug 12859) $wgRateLimitsExcludedGroups has been deprecated in favor of
347348 $wgGroupPermissions[]['noratelimit'].
348349 * (Bug 13828) Split parameter $1 of MediaWiki:Missingarticle into $1 (=title)

Follow-up revisions

RevisionCommit summaryAuthorDate
r36109Alrighty, now we properly remove old blocks before inserting the new one. (Bu...demon22:03, 9 June 2008
r36113Revert r36076, r36109, r36110 -- just doesn't work right. Sometimes removes b...brion23:16, 9 June 2008
r42843(bug 10080) (bug 15820) - Allow modification of blocks without unblocking, an...mrzman21:45, 30 October 2008

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r35901Bug 10080 - Sysops can now modify a block without unblocking first. Patch by ...demon00:11, 5 June 2008

Status & tagging log