r93233 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93232‎ | r93233 | r93234 >
Date:19:04, 26 July 2011
Author:happy-melon
Status:ok (Comments)
Tags:
Comment:
* Fix double-escaping from r85025
* Allow admins to modify blocks placed (probably accidentally) on themselves *by* themselves, whether or not they have the 'unblockself' permission.
Modified paths:
  • /trunk/phase3/includes/specials/SpecialBlock.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialBlock.php
@@ -346,12 +346,10 @@
347347 protected function doPostText( HTMLForm &$form ){
348348 global $wgUser, $wgLang;
349349
350 - $skin = $wgUser->getSkin();
351 -
352350 # Link to the user's contributions, if applicable
353351 if( $this->target instanceof User ){
354352 $contribsPage = SpecialPage::getTitleFor( 'Contributions', $this->target->getName() );
355 - $links[] = $skin->link(
 353+ $links[] = Linker::link(
356354 $contribsPage,
357355 wfMsgExt( 'ipb-blocklist-contribs', 'escape', $this->target->getName() )
358356 );
@@ -365,17 +363,17 @@
366364 $message = wfMsgExt( 'ipb-unblock', array( 'parseinline' ) );
367365 $list = SpecialPage::getTitleFor( 'Unblock' );
368366 }
369 - $links[] = $skin->linkKnown( $list, $message, array() );
 367+ $links[] = Linker::linkKnown( $list, $message, array() );
370368
371369 # Link to the block list
372 - $links[] = $skin->linkKnown(
 370+ $links[] = Linker::linkKnown(
373371 SpecialPage::getTitleFor( 'BlockList' ),
374372 wfMsg( 'ipb-blocklist' )
375373 );
376374
377375 # Link to edit the block dropdown reasons, if applicable
378376 if ( $wgUser->isAllowed( 'editinterface' ) ) {
379 - $links[] = $skin->link(
 377+ $links[] = Linker::link(
380378 Title::makeTitle( NS_MEDIAWIKI, 'Ipbreason-dropdown' ),
381379 wfMsgHtml( 'ipb-edit-dropdown' ),
382380 array(),
@@ -476,6 +474,8 @@
477475 /**
478476 * HTMLForm field validation-callback for Target field.
479477 * @since 1.18
 478+ * @param $value String
 479+ * @param $alldata Array
480480 * @return Message
481481 */
482482 public static function validateTargetField( $value, $alldata = null ) {
@@ -636,7 +636,7 @@
637637 if( !$status ) {
638638 # Show form unless the user is already aware of this...
639639 if( !$data['Confirm'] || ( array_key_exists( 'PreviousTarget', $data )
640 - && $data['PreviousTarget'] !== htmlspecialchars( $block->getTarget() ) ) )
 640+ && $data['PreviousTarget'] !== $block->getTarget() ) )
641641 {
642642 return array( array( 'ipb_already_blocked', $block->getTarget() ) );
643643 # Otherwise, try to update the block...
@@ -715,6 +715,8 @@
716716 * Get an array of suggested block durations from MediaWiki:Ipboptions
717717 * @todo FIXME: This uses a rather odd syntax for the options, should it be converted
718718 * to the standard "**<duration>|<displayname>" format?
 719+ * @param $lang Language|null the language to get the durations in, or null to use
 720+ * the wiki's content language
719721 * @return Array
720722 */
721723 public static function getSuggestedDurations( $lang = null ){
@@ -775,6 +777,7 @@
776778 * others, and probably shouldn't be able to unblock themselves
777779 * either.
778780 * @param $user User|Int|String
 781+ * @return Bool|String true or error message key
779782 */
780783 public static function checkUnblockSelf( $user ) {
781784 global $wgUser;
@@ -788,6 +791,9 @@
789792 # User is trying to unblock themselves
790793 if ( $wgUser->isAllowed( 'unblockself' ) ) {
791794 return true;
 795+ # User blocked themselves and is now trying to reverse it
 796+ } elseif ( $wgUser->blockedBy() === $wgUser->getName() ) {
 797+ return true;
792798 } else {
793799 return 'ipbnounblockself';
794800 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r94235Followup r85025, r85166, r93233: use strict comparison per CR comment, becaus...catrope10:33, 11 August 2011
r94446MFT to REL1_18:...hashar09:27, 14 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85025(bug 23408) give admins a warning before letting them block themselves. Also...happy-melon18:00, 30 March 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   17:59, 2 August 2011
$wgUser->blockedBy() === $wgUser->getName()

Could this use ID instead of name?

#Comment by Happy-melon (talk | contribs)   08:03, 3 August 2011

If the available accessors in User weren't so retarded, sure... :P

Status & tagging log