r105879 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105878‎ | r105879 | r105880 >
Date:14:19, 12 December 2011
Author:reedy
Status:deferred
Tags:
Comment:
Followup r98339, user_options is dead

We've got a user row, so create a user object and that to look up what that the value is, rather than copy paste duplicated code
Modified paths:
  • /trunk/extensions/SemanticNotifyMe/includes/SMW_NotifyProcessor.php (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/includes/SMW_NotifyProcessor.smw15.php (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/includes/storage/SMW_NMStorageSQL.php (modified) (history)
  • /trunk/extensions/SemanticNotifyMe/specials/SMWNotifyMe/SMW_NMSendMailAsync.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticNotifyMe/specials/SMWNotifyMe/SMW_NMSendMailAsync.php
@@ -26,19 +26,6 @@
2727 die( -1 );
2828 }
2929
30 -// copy from user class
31 -function getUserNMOption( $str ) {
32 - $options = array();
33 - $a = explode( "\n", $str );
34 - foreach ( $a as $s ) {
35 - $m = array();
36 - if ( preg_match( "/^(.[^=]*)=(.*)$/", $s, $m ) ) {
37 - $options[$m[1]] = $m[2];
38 - }
39 - }
40 - return $options['enotifyme'];
41 -}
42 -
4330 // include commandLine script which provides some basic
4431 // methodes for maintenance scripts
4532 $mediaWikiLocation = dirname( __FILE__ ) . '/../../../..';
@@ -50,9 +37,12 @@
5138 $msgs = $sStore->getUnmailedNMMessages();
5239 foreach ( $msgs as $msg ) {
5340 // send notifications by mail
54 - if ( $msg['user_id'] == null ) continue;
 41+ if ( $msg['user_id'] == null ) {
 42+ continue;
 43+ }
5544 $user_info = $sStore->getUserInfo( $msg['user_id'] );
56 - if ( ( $user_info->user_email != '' ) && getUserNMOption( $user_info->user_options ) ) {
 45+ $user = User::newFromRow( $user_info );
 46+ if ( ( $user_info->user_email != '' ) && $user->getOption( 'enotifyme' ) ) {
5747 $name = ( ( $user_info->user_real_name == '' ) ? $user_info->user_name:$user_info->user_real_name );
5848
5949 UserMailer::send(
Index: trunk/extensions/SemanticNotifyMe/includes/SMW_NotifyProcessor.smw15.php
@@ -1632,7 +1632,8 @@
16331633 if ( $wgEnotifyMeJob ) {
16341634 // send notifications by mail
16351635 $user_info = $sStore->getUserInfo( $user_id );
1636 - if ( ( $user_info->user_email != '' ) && $this->getUserNMOption( $user_info->user_options ) ) {
 1636+ $user = User::newFromRow( $user_info );
 1637+ if ( ( $user_info->user_email != '' ) && $user->getOption( 'enotifyme' ) ) {
16371638 $name = ( ( $user_info->user_real_name == '' ) ? $user_info->user_name:$user_info->user_real_name );
16381639
16391640 $params = array( 'to' => new MailAddress( $user_info->user_email, $name ),
Index: trunk/extensions/SemanticNotifyMe/includes/SMW_NotifyProcessor.php
@@ -1629,7 +1629,8 @@
16301630 if ( $wgEnotifyMeJob ) {
16311631 // send notifications by mail
16321632 $user_info = $sStore->getUserInfo( $user_id );
1633 - if ( ( $user_info->user_email != '' ) && $this->getUserNMOption( $user_info->user_options ) ) {
 1633+ $user = User::newFromRow( $user_info );
 1634+ if ( ( $user_info->user_email != '' ) && $user->getOption( 'enotifyme' ) ) {
16341635 $name = ( ( $user_info->user_real_name == '' ) ? $user_info->user_name:$user_info->user_real_name );
16351636
16361637 $params = array( 'to' => new MailAddress( $user_info->user_email, $name ),
@@ -1682,16 +1683,4 @@
16831684 }
16841685 }
16851686 }
1686 - // copy from user class
1687 - function getUserNMOption( $str ) {
1688 - $options = array();
1689 - $a = explode( "\n", $str );
1690 - foreach ( $a as $s ) {
1691 - $m = array();
1692 - if ( preg_match( "/^(.[^=]*)=(.*)$/", $s, $m ) ) {
1693 - $options[$m[1]] = $m[2];
1694 - }
1695 - }
1696 - return $options['enotifyme'];
1697 - }
16981687 }
Index: trunk/extensions/SemanticNotifyMe/includes/storage/SMW_NMStorageSQL.php
@@ -600,7 +600,7 @@
601601 wfProfileIn( $fname );
602602
603603 $db = wfGetDB( DB_SLAVE );
604 - $result = $db->selectRow( 'user', array( 'user_name', 'user_real_name', 'user_email', 'user_options' ), array( 'user_id' => $user_id ), $fname );
 604+ $result = $db->selectRow( 'user', array( 'user_name', 'user_real_name', 'user_email' ), array( 'user_id' => $user_id ), $fname );
605605
606606 wfProfileOut( $fname );
607607 return $result;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98339* (bug 31204) Remove old user.user_options...reedy18:08, 28 September 2011