public function execute() {
		$userName = '******'; // <- targer username

		$user = new CentralAuthUser( $userName );
		if ( !$user->exists() ) {
			echo "Cannot unsuppress non-existent user {$userName}!\n";
			exit( 0 );
		}
		$userName = $user->getName(); // sanity
		$wikis = $user->listAttached(); // wikis with attached accounts
		foreach ( $wikis as $wiki ) {
			$lb = wfGetLB( $wiki );
			$dbw = $lb->getConnection( DB_MASTER, array(), $wiki );
			# Get local ID like $user->localUserData( $wiki ) does
			$localUserId = $dbw->selectField( 'user', 'user_id',
				array( 'user_name' => $userName ), __METHOD__ );

			$delUserBit = Revision::DELETED_USER;
			$hiddenCount = $dbw->selectField( 'revision', 'COUNT(*)',
				array( 'rev_user' => $localUserId, "rev_deleted & $delUserBit != 0" ), __METHOD__ );
			echo "$hiddenCount edits have the username hidden on \"$wiki\"\n";
			# Unsuppress username on edits
			if ( $hiddenCount > 0 ) {
				echo "Unsuppressed edits of attached account (local id $localUserId) on \"$wiki\"...";
				IPBlockForm::unsuppressUserName( $userName, $localUserId, $dbw );
				echo "done!\n\n";
			}
			$lb->reuseConnection( $dbw ); // not really needed
			# Don't lag too bad
			wfWaitForSlaves( 5 );
		}
	}
Esempio n. 2
0
 /**
  * Backend code for unblocking. doSubmit() wraps around this.
  * $range is only used when UNBLOCK_BLOCKED_AS_RANGE is returned, in which
  * case it contains the range $ip is part of.
  * @return array array(message key, parameters) on failure, empty array on success
  */
 static function doUnblock(&$id, &$ip, &$reason, &$range = null, $blocker = null)
 {
     if ($id) {
         $block = Block::newFromID($id);
         if (!$block) {
             return array('ipb_cant_unblock', htmlspecialchars($id));
         }
         $ip = $block->getRedactedName();
     } else {
         $block = new Block();
         $ip = trim($ip);
         if (substr($ip, 0, 1) == "#") {
             $id = substr($ip, 1);
             $block = Block::newFromID($id);
             if (!$block) {
                 return array('ipb_cant_unblock', htmlspecialchars($id));
             }
             $ip = $block->getRedactedName();
         } else {
             $block = Block::newFromDB($ip);
             if (!$block) {
                 return array('ipb_cant_unblock', htmlspecialchars($id));
             }
             if ($block->mRangeStart != $block->mRangeEnd && !strstr($ip, "/")) {
                 /* If the specified IP is a single address, and the block is
                  * a range block, don't unblock the range. */
                 $range = $block->mAddress;
                 return array('ipb_blocked_as_range', $ip, $range);
             }
         }
     }
     // Yes, this is really necessary
     $id = $block->mId;
     # If the name was hidden and the blocking user cannot hide
     # names, then don't allow any block removals...
     if ($blocker && $block->mHideName && !$blocker->isAllowed('hideuser')) {
         return array('ipb_cant_unblock', htmlspecialchars($id));
     }
     # Delete block
     if (!$block->delete()) {
         return array('ipb_cant_unblock', htmlspecialchars($id));
     }
     # Unset _deleted fields as needed
     if ($block->mHideName) {
         IPBlockForm::unsuppressUserName($block->mAddress, $block->mUser);
     }
     # Make log entry
     $log = new LogPage('block');
     $log->addEntry('unblock', Title::makeTitle(NS_USER, $ip), $reason);
     return array();
 }