MediaWiki r9649 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r9648‎ | r9649 (on ViewVC)‎ | r9650 >
Date:13:47, 25 June 2005
Author:timstarling
Status:old
Tags:
Comment:
recovering previous behaviour when enotif is switched off
Modified paths:

Diff [purge]

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
18 + native
Name: svn:keywords
29 + Author Date Id Revision
Index: trunk/phase3/maintenance/updaters.inc
@@ -23,6 +23,7 @@
2424 array( 'categorylinks', 'patch-categorylinks.sql' ),
2525 array( 'logging', 'patch-logging.sql' ),
2626 array( 'validate', 'patch-validate.sql' ),
 27+ array( 'user_newtalk', 'patch-usernewtalk2.sql' ),
2728 );
2829
2930 $wgNewFields = array(
@@ -45,7 +46,7 @@
4647 array( 'image', 'img_metadata', 'patch-img_metadata.sql' ),
4748 array( 'image', 'img_media_type', 'patch-img_media_type.sql' ),
4849 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' ),
5051 );
5152
5253 function rename_table( $from, $to, $patch ) {
@@ -167,9 +168,9 @@
168169 function do_watchlist_update() {
169170 global $wgDatabase;
170171 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";
172173 } else {
173 - echo "ENOTIF: Adding wl_notificationtimestamp field for email notification management.";
 174+ echo "Adding wl_notificationtimestamp field for email notification management.";
174175 /* ALTER TABLE watchlist ADD (wl_notificationtimestamp varchar(14) binary NOT NULL default '0'); */
175176 dbsource( "maintenance/archives/patch-email-notification.sql", $wgDatabase );
176177 echo "ok\n";
@@ -180,47 +181,38 @@
181182 global $wgDatabase;
182183 global $wgCommandLineMode; # this needs to be saved while getID() and getName() are called
183184
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";
189189
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)
208195 $wgDatabase->replace( 'watchlist',
209196 array(array('wl_user','wl_namespace', 'wl_title', 'wl_notificationtimestamp' )),
210 - array('wl_user' => $user->getID(),
 197+ array('wl_user' => 0,
211198 'wl_namespace' => NS_USER_TALK,
212 - 'wl_title' => $user->getName(),
 199+ 'wl_title' => $wluser->user_ip,
213200 'wl_notificationtimestamp' => '19700101000000'
214 - ), 'updaters.inc::do_watchlist_update3'
 201+ ), 'updaters.inc::do_watchlist_update2'
215202 );
216 - echo 'ENOTIF: ====> watchlist: user_id='.$user->getID().' '.$user->getName()."\n";
217203 }
 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+ );
218214 }
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";
224215 }
 216+ echo "Done.\n";
225217 }
226218
227219
Index: trunk/phase3/maintenance/tables.sql
@@ -135,14 +135,14 @@
136136 KEY (ug_group)
137137 ) TYPE=InnoDB;
138138
 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+);
139147
140148
141149 --
Index: trunk/phase3/includes/Article.php
@@ -1199,6 +1199,7 @@
12001200 */
12011201 function showArticle( $text, $subtitle , $sectionanchor = '', $me2, $now, $summary, $oldid ) {
12021202 global $wgUseDumbLinkUpdate, $wgAntiLockFlags, $wgOut, $wgUser, $wgLinkCache, $wgEnotif;
 1203+ global $wgUseEnotif;
12031204
12041205 $wgLinkCache = new LinkCache();
12051206
@@ -1251,12 +1252,12 @@
12521253 $r = '';
12531254 $wgOut->redirect( $this->mTitle->getFullURL( $r ).$sectionanchor );
12541255
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+ }
12611262 }
12621263
12631264 /**
@@ -1933,7 +1934,7 @@
19341935 * @private
19351936 */
19361937 function viewUpdates() {
1937 - global $wgDeferredUpdateList;
 1938+ global $wgDeferredUpdateList, $wgUseEnotif;
19381939
19391940 if ( 0 != $this->getID() ) {
19401941 global $wgDisableCounters;
@@ -1951,9 +1952,14 @@
19521953 if ($this->mTitle->getNamespace() == NS_USER_TALK &&
19531954 $this->mTitle->getText() == $wgUser->getName())
19541955 {
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 ) {
19581964 $wgUser->clearNotification( $this->mTitle );
19591965 }
19601966
@@ -1967,7 +1973,7 @@
19681974 */
19691975 function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange) {
19701976 global $wgDeferredUpdateList, $wgDBname, $wgMemc;
1971 - global $wgMessageCache, $wgUser;
 1977+ global $wgMessageCache, $wgUser, $wgUseEnotif;
19721978
19731979 wfSeedRandom();
19741980 if ( 0 == mt_rand( 0, 999 ) ) {
@@ -1991,13 +1997,18 @@
19921998 $u = new SearchUpdate( $id, $title, $text );
19931999 array_push( $wgDeferredUpdateList, $u );
19942000
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
19972002
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+ }
20022013 }
20032014
20042015 if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
Index: trunk/phase3/includes/Setup.php
@@ -101,6 +101,8 @@
102102 $wgSkipSkins[] = $wgSkipSkin;
103103 }
104104
 105+$wgUseEnotif = $wgEnotifUserTalk || $wgEnotifWatchlist;
 106+
105107 wfProfileOut( $fname.'-misc1' );
106108 wfProfileIn( $fname.'-memcached' );
107109

Status & tagging log

  • 01:56, 13 October 2010 ^demon (Talk | contribs) changed the status of r9649 [removed: new added: old]
Personal tools
Namespaces

Variants
Views
Actions
Navigation
Support
Download
Development
Communication
Toolbox