? CVS-REL1_5.diff
Index: includes/Article.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/Article.php,v
retrieving revision 1.367.2.1
diff -u -b -r1.367.2.1 Article.php
--- includes/Article.php	15 Aug 2005 23:40:19 -0000	1.367.2.1
+++ includes/Article.php	22 Aug 2005 00:01:33 -0000
@@ -1069,11 +1069,6 @@
 		$this->updateRevisionOn( $dbw, $revision, 0 );
 
 		Article::onArticleCreate( $this->mTitle );
-		if(!$suppressRC) {
-			RecentChange::notifyNew( $now, $this->mTitle, $isminor, $wgUser, $summary, 'default',
-			  '', strlen( $text ), $revisionId );
-		}
-
 		if ($watchthis) {
 			if(!$this->mTitle->userIsWatching()) $this->watch();
 		} else {
@@ -1091,10 +1086,19 @@
 			$fname );
 
 		# standard deferred updates
-		$this->editUpdates( $text, $summary, $isminor, $now );
+		$this->editUpdates( $text );
+
+		# TG PATCH. Moved from some lines above to here
+		# Is important to call RecentChange::notifyNew __after__ editUpdates
+		# because a user_newtalk flag and addwatch might be committed in editUpdates
+		# which triggers the sending of an Enotif in RecentChange::notifyNew just right now
+		if(!$suppressRC) {
+			RecentChange::notifyNew( $now, $this->mTitle, $isminor, $wgUser, $summary, 'default',
+			  '', strlen( $text ), $revisionId );
+		}
 
 		$oldid = 0; # new article
-		$this->showArticle( $text, wfMsg( 'newarticle' ), false, $isminor, $now, $summary, $oldid );
+		$this->showArticle( $text, wfMsg( 'newarticle' ), false );
 		wfProfileOut( $fname );
 	}
 
@@ -1228,6 +1232,7 @@
 		$lastRevision = 0;
 
 		if ( 0 != strcmp( $text, $oldtext ) ) {
+			$empty = false;
 			$this->mGoodAdjustment = $this->isCountable( $text )
 			  - $this->isCountable( $oldtext );
 			$this->mTotalAdjustment = 0;
@@ -1255,14 +1260,13 @@
 				$good = false;
 				$dbw->rollback();
 			} else {
-				# Update recentchanges and purge cache and whatnot
+				# Update recentchanges (moved some lines below) and purge cache and whatnot
 				$bot = (int)($wgUser->isBot() || $forceBot);
-				RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $wgUser, $summary,
-					$lastRevision, $this->getTimestamp(), $bot, '', $oldsize, $newsize,
-					$revisionId );
 				Article::onArticleEdit( $this->mTitle );
 				$dbw->commit();
 			}
+		} else {
+			$empty = true;
 		}
 
 		if( !$wgDBtransactions ) {
@@ -1278,8 +1282,16 @@
 				}
 			}
 			# standard deferred updates
-			$this->editUpdates( $text, $summary, $minor, $now );
+			$this->editUpdates( $text );
 
+			if (!$empty) {
+				# moved from above to make sure editUpdates were performed:
+				# Is important to call RecentChange::notifyEdit _after_ editUpdates
+				# because a user_newtalk flag and addwatch might be committed in editUpdates
+				# which triggers the sending of an Enotif in RecentChange::notifyEdit just right now
+				RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $wgUser, $summary,
+					$lastRevision, $this->getTimestamp(), $bot, '', $oldsize, $newsize, $revisionId );
+			}
 
 			$urls = array();
 			# Template namespace
@@ -1307,7 +1319,7 @@
 				@unlink($cm->fileCacheName());
 			}
 
-			$this->showArticle( $text, wfMsg( 'updated' ), $sectionanchor, $isminor, $now, $summary, $lastRevision );
+			$this->showArticle( $text, wfMsg( 'updated' ), $sectionanchor );
 		}
 		wfProfileOut( $fname );
 		return $good;
@@ -1317,9 +1329,8 @@
 	 * After we've either updated or inserted the article, update
 	 * the link tables and redirect to the new page.
 	 */
-	function showArticle( $text, $subtitle , $sectionanchor = '', $me2, $now, $summary, $oldid ) {
-		global $wgUseDumbLinkUpdate, $wgAntiLockFlags, $wgOut, $wgUser, $wgLinkCache, $wgEnotif;
-		global $wgUseEnotif;
+	function showArticle( $text, $subtitle , $sectionanchor = '' ) {
+		global $wgUseDumbLinkUpdate, $wgAntiLockFlags, $wgOut, $wgUser, $wgLinkCache;
 
 		$fname = 'Article::showArticle';
 		wfProfileIn( $fname );
@@ -1362,12 +1373,6 @@
 			$r = '';
 		$wgOut->redirect( $this->mTitle->getFullURL( $r ).$sectionanchor );
 
-		if ( $wgUseEnotif  ) {
-			# this would be better as an extension hook
-			include_once( "UserMailer.php" );
-			$wgEnotif = new EmailNotification ();
-			$wgEnotif->notifyOnPageChange( $this->mTitle, $now, $summary, $me2, $oldid );
-		}
 		wfProfileOut( $fname );
 	}
 
@@ -2048,7 +2053,7 @@
 	 * @private
 	 */
 	function viewUpdates() {
-		global $wgDeferredUpdateList, $wgUseEnotif;
+		global $wgDeferredUpdateList;
 
 		if ( 0 != $this->getID() ) {
 			global $wgDisableCounters;
@@ -2064,16 +2069,10 @@
 
 		global $wgUser;
 		if ($this->mTitle->getNamespace() == NS_USER_TALK &&
-			$this->mTitle->getText() == $wgUser->getName())
-		{
-			if ( $wgUseEnotif ) {
-				require_once( 'UserTalkUpdate.php' );
-				$u = new UserTalkUpdate( 0, $this->mTitle->getNamespace(), $this->mTitle->getDBkey(), false, false, false );
-			} else {
+			$this->mTitle->getText() == $wgUser->getName()) {
 				$wgUser->setNewtalk(0);
 				$wgUser->saveNewtalk();
-			}
-		} elseif ( $wgUseEnotif ) {
+		} else {
 			$wgUser->clearNotification( $this->mTitle );
 		}
 
@@ -2085,9 +2084,9 @@
 	 * @private
 	 * @param string $text
 	 */
-	function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange) {
+	function editUpdates( $text ) {
 		global $wgDeferredUpdateList, $wgDBname, $wgMemc;
-		global $wgMessageCache, $wgUser, $wgUseEnotif;
+		global $wgMessageCache, $wgUser;
 
 		wfSeedRandom();
 		if ( 0 == mt_rand( 0, 999 ) ) {
@@ -2117,11 +2116,6 @@
 			# If this is another user's talk page, update newtalk
 
 			if ($this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $wgUser->getName()) {
-				if ( $wgUseEnotif ) {
-					require_once( 'UserTalkUpdate.php' );
-					$u = new UserTalkUpdate( 1, $this->mTitle->getNamespace(), $shortTitle, $summary,
-					  $minoredit, $timestamp_of_pagechange);
-				} else {
 					$other = User::newFromName( $shortTitle );
 					if( is_null( $other ) && User::isIP( $shortTitle ) ) {
 						// An anonymous user
@@ -2129,11 +2123,11 @@
 						$other->setName( $shortTitle );
 					}
 					if( $other ) {
+					$other->addWatch( $this->mTitle );
 						$other->setNewtalk(1);
 						$other->saveNewtalk();
 					}
 				}
-			}
 
 			if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
 				$wgMessageCache->replace( $shortTitle, $text );
Index: includes/RecentChange.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/RecentChange.php,v
retrieving revision 1.33
diff -u -b -r1.33 RecentChange.php
--- includes/RecentChange.php	1 Jul 2005 23:50:11 -0000	1.33
+++ includes/RecentChange.php	22 Aug 2005 00:01:33 -0000
@@ -226,6 +226,10 @@
 			'newSize'       => $newSize,
 		);
 		$rc->save();
+
+		include_once( "UserMailer.php" );
+		$wgEnotif = new EmailNotification ();
+		$wgEnotif->notifyOnPageChangeOrNewpage( $title, $timestamp, $comment, $minor, $oldId );
 	}
 
 	# Makes an entry in the database corresponding to page creation
@@ -270,6 +274,10 @@
 			'newSize' => $size
 		);
 		$rc->save();
+
+		include_once( "UserMailer.php" );
+		$wgEnotif = new EmailNotification ();
+		$wgEnotif->notifyOnPageChangeOrNewpage( $title, $timestamp, $comment, $minor, 0 );
 	}
 
 	# Makes an entry in the database corresponding to a rename
Index: includes/User.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/User.php,v
retrieving revision 1.176
diff -u -b -r1.176 User.php
--- includes/User.php	26 Jul 2005 16:09:00 -0000	1.176
+++ includes/User.php	22 Aug 2005 00:01:38 -0000
@@ -737,9 +737,16 @@
 		if( $this->mNewtalk == -1 ) {
 			$this->mNewtalk = 0; # reset talk page status
 
+			$dbr =& wfGetDB( DB_SLAVE );
+			if($this->mId) {
+				$res = $dbr->select( 'user_newtalk', 1, array( 'user_id' => $this->mId ), $fname );
+				if ( $dbr->numRows($res)>0 ) {
+					$this->mNewtalk= 1;
+				}
+				$dbr->freeResult( $res );
+			} else {
 			# Check memcached separately for anons, who have no
 			# entire User object stored in there.
-			if( !$this->mId ) {
 				global $wgDBname, $wgMemc;
 				$key = "$wgDBname:newtalk:ip:{$this->mName}";
 				$newtalk = $wgMemc->get( $key );
@@ -747,36 +754,18 @@
 					$this->mNewtalk = $newtalk ? 1 : 0;
 					return (bool)$this->mNewtalk;
 				}
-			}
-
-			$dbr =& wfGetDB( DB_SLAVE );
-			if ( $wgUseEnotif ) {
-				$res = $dbr->select( 'watchlist',
-					array( 'wl_user' ),
-					array( 'wl_title'     => $this->getTitleKey(),
-						   'wl_namespace' => NS_USER_TALK,
-						   'wl_user'      => $this->mId,
-						   'wl_notificationtimestamp != 0' ),
-					'User::getNewtalk' );
-				if( $dbr->numRows($res) > 0 ) {
-					$this->mNewtalk = 1;
-				}
-				$dbr->freeResult( $res );
-			} elseif ( $this->mId ) {
-				$res = $dbr->select( 'user_newtalk', 1, array( 'user_id' => $this->mId ), $fname );
 
-				if ( $dbr->numRows($res)>0 ) {
-					$this->mNewtalk= 1;
-				}
-				$dbr->freeResult( $res );
-			} else {
+				if( ! is_integer( $newtalk ) ){
 				$res = $dbr->select( 'user_newtalk', 1, array( 'user_ip' => $this->mName ), $fname );
+
 				$this->mNewtalk = $dbr->numRows( $res ) > 0 ? 1 : 0;
 				$dbr->freeResult( $res );
-			}
 
-			if( !$this->mId ) {
 				$wgMemc->set( $key, $this->mNewtalk, time() ); // + 1800 );
+				} else {
+					$this->mNewtalk = $newtalk ? 1 : 0;
+					return (bool)$this->mNewtalk;
+				}
 			}
 		}
 
@@ -1184,12 +1173,14 @@
 					'wl_notificationtimestamp' => 0
 				), array( /* WHERE */
 					'wl_user' => $currentUser
-				), 'UserMailer::clearAll'
+				), 'UserMailer::clearAllNotifications'
 			);
+		}
 
 		# 	we also need to clear here the "you have new message" notification for the own user_talk page
 		#	This is cleared one page view later in Article::viewUpdates();
-		}
+		$this->setnewtalk(0);
+		$this->saveNewtalk();
 	}
 
 	/**
@@ -1259,12 +1250,16 @@
 	 * Save object settings into database
 	 */
 	function saveSettings() {
-		global $wgMemc, $wgDBname, $wgUseEnotif;
+		global $wgMemc, $wgDBname;
 		$fname = 'User::saveSettings';
 
 		if ( wfReadOnly() ) { return; }
-		$this->saveNewtalk();
-		if ( 0 == $this->mId ) { return; }
+		if( !$this->mId ) {
+				# Anon users have a separate memcache space for newtalk
+				# since they don't store their own info. Trim...
+				$wgMemc->delete( "$wgDBname:newtalk:ip:{$this->mName}" );
+				return;
+		}
 
 		$dbw =& wfGetDB( DB_MASTER );
 		$dbw->update( 'user',
@@ -1289,34 +1284,17 @@
 	 * Save value of new talk flag.
 	 */
 	function saveNewtalk() {
-		global $wgDBname, $wgMemc, $wgUseEnotif;
+		global $wgDBname, $wgMemc;
 
 		$fname = 'User::saveNewtalk';
 
 		$changed = false;
 
 		if ( wfReadOnly() ) { return ; }
+
 		$dbr =& wfGetDB( DB_SLAVE );
 		$dbw =& wfGetDB( DB_MASTER );
-		$changed = false;
-		if ( $wgUseEnotif ) {
-			if ( ! $this->getNewtalk() ) {
-				# Delete the watchlist entry for user_talk page X watched by user X
-				$dbw->delete( 'watchlist',
-					array( 'wl_user'      => $this->mId,
-						   'wl_title'     => $this->getTitleKey(),
-						   'wl_namespace' => NS_USER_TALK ),
-					$fname );
-				if ( $dbw->affectedRows() ) {
-					$changed = true;
-				}
-				if( !$this->mId ) {
-					# Anon users have a separate memcache space for newtalk
-					# since they don't store their own info. Trim...
-					$wgMemc->delete( "$wgDBname:newtalk:ip:{$this->mName}" );
-				}
-			}
-		} else {
+
 			if ($this->getID() != 0) {
 				$field = 'user_id';
 				$value = $this->getID();
@@ -1327,11 +1305,7 @@
 				$key = "$wgDBname:newtalk:ip:$this->mName";
 			}
 
-			$dbr =& wfGetDB( DB_SLAVE );
-			$dbw =& wfGetDB( DB_MASTER );
-
-			$res = $dbr->selectField('user_newtalk', $field,
-									 array($field => $value), $fname);
+		$res = $dbr->selectField('user_newtalk', $field, array($field => $value), $fname);
 
 			$changed = true;
 			if ($res !== false && $this->mNewtalk == 0) {
@@ -1347,7 +1321,7 @@
 			} else {
 				$changed = false;
 			}
-		}
+
 
 		# Update user_touched, so that newtalk notifications in the client cache are invalidated
 		if ( $changed && $this->getID() ) {
Index: includes/UserMailer.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/UserMailer.php,v
retrieving revision 1.30
diff -u -b -r1.30 UserMailer.php
--- includes/UserMailer.php	22 Jul 2005 11:21:57 -0000	1.30
+++ includes/UserMailer.php	22 Aug 2005 00:01:38 -0000
@@ -152,7 +152,7 @@
 	 * @param $currentMinorEdit
 	 * @param $oldid (default: false)
 	 */
-	function notifyOnPageChange(&$title, $timestamp, $summary, $minorEdit, $oldid=false) {
+	function notifyOnPageChangeOrNewpage(&$title, $timestamp, $summary, $minorEdit, $oldid=false) {
 	
 		# we use $wgEmergencyContact as sender's address
 		global $wgUser, $wgLang, $wgEmergencyContact;
@@ -163,7 +163,7 @@
 		global $wgEmailAuthentication;
 		global $wgShowUpdatedMarker;
 
-		$fname = 'UserMailer::notifyOnPageChange';
+		$fname = 'UserMailer::notifyOnPageChangeOrNewpage';
 		wfProfileIn( $fname );
 		
 		# The following code is only run, if several conditions are met:
@@ -196,18 +196,19 @@
 				$this->minorEdit = $minorEdit;
 				$this->oldid = $oldid;
 
-				$this->composeCommonMailtext();
+				$mail = $this->composeCommonMailtext();
 				$watchingUser = new User();
+				$initialised = true;
 	
 				# ... now do for all watching users ... if the options fit
 				for ($i = 1; $i <= $dbr->numRows( $res ); $i++) { 
 
 					$wuser = $dbr->fetchObject( $res );
 					$watchingUser->setID($wuser->wl_user);
-					if ( ( $enotifwatchlistpage && $watchingUser->getOption('enotifwatchlistpages') ) ||
-						( $enotifusertalkpage && $watchingUser->getOption('enotifusertalkpages') )
+					if ( ( ( $enotifwatchlistpage && $watchingUser->getOption('enotifwatchlistpages') ) ||
+						( $enotifusertalkpage && $watchingUser->getOption('enotifusertalkpages') ) )
 					&& (!$minorEdit || ($wgEnotifMinorEdits && $watchingUser->getOption('enotifminoredits') ) )
-					&& ($watchingUser->isEmailConfirmed() ) ) {
+					&& $watchingUser->canReceiveEmail() ) {
 						# ... adjust remaining text and page edit time placeholders
 						# which needs to be personalized for each user
 						$this->composeAndSendPersonalisedMail( $watchingUser );
@@ -227,7 +228,7 @@
 				), array( /* WHERE */
 					'wl_title' => $title->getDBkey(),
 					'wl_namespace' => $title->getNamespace(),
-				), 'UserMailer::NotifyOnChange'
+				), $fname
 			);
 		}
 
@@ -249,6 +250,7 @@
 		# named variables when composing your notification emails while
 		# simply editing the Meta pages
 		
+		### $to      = wfMsgForContent( 'enotif_to' );
 		$subject = wfMsgForContent( 'enotif_subject' );
 		$body    = wfMsgForContent( 'enotif_body' );
 		$from    = ''; /* fail safe */
@@ -345,8 +347,10 @@
 		// From the PHP manual:
 		//     Note:  The to parameter cannot be an address in the form of "Something <someone@example.com>". 
 		//     The mail command will not parse this properly while talking with the MTA.
+		//	$to = $watchingUser->getName() . ' <' . $watchingUser->getEmail() . '>';
 		$to = $watchingUser->getEmail();
 		$body = str_replace( '$WATCHINGUSERNAME', $watchingUser->getName() , $this->body );
+		$body = str_replace( '$WATCHINGUSEREMAILADDR', $watchingUser->getEmail(), $body );
 	
 		$timecorrection = $watchingUser->getOption( 'timecorrection' );
 		if( !$timecorrection ) {
@@ -357,7 +361,7 @@
 		# expressed in terms of individual local time of the notification
 		# recipient, i.e. watching user
 		$body = str_replace('$PAGEEDITDATE',
-			$wgLang->timeanddate( $this->timestamp, true, false, $timecorrection ),
+			$wgLang->timeanddate( $this->timestamp, true, false, $timecorrection, true ),
 			$body);
 		
 		$error = userMailer( $to, $this->from, $this->subject, $body, $this->replyto );
Index: includes/WatchedItem.php
===================================================================
RCS file: /cvsroot/wikipedia/phase3/includes/WatchedItem.php,v
retrieving revision 1.17
diff -u -b -r1.17 WatchedItem.php
--- includes/WatchedItem.php	14 May 2005 17:55:04 -0000	1.17
+++ includes/WatchedItem.php	22 Aug 2005 00:01:38 -0000
@@ -66,27 +66,45 @@
 	function addWatch() {
 		$fname = 'WatchedItem::addWatch';
 		wfProfileIn( $fname );
-		# REPLACE instead of INSERT because occasionally someone
-		# accidentally reloads a watch-add operation.
+		# when addWatch() is called, potentially pending notifications must be preserved
+		# article and talk pages are separately checked for their presence in the watchlist table
+		# and missing entry/ies is/are safely added
+		# reminder: since enotif, each page has its own entry in table watchlist to record the notification-
+		# timestamps separately. Tom Gries
 		$dbw =& wfGetDB( DB_MASTER );
+		$dbr =& wfGetDB( DB_MASTER );
+		extract( $dbr->tableNames( 'watchlist' ) );
+		$res = $dbr->selectRow( 'watchlist', array( 'wl_user' ),
+			array(
+				'wl_user' => $this->id,
+				'wl_namespace' => ( $this->ns & ~1 ),
+				'wl_title' => $this->ti
+			), $fname );
+		if ( !$res ) {
 		$dbw->replace( 'watchlist', array(array('wl_user', 'wl_namespace', 'wl_title', 'wl_notificationtimestamp')),
 		  array( 
 		    'wl_user' => $this->id,
-			'wl_namespace' => ($this->ns & ~1),
+			'wl_namespace' => ( $this->ns & ~1 ),
 			'wl_title' => $this->ti,
 			'wl_notificationtimestamp' => '0'
 		  ), $fname );
+		}
 
-		# the following code compensates the new behaviour, introduced by the enotif patch,
-		# that every single watched page needs now to be listed in watchlist
-		# namespace:page and namespace_talk:page need separate entries: create them
+		$res = $dbr->selectRow( 'watchlist', array( 'wl_user' ),
+			array(
+				'wl_user' => $this->id,
+				'wl_namespace' => ( $this->ns | 1 ),
+				'wl_title' => $this->ti,
+			), $fname );
+		if ( !$res ) {
 		$dbw->replace( 'watchlist', array(array('wl_user', 'wl_namespace', 'wl_title', 'wl_notificationtimestamp')),
 		  array(
 			'wl_user' => $this->id,
-			'wl_namespace' => ($this->ns | 1 ),
+			'wl_namespace' => ( $this->ns | 1 ),
 			'wl_title' => $this->ti,
 			'wl_notificationtimestamp' => '0'
 		  ), $fname );
+		}
 
 		global $wgMemc;
 		$wgMemc->set( $this->watchkey(), 1 );
Index: maintenance/updaters.inc
===================================================================
RCS file: /cvsroot/wikipedia/phase3/maintenance/updaters.inc,v
retrieving revision 1.66
diff -u -b -r1.66 updaters.inc
--- maintenance/updaters.inc	23 Jul 2005 05:47:24 -0000	1.66
+++ maintenance/updaters.inc	22 Aug 2005 00:01:38 -0000
@@ -180,45 +180,6 @@
 	}
 }
 
-function do_copy_newtalk_to_watchlist() {
-	global $wgDatabase;
-	global $wgCommandLineMode;	# this needs to be saved while getID() and getName() are called
-
-	$res = $wgDatabase->safeQuery( 'SELECT user_id, user_ip FROM !',
-		$wgDatabase->tableName( 'user_newtalk' ) );
-	$num_newtalks=$wgDatabase->numRows($res);
-	echo "Now converting ".$num_newtalks." user_newtalk entries to watchlist table entries ... \n";
-
-	$user = new User();
-	for ( $i = 1; $i <= $num_newtalks; $i++ ) {
-		$wluser = $wgDatabase->fetchObject( $res );
-		if ($wluser->user_id == 0) { # anonymous users ... have IP numbers as "names"
-			if ($user->isIP($wluser->user_ip)) { # do only if it really looks like an IP number (double checked)
-				$wgDatabase->replace( 'watchlist',
-					array(array('wl_user','wl_namespace', 'wl_title', 'wl_notificationtimestamp' )),
-					  array('wl_user' 			=> 0,
-						'wl_namespace' 			=> NS_USER_TALK,
-						'wl_title' 			=> $wluser->user_ip,
-						'wl_notificationtimestamp' 	=> '19700101000000'
-						), 'updaters.inc::do_watchlist_update2'
-					);
-			}
-		} else { # normal users ... have user_ids
-			$user->setID($wluser->user_id);
-			$wgDatabase->replace( 'watchlist',
-				array(array('wl_user','wl_namespace', 'wl_title', 'wl_notificationtimestamp' )),
-				  array('wl_user' 			=> $user->getID(),
-					'wl_namespace' 			=> NS_USER_TALK,
-					'wl_title' 			=> $user->getName(),
-					'wl_notificationtimestamp' 	=> '19700101000000'
-					), 'updaters.inc::do_watchlist_update3'
-				);
-		}
-	}
-	echo "Done.\n";
-}
-
-
 function do_user_update() {
 	global $wgDatabase;
 	if( $wgDatabase->fieldExists( 'user', 'user_emailauthenticationtimestamp' ) ) {
@@ -652,7 +613,6 @@
 	do_image_name_unique_update(); flush();
 	do_watchlist_update(); flush();
 	do_user_update(); flush();
-######	do_copy_newtalk_to_watchlist(); flush();
 	do_logging_encoding(); flush();
 	
 	do_schema_restructuring(); flush();
