r93538 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93537‎ | r93538 | r93539 >
Date:16:10, 30 July 2011
Author:ashley
Status:deferred
Tags:
Comment:
AutomaticBoardWelcome: follow-up to r93523: ignore blocked sysops (thanks iAlex for catching this and thanks Skizzerz for helping me with the DB query) and move wfReadOnly() check above any DB queries (thanks Skizzerz)
Modified paths:
  • /trunk/extensions/AutomaticBoardWelcome/AutomaticBoardWelcome.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AutomaticBoardWelcome/AutomaticBoardWelcome.php
@@ -8,7 +8,7 @@
99 * @file
1010 * @ingroup Extensions
1111 * @version 0.1
12 - * @date 20 July 2011
 12+ * @date 30 July 2011
1313 * @author Jack Phoenix <jack@countervandalism.net>
1414 * @license http://en.wikipedia.org/wiki/Public_domain Public domain
1515 */
@@ -43,13 +43,23 @@
4444 return true;
4545 }
4646
 47+ // Just quit if we're in read-only mode
 48+ if ( wfReadOnly() ) {
 49+ return true;
 50+ }
 51+
4752 $dbr = wfGetDB( DB_SLAVE );
48 - // Get all users who are in the 'sysop' group from the database
 53+ // Get all users who are in the 'sysop' group and aren't blocked from
 54+ // the database
4955 $res = $dbr->select(
50 - 'user_groups',
 56+ array( 'user_groups', 'ipblocks' ),
5157 array( 'ug_group', 'ug_user' ),
52 - array( 'ug_group' => 'sysop' ),
53 - __METHOD__
 58+ array( 'ug_group' => 'sysop', 'ipb_user' => null ),
 59+ __METHOD__,
 60+ array(),
 61+ array(
 62+ 'ipblocks' => array( 'LEFT JOIN', 'ipb_user = ug_user' )
 63+ )
5464 );
5565
5666 $adminUids = array();
@@ -61,24 +71,21 @@
6272 $random = array_rand( array_flip( $adminUids ), 1 );
6373 $sender = User::newFromId( $random );
6474
65 - // Ignore blocked users who have +sysop and only send out the message
66 - // when we can, i.e. when the DB is *not* locked
67 - if ( !$sender->isBlocked() && !wfReadOnly() ) {
68 - $senderUid = $sender->getId();
69 - $senderName = $sender->getName();
 75+ $senderUid = $sender->getId();
 76+ $senderName = $sender->getName();
7077
71 - $b = new UserBoard();
72 - $b->sendBoardMessage(
73 - $senderUid, // sender's UID
74 - $senderName, // sender's name
75 - $user->getId(),
76 - $user->getName(),
77 - // passing the senderName as an argument here so that we can do
78 - // stuff like [[User talk:$1|contact me]] or w/e in the message
79 - wfMsgForContent( 'user-board-welcome-message', $senderName )
80 - // the final argument is message type: 0 (default) for public
81 - );
82 - }
 78+ // Send the message
 79+ $b = new UserBoard();
 80+ $b->sendBoardMessage(
 81+ $senderUid, // sender's UID
 82+ $senderName, // sender's name
 83+ $user->getId(),
 84+ $user->getName(),
 85+ // passing the senderName as an argument here so that we can do
 86+ // stuff like [[User talk:$1|contact me]] or w/e in the message
 87+ wfMsgForContent( 'user-board-welcome-message', $senderName )
 88+ // the final argument is message type: 0 (default) for public
 89+ );
8390 }
8491 return true;
8592 }
\ No newline at end of file

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r93523Automatic Board Welcome extension -- automatically posts a welcome message on...ashley13:55, 30 July 2011

Status & tagging log