| Index: trunk/phase3/maintenance/archives/patch-usernewtalk2.sql |
| — | — | @@ -0,0 +1,6 @@ |
| | 2 | +CREATE TABLE /*$wgDBprefix*/user_newtalk ( |
| | 3 | + user_id int(5) NOT NULL default '0', |
| | 4 | + user_ip varchar(40) NOT NULL default '', |
| | 5 | + INDEX user_id (user_id), |
| | 6 | + INDEX user_ip (user_ip) |
| | 7 | +); |
| Property changes on: trunk/phase3/maintenance/archives/patch-usernewtalk2.sql |
| ___________________________________________________________________ |
| Name: svn:eol-style |
| 1 | 8 | + native |
| Name: svn:keywords |
| 2 | 9 | + Author Date Id Revision |
| Index: trunk/phase3/maintenance/updaters.inc |
| — | — | @@ -23,6 +23,7 @@ |
| 24 | 24 | array( 'categorylinks', 'patch-categorylinks.sql' ), |
| 25 | 25 | array( 'logging', 'patch-logging.sql' ), |
| 26 | 26 | array( 'validate', 'patch-validate.sql' ), |
| | 27 | + array( 'user_newtalk', 'patch-usernewtalk2.sql' ), |
| 27 | 28 | ); |
| 28 | 29 | |
| 29 | 30 | $wgNewFields = array( |
| — | — | @@ -45,7 +46,7 @@ |
| 46 | 47 | array( 'image', 'img_metadata', 'patch-img_metadata.sql' ), |
| 47 | 48 | array( 'image', 'img_media_type', 'patch-img_media_type.sql' ), |
| 48 | 49 | array( 'validate', 'val_ip', 'patch-val_ip.sql' ), |
| 49 | | - array( 'site_stats', 'ss_total_articles', 'patch-ss_total_articles.sql' ), |
| | 50 | + array( 'site_stats', 'ss_total_pages', 'patch-ss_total_articles.sql' ), |
| 50 | 51 | ); |
| 51 | 52 | |
| 52 | 53 | function rename_table( $from, $to, $patch ) { |
| — | — | @@ -167,9 +168,9 @@ |
| 168 | 169 | function do_watchlist_update() { |
| 169 | 170 | global $wgDatabase; |
| 170 | 171 | if( $wgDatabase->fieldExists( 'watchlist', 'wl_notificationtimestamp' ) ) { |
| 171 | | - echo "ENOTIF: The watchlist table is already set up for email notification.\n"; |
| | 172 | + echo "The watchlist table is already set up for email notification.\n"; |
| 172 | 173 | } else { |
| 173 | | - echo "ENOTIF: Adding wl_notificationtimestamp field for email notification management."; |
| | 174 | + echo "Adding wl_notificationtimestamp field for email notification management."; |
| 174 | 175 | /* ALTER TABLE watchlist ADD (wl_notificationtimestamp varchar(14) binary NOT NULL default '0'); */ |
| 175 | 176 | dbsource( "maintenance/archives/patch-email-notification.sql", $wgDatabase ); |
| 176 | 177 | echo "ok\n"; |
| — | — | @@ -180,47 +181,38 @@ |
| 181 | 182 | global $wgDatabase; |
| 182 | 183 | global $wgCommandLineMode; # this needs to be saved while getID() and getName() are called |
| 183 | 184 | |
| 184 | | - if ( $wgDatabase->tableExists( 'user_newtalk' ) ) { |
| 185 | | - $res = $wgDatabase->safeQuery( 'SELECT user_id, user_ip FROM !', |
| 186 | | - $wgDatabase->tableName( 'user_newtalk' ) ); |
| 187 | | - $num_newtalks=$wgDatabase->numRows($res); |
| 188 | | - echo "ENOTIF: Now converting ".$num_newtalks." user_newtalk entries to watchlist table entries ... \n"; |
| | 185 | + $res = $wgDatabase->safeQuery( 'SELECT user_id, user_ip FROM !', |
| | 186 | + $wgDatabase->tableName( 'user_newtalk' ) ); |
| | 187 | + $num_newtalks=$wgDatabase->numRows($res); |
| | 188 | + echo "Now converting ".$num_newtalks." user_newtalk entries to watchlist table entries ... \n"; |
| 189 | 189 | |
| 190 | | - $user = new User(); |
| 191 | | - for ( $i = 1; $i <= $num_newtalks; $i++ ) { |
| 192 | | - $wluser = $wgDatabase->fetchObject( $res ); |
| 193 | | - echo 'ENOTIF: <= user_newtalk: user_id='.$wluser->user_id.' user_ip='.$wluser->user_ip."\n"; |
| 194 | | - if ($wluser->user_id == 0) { # anonymous users ... have IP numbers as "names" |
| 195 | | - if ($user->isIP($wluser->user_ip)) { # do only if it really looks like an IP number (double checked) |
| 196 | | - $wgDatabase->replace( 'watchlist', |
| 197 | | - array(array('wl_user','wl_namespace', 'wl_title', 'wl_notificationtimestamp' )), |
| 198 | | - array('wl_user' => 0, |
| 199 | | - 'wl_namespace' => NS_USER_TALK, |
| 200 | | - 'wl_title' => $wluser->user_ip, |
| 201 | | - 'wl_notificationtimestamp' => '19700101000000' |
| 202 | | - ), 'updaters.inc::do_watchlist_update2' |
| 203 | | - ); |
| 204 | | - echo 'ENOTIF: ====> watchlist: user_id=0 '.$wluser->user_ip."\n"; |
| 205 | | - } |
| 206 | | - } else { # normal users ... have user_ids |
| 207 | | - $user->setID($wluser->user_id); |
| | 190 | + $user = new User(); |
| | 191 | + for ( $i = 1; $i <= $num_newtalks; $i++ ) { |
| | 192 | + $wluser = $wgDatabase->fetchObject( $res ); |
| | 193 | + if ($wluser->user_id == 0) { # anonymous users ... have IP numbers as "names" |
| | 194 | + if ($user->isIP($wluser->user_ip)) { # do only if it really looks like an IP number (double checked) |
| 208 | 195 | $wgDatabase->replace( 'watchlist', |
| 209 | 196 | array(array('wl_user','wl_namespace', 'wl_title', 'wl_notificationtimestamp' )), |
| 210 | | - array('wl_user' => $user->getID(), |
| | 197 | + array('wl_user' => 0, |
| 211 | 198 | 'wl_namespace' => NS_USER_TALK, |
| 212 | | - 'wl_title' => $user->getName(), |
| | 199 | + 'wl_title' => $wluser->user_ip, |
| 213 | 200 | 'wl_notificationtimestamp' => '19700101000000' |
| 214 | | - ), 'updaters.inc::do_watchlist_update3' |
| | 201 | + ), 'updaters.inc::do_watchlist_update2' |
| 215 | 202 | ); |
| 216 | | - echo 'ENOTIF: ====> watchlist: user_id='.$user->getID().' '.$user->getName()."\n"; |
| 217 | 203 | } |
| | 204 | + } else { # normal users ... have user_ids |
| | 205 | + $user->setID($wluser->user_id); |
| | 206 | + $wgDatabase->replace( 'watchlist', |
| | 207 | + array(array('wl_user','wl_namespace', 'wl_title', 'wl_notificationtimestamp' )), |
| | 208 | + array('wl_user' => $user->getID(), |
| | 209 | + 'wl_namespace' => NS_USER_TALK, |
| | 210 | + 'wl_title' => $user->getName(), |
| | 211 | + 'wl_notificationtimestamp' => '19700101000000' |
| | 212 | + ), 'updaters.inc::do_watchlist_update3' |
| | 213 | + ); |
| 218 | 214 | } |
| 219 | | - echo "ENOTIF: The watchlist table has got the former user_newtalk entries.\n"; |
| 220 | | - dbsource( "maintenance/archives/patch-drop-user_newtalk.sql", $wgDatabase ); |
| 221 | | - echo "ENOTIF: Deleting the user_newtalk table as its entries are now in the watchlist table.\n"; |
| 222 | | - } else { |
| 223 | | - echo "ENOTIF: No user_newtalk table found. Nothing to convert to watchlist table entries.\n"; |
| 224 | 215 | } |
| | 216 | + echo "Done.\n"; |
| 225 | 217 | } |
| 226 | 218 | |
| 227 | 219 | |
| Index: trunk/phase3/maintenance/tables.sql |
| — | — | @@ -135,14 +135,14 @@ |
| 136 | 136 | KEY (ug_group) |
| 137 | 137 | ) TYPE=InnoDB; |
| 138 | 138 | |
| | 139 | +-- Stores notifications of user talk page changes, for the display |
| | 140 | +-- of the "you have new messages" box |
| | 141 | +CREATE TABLE /*$wgDBprefix*/user_newtalk ( |
| | 142 | + user_id int(5) NOT NULL default '0', |
| | 143 | + user_ip varchar(40) NOT NULL default '', |
| | 144 | + INDEX user_id (user_id), |
| | 145 | + INDEX user_ip (user_ip) |
| | 146 | +); |
| 139 | 147 | |
| 140 | 148 | |
| 141 | 149 | -- |
| Index: trunk/phase3/includes/Article.php |
| — | — | @@ -1199,6 +1199,7 @@ |
| 1200 | 1200 | */ |
| 1201 | 1201 | function showArticle( $text, $subtitle , $sectionanchor = '', $me2, $now, $summary, $oldid ) { |
| 1202 | 1202 | global $wgUseDumbLinkUpdate, $wgAntiLockFlags, $wgOut, $wgUser, $wgLinkCache, $wgEnotif; |
| | 1203 | + global $wgUseEnotif; |
| 1203 | 1204 | |
| 1204 | 1205 | $wgLinkCache = new LinkCache(); |
| 1205 | 1206 | |
| — | — | @@ -1251,12 +1252,12 @@ |
| 1252 | 1253 | $r = ''; |
| 1253 | 1254 | $wgOut->redirect( $this->mTitle->getFullURL( $r ).$sectionanchor ); |
| 1254 | 1255 | |
| 1255 | | - # this call would better fit into RecentChange::notifyEdit and RecentChange::notifyNew . |
| 1256 | | - # this will be improved later (to-do) |
| 1257 | | - |
| 1258 | | - include_once( "UserMailer.php" ); |
| 1259 | | - $wgEnotif = new EmailNotification (); |
| 1260 | | - $wgEnotif->notifyOnPageChange( $this->mTitle, $now, $summary, $me2, $oldid ); |
| | 1256 | + if ( $wgUseEnotif ) { |
| | 1257 | + # this would be better as an extension hook |
| | 1258 | + include_once( "UserMailer.php" ); |
| | 1259 | + $wgEnotif = new EmailNotification (); |
| | 1260 | + $wgEnotif->notifyOnPageChange( $this->mTitle, $now, $summary, $me2, $oldid ); |
| | 1261 | + } |
| 1261 | 1262 | } |
| 1262 | 1263 | |
| 1263 | 1264 | /** |
| — | — | @@ -1933,7 +1934,7 @@ |
| 1934 | 1935 | * @private |
| 1935 | 1936 | */ |
| 1936 | 1937 | function viewUpdates() { |
| 1937 | | - global $wgDeferredUpdateList; |
| | 1938 | + global $wgDeferredUpdateList, $wgUseEnotif; |
| 1938 | 1939 | |
| 1939 | 1940 | if ( 0 != $this->getID() ) { |
| 1940 | 1941 | global $wgDisableCounters; |
| — | — | @@ -1951,9 +1952,14 @@ |
| 1952 | 1953 | if ($this->mTitle->getNamespace() == NS_USER_TALK && |
| 1953 | 1954 | $this->mTitle->getText() == $wgUser->getName()) |
| 1954 | 1955 | { |
| 1955 | | - require_once( 'UserTalkUpdate.php' ); |
| 1956 | | - $u = new UserTalkUpdate( 0, $this->mTitle->getNamespace(), $this->mTitle->getDBkey(), false, false, false ); |
| 1957 | | - } else { |
| | 1956 | + if ( $wgUseEnotif ) { |
| | 1957 | + require_once( 'UserTalkUpdate.php' ); |
| | 1958 | + $u = new UserTalkUpdate( 0, $this->mTitle->getNamespace(), $this->mTitle->getDBkey(), false, false, false ); |
| | 1959 | + } else { |
| | 1960 | + $wgUser->setNewtalk(0); |
| | 1961 | + $wgUser->saveNewtalk(); |
| | 1962 | + } |
| | 1963 | + } elseif ( $wgUseEnotif ) { |
| 1958 | 1964 | $wgUser->clearNotification( $this->mTitle ); |
| 1959 | 1965 | } |
| 1960 | 1966 | |
| — | — | @@ -1967,7 +1973,7 @@ |
| 1968 | 1974 | */ |
| 1969 | 1975 | function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange) { |
| 1970 | 1976 | global $wgDeferredUpdateList, $wgDBname, $wgMemc; |
| 1971 | | - global $wgMessageCache, $wgUser; |
| | 1977 | + global $wgMessageCache, $wgUser, $wgUseEnotif; |
| 1972 | 1978 | |
| 1973 | 1979 | wfSeedRandom(); |
| 1974 | 1980 | if ( 0 == mt_rand( 0, 999 ) ) { |
| — | — | @@ -1991,13 +1997,18 @@ |
| 1992 | 1998 | $u = new SearchUpdate( $id, $title, $text ); |
| 1993 | 1999 | array_push( $wgDeferredUpdateList, $u ); |
| 1994 | 2000 | |
| 1995 | | - # If this is another user's talk page, |
| 1996 | | - # create a watchlist entry for this page |
| | 2001 | + # If this is another user's talk page, update newtalk |
| 1997 | 2002 | |
| 1998 | | - if ($this->mTitle->getNamespace() == NS_USER_TALK && |
| 1999 | | - $shortTitle != $wgUser->getName()) { |
| 2000 | | - require_once( 'UserTalkUpdate.php' ); |
| 2001 | | - $u = new UserTalkUpdate( 1, $this->mTitle->getNamespace(), $shortTitle, $summary, $minoredit, $timestamp_of_pagechange); |
| | 2003 | + if ($this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $wgUser->getName()) { |
| | 2004 | + if ( $wgUseEnotif ) { |
| | 2005 | + require_once( 'UserTalkUpdate.php' ); |
| | 2006 | + $u = new UserTalkUpdate( 1, $this->mTitle->getNamespace(), $shortTitle, $summary, |
| | 2007 | + $minoredit, $timestamp_of_pagechange); |
| | 2008 | + } else { |
| | 2009 | + $other = User::newFromName($shortTitle); |
| | 2010 | + $other->setNewtalk(1); |
| | 2011 | + $other->saveNewtalk(); |
| | 2012 | + } |
| 2002 | 2013 | } |
| 2003 | 2014 | |
| 2004 | 2015 | if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { |
| Index: trunk/phase3/includes/Setup.php |
| — | — | @@ -101,6 +101,8 @@ |
| 102 | 102 | $wgSkipSkins[] = $wgSkipSkin; |
| 103 | 103 | } |
| 104 | 104 | |
| | 105 | +$wgUseEnotif = $wgEnotifUserTalk || $wgEnotifWatchlist; |
| | 106 | + |
| 105 | 107 | wfProfileOut( $fname.'-misc1' ); |
| 106 | 108 | wfProfileIn( $fname.'-memcached' ); |
| 107 | 109 | |