r42020 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42019‎ | r42020 | r42021 >
Date:06:17, 13 October 2008
Author:aaron
Status:old (Comments)
Tags:
Comment:
Refactor sendToUDP() some more
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuth.php (modified) (history)
  • /trunk/extensions/CentralAuth/CentralAuthUser.php (modified) (history)
  • /trunk/phase3/includes/RecentChange.php (modified) (history)
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -814,8 +814,14 @@
815815 $this->loadDefaults();
816816 return false;
817817 }
818 - if ( isset( $_SESSION['wsUserName'] ) ) {
819 - $sName = $_SESSION['wsUserName'];
 818+ if ( isset( $_SESSION['wsUserName'] ) && isset( $_COOKIE["{$wgCookiePrefix}UserName"] ) ) {
 819+ // Cookie and session username should match
 820+ if( $_SESSION['wsUserName'] == $_COOKIE["{$wgCookiePrefix}UserName"] ) {
 821+ $sName = $_SESSION['wsUserName'];
 822+ } else {
 823+ $this->loadDefaults();
 824+ return false;
 825+ }
820826 } else if ( isset( $_COOKIE["{$wgCookiePrefix}UserName"] ) ) {
821827 $sName = $_COOKIE["{$wgCookiePrefix}UserName"];
822828 $_SESSION['wsUserName'] = $sName;
Index: trunk/phase3/includes/RecentChange.php
@@ -140,7 +140,7 @@
141141 # Writes the data in this object to the database
142142 function save()
143143 {
144 - global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress, $wgRC2UDPPrefix, $wgRC2UDPOmitBots;
 144+ global $wgLocalInterwiki, $wgPutIPinRC, $wgRC2UDPAddress, $wgRC2UDPOmitBots;
145145 $fname = 'RecentChange::save';
146146
147147 $dbw = wfGetDB( DB_MASTER );
@@ -176,7 +176,7 @@
177177
178178 # Notify external application via UDP
179179 if ( $wgRC2UDPAddress && ( !$this->mAttribs['rc_bot'] || !$wgRC2UDPOmitBots ) ) {
180 - self::sendToUDP( $wgRC2UDPPrefix, $this->getIRCLine() );
 180+ self::sendToUDP( $this->getIRCLine() );
181181 }
182182
183183 # E-mail notifications
@@ -208,16 +208,21 @@
209209 /**
210210 * Send some text to UDP
211211 * @param string $line
 212+ * @param string $prefix
 213+ * @param string $address
212214 * @return bool success
213215 */
214 - public static function sendToUDP( $prefix, $line ) {
215 - global $wgRC2UDPAddress, $wgRC2UDPPort;
 216+ public static function sendToUDP( $line, $address = '', $prefix = '' ) {
 217+ global $wgRC2UDPAddress, $wgRC2UDPPrefix, $wgRC2UDPPort;
 218+ # Assume default for standard RC case
 219+ $address = $address ? $address : $wgRC2UDPAddress;
 220+ $prefix = $prefix ? $prefix : $wgRC2UDPPrefix;
216221 # Notify external application via UDP
217 - if( $wgRC2UDPAddress ) {
 222+ if( $address && $prefix ) {
218223 $conn = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
219224 if( $conn ) {
220225 $line = $prefix . $line;
221 - socket_sendto( $conn, $line, strlen($line), 0, $wgRC2UDPAddress, $wgRC2UDPPort );
 226+ socket_sendto( $conn, $line, strlen($line), 0, $address, $wgRC2UDPPort );
222227 socket_close( $conn );
223228 return true;
224229 }
Index: trunk/extensions/CentralAuth/CentralAuthUser.php
@@ -1015,10 +1015,11 @@
10161016 }
10171017
10181018 $this->invalidateCache();
1019 - global $wgCentralAuthNew2UDPPrefix;
1020 - if( $wgCentralAuthNew2UDPPrefix ) {
 1019+ global $wgCentralAuthUDPAddress, $wgCentralAuthNew2UDPPrefix;
 1020+ if( $wgCentralAuthUDPAddress ) {
10211021 $userpage = Title::makeTitleSafe( NS_USER, $this->mName );
1022 - RecentChange::sendToUDP( $wgCentralAuthNew2UDPPrefix, self::getIRCLine( $userpage, $wikiID ) );
 1022+ RecentChange::sendToUDP( self::getIRCLine( $userpage, $wikiID ),
 1023+ $wgCentralAuthUDPAddress, $wgCentralAuthNew2UDPPrefix );
10231024 }
10241025 }
10251026
Index: trunk/extensions/CentralAuth/CentralAuth.php
@@ -124,6 +124,8 @@
125125 */
126126 $wgCentralAuthCreateOnView = false;
127127
 128+// UDP logging stuff
 129+$wgCentralAuthUDPAddress = false;
128130 $wgCentralAuthNew2UDPPrefix = '';
129131
130132 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r42036Comment out accidentally committed code from r42020; didn't mean to commit ju...aaron15:02, 13 October 2008

Comments

#Comment by Voice of All (talk | contribs)   15:02, 13 October 2008

Didn't mean to commit User changes. Commented out in r42036.

#Comment by Brion VIBBER (talk | contribs)   19:11, 13 October 2008

r42038 removed the $prefix check in sendToUDP() so it's possible again to send with an empty prefix

Status & tagging log