r35901 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35900‎ | r35901 | r35902 >
Date:00:11, 5 June 2008
Author:demon
Status:old
Tags:
Comment:
Bug 10080 - Sysops can now modify a block without unblocking first. Patch by Huji with some tweaks to allow for silent unblocking (no log entry).
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialBlockip.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialBlockip.php
@@ -47,10 +47,32 @@
4848 # var $BlockEmail;
4949
5050 function IPBlockForm( $par ) {
51 - global $wgRequest, $wgUser;
 51+ global $wgRequest, $wgUser, $wgLang;
5252
5353 $this->BlockAddress = $wgRequest->getVal( 'wpBlockAddress', $wgRequest->getVal( 'ip', $par ) );
5454 $this->BlockAddress = strtr( $this->BlockAddress, '_', ' ' );
 55+ $this->AlreadyBlocked = false;
 56+
 57+ if( $this->BlockAddress && !$wgRequest->wasPosted() ){
 58+ $this->mBlock = new Block();
 59+ if( $this->mBlock->load($this->BlockAddress) ) {
 60+ $this->AlreadyBlocked = true;
 61+ $this->BlockReason = wfMsgForContent( 'ipb_modifying_block' );
 62+ $this->BlockReasonList = $wgRequest->getText( 'wpBlockReasonList' );
 63+ $this->BlockExpiry = wfMsg('ipbotheroption');
 64+ $this->BlockOther = $wgLang->timeanddate( $this->mBlock->mExpiry );
 65+ $this->BlockAnonOnly = $wgRequest->getBool( 'wpAnonOnly', true );
 66+ $this->BlockCreateAccount = $wgRequest->getBool( 'wpCreateAccount', true );
 67+ $this->BlockEnableAutoblock = $wgRequest->getBool( 'wpEnableAutoblock', true );
 68+ $this->BlockEmail = $wgRequest->getBool( 'wpEmailBan', false );
 69+ $this->BlockEmail = $this->mBlock->mBlockEmail;
 70+ $this->BlockWatchUser = $wgRequest->getBool( 'wpWatchUser', false );
 71+ # Re-check user's rights to hide names, very serious, defaults to 0
 72+ $this->BlockHideName = ( $this->mBlock->mHideName && $wgUser->isAllowed( 'hideuser' ) ) ? 1 : 0;
 73+ return true;
 74+ }
 75+ }
 76+
5577 $this->BlockReason = $wgRequest->getText( 'wpBlockReason' );
5678 $this->BlockReasonList = $wgRequest->getText( 'wpBlockReasonList' );
5779 $this->BlockExpiry = $wgRequest->getVal( 'wpBlockExpiry', wfMsg('ipbotheroption') );
@@ -111,6 +133,10 @@
112134 wfMsgForContent( 'ipbreasonotherlist' ), '', 'wpBlockDropDown', 4 );
113135
114136 global $wgStylePath, $wgStyleVersion;
 137+ if( $this->AlreadyBlocked ) {
 138+ $wgOut->addHTML( Xml::element( 'p', array ( 'class' => 'error' ),
 139+ wfMsg( 'ipb_already_blocked', $this->BlockAddress ) ) );
 140+ }
115141 $wgOut->addHTML(
116142 Xml::tags( 'script', array( 'type' => 'text/javascript', 'src' => "$wgStylePath/common/block.js?$wgStyleVersion" ), '' ) .
117143 Xml::openElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalURL( "action=submit" ), 'id' => 'blockip' ) ) .
@@ -358,7 +384,10 @@
359385 if (wfRunHooks('BlockIp', array(&$block, &$wgUser))) {
360386
361387 if ( !$block->insert() ) {
362 - return array('ipb_already_blocked', htmlspecialchars($this->BlockAddress));
 388+ // Block already exists. Silently delete the existing block and insert it again
 389+ $oldblock = Block::newFromDB( $this->BlockAddress );
 390+ $oldblock->delete();
 391+ $block->insert();
363392 }
364393
365394 wfRunHooks('BlockIpComplete', array($block, $wgUser));
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2356,7 +2356,8 @@
23572357 'block-log-flags-noemail' => 'e-mail blocked',
23582358 'range_block_disabled' => 'The sysop ability to create range blocks is disabled.',
23592359 'ipb_expiry_invalid' => 'Expiry time invalid.',
2360 -'ipb_already_blocked' => '"$1" is already blocked',
 2360+'ipb_already_blocked' => 'Caution: "$1" is alrady blocked. You can modify the block settings by using this form.',
 2361+'ipb_modifying_block' => 'Modifying existing block:',
23612362 'ipb_cant_unblock' => 'Error: Block ID $1 not found. It may have been unblocked already.',
23622363 'ipb_blocked_as_range' => 'Error: The IP $1 is not blocked directly and cannot be unblocked.
23632364 It is, however, blocked as part of the range $2, which can be unblocked.',
Index: trunk/phase3/RELEASE-NOTES
@@ -334,6 +334,7 @@
335335 * (bug 14385) "Move subpages" option no longer tries to move to invalid titles
336336 * (bug 14386) Fix subpage namespace oddity when moving a talk page
337337 * (bug 11771) Signup form now not shown if in read-only mode.
 338+* (bug 10080) Users can now modify an existing block without unblocking first.
338339
339340 === API changes in 1.13 ===
340341

Follow-up revisions

RevisionCommit summaryAuthorDate
r35960Revert r35901 -- UI regressions (ipb_already_blocked appears to have changed ...brion00:46, 6 June 2008
r36076Bug 10080 - Finally fixed. No longer mis-detects an individual IP as blocked ...demon13:03, 9 June 2008
r36109Alrighty, now we properly remove old blocks before inserting the new one. (Bu...demon22:03, 9 June 2008
r42843(bug 10080) (bug 15820) - Allow modification of blocks without unblocking, an...mrzman21:45, 30 October 2008

Status & tagging log