Beispiel #1
0
 public function execute()
 {
     $this->logRunTime();
     $watchlistBot = new GlobalWatchlistBot();
     try {
         $watchlistBot->sendWeeklyDigest();
     } catch (Exception $e) {
         $this->logError($e);
     }
 }
 /**
  * Adds entries for watched pages in the global_watchlist table.
  * @param String $databaseKey
  * @param String $nameSpace
  * @param array $watchers
  */
 public function addWatchers($databaseKey, $nameSpace, array $watchers)
 {
     $titleObj = Title::newFromText($databaseKey, $nameSpace);
     if ($titleObj instanceof Title && $titleObj->exists()) {
         $revision = Revision::newFromTitle($titleObj);
         // Skip revisions that doesn't exist
         if (!empty($revision)) {
             $globalWatchlistBot = new GlobalWatchlistBot();
             $db = wfGetDB(DB_MASTER, [], \F::app()->wg->ExternalDatawareDB);
             foreach ($watchers as $watcherID) {
                 if ($globalWatchlistBot->shouldNotSendDigest($watcherID)) {
                     $this->clearGlobalWatchlistAll($watcherID);
                     continue;
                 }
                 (new WikiaSQL())->INSERT()->INTO(GlobalWatchlistTable::TABLE_NAME)->SET(GlobalWatchlistTable::COLUMN_USER_ID, $watcherID)->SET(GlobalWatchlistTable::COLUMN_CITY_ID, \F::app()->wg->CityId)->SET(GlobalWatchlistTable::COLUMN_TITLE, $databaseKey)->SET(GlobalWatchlistTable::COLUMN_NAMESPACE, $nameSpace)->SET(GlobalWatchlistTable::COLUMN_REVISION_ID, $revision->getId())->SET(GlobalWatchlistTable::COLUMN_REVISION_TIMESTAMP, $revision->getTimestamp())->SET(GlobalWatchlistTable::COLUMN_TIMESTAMP, $revision->getTimestamp())->ON_DUPLICATE_KEY_UPDATE([GlobalWatchlistTable::COLUMN_USER_ID => $watcherID])->run($db);
             }
         }
     }
 }
Beispiel #3
0
 * @addto maintenance
 * @author Adrian 'ADi' Wieczorek <adi(at)wikia.com>
 * @author Piotr Molski <moli(at)wikia-inc.com>
 *
 */
ini_set("include_path", dirname(__FILE__) . "/..");
require_once 'commandLine.inc';
$bDebugMode = isset($options['d']) || isset($options['debug']) ? true : false;
$aUserNames = isset($options['users']) ? explode(',', $options['users']) : array();
$aUseDB = isset($options['usedb']) ? explode(',', $options['usedb']) : array();
$bDbExistsCheck = isset($options['checkdb']) ? true : false;
$bClearMode = isset($options['clear']) ? true : false;
$bRegenMode = isset($options['regen']) ? true : false;
$sDebugMailTo = isset($options['mailto']) ? $options['mailto'] : '';
if (class_exists('GlobalWatchlistBot')) {
    $oWatchlistBot = new GlobalWatchlistBot($bDebugMode, $aUserNames, $aUseDB);
    //$oWatchlistBot->setDbExistsCheck($bDbExistsCheck);
    $oWatchlistBot->setDebugMailTo($sDebugMailTo);
    if ($bClearMode) {
        $oWatchlistBot->clear();
    } elseif ($bRegenMode) {
        $oWatchlistBot->regenerate();
    } else {
        $oWatchlistBot->run();
        //
        $oUser = User::newFromId(115748);
        //Moli.wikia
        $oUser->load();
        $oUser->sendMail('Global watchlist is finished', 'Global watchlist is finished', 'Wikia <*****@*****.**>', null, 'GlobalWatchlist');
    }
} else {
Beispiel #4
0
	public function execute() {
		if ( class_exists('GlobalWatchlistBot') ) {
			
			// defaults
			$bDebugMode = $bClearMode = $bUpdateMode = $bSendMode = $bRegenMode = false;
			$aUserNames = $aUseDB = array();
			$sDebugMailTo = $sPage = '';
			$sNamespace = null;
			
			// options
			if( $this->hasOption( 'debug' ) ) {
				$bDebugMode = true;
			} 
			
			if ( $this->hasOption( 'clear' ) ) {
				$bClearMode = true;
			} elseif ( $this->hasOption( 'update' ) ) {
				$bUpdateMode = true;
			} elseif ( $this->hasOption( 'send' ) ) {
				$bSendMode = true;
			} elseif ( $this->hasOption( 'regen' ) ) {
				$bRegenMode = true;
			}
			
			if ( $this->hasOption( 'users' ) ) {
				$aUserNames = explode( ',', $this->getOption( 'users' ) );
			} 
			if ( $this->hasOption( 'usedb' ) ) {
				$aUseDB = explode( ',', $this->getOption( 'usedb' ) );
			} 
			if ( $this->hasOption( 'mailto' ) ) {
				$sDebugMailTo = $this->getOption( 'mailto' );
			} 
			if ( $this->hasOption( 'page' ) ) {
				$sPage = $this->getOption( 'page' );
			} 
			if ( $this->hasOption( 'namespace' ) ) {
				$sNamespace = $this->getOption( 'namespace' );
			}
			
			$oWatchlistBot = new GlobalWatchlistBot( $bDebugMode, $aUserNames, $aUseDB );
			$oWatchlistBot->setDebugMailTo( $sDebugMailTo );

			if ( $bClearMode ) {
				$this->output( "Run weekly digest with --clear option ... \n" );
				$oWatchlistBot->clear();
			} elseif ( $bRegenMode ) {
				$this->output( "Run weekly digest with --regen option ... \n" );
				$oWatchlistBot->regenerate();			
			} elseif ( $bUpdateMode ) {
				$this->output( "Run weekly digest with --update option for page {$sPage} and namespace {$sNamespace} ... \n" );
				if ( !empty( $sPage ) && !is_null( $sNamespace ) ) {
					if ( ! $oWatchlistBot->updateLocalWatchlist( $sPage, $sNamespace ) ) {
						print "Update error \n"; 
						exit(1);						
					}
				} else {
					print "Invalid title \n"; 
					exit(1);
				}
			} elseif ( $bSendMode ) { 
				$this->output( "Run weekly digest with --send option for user {$this->getOption( 'users' )} ... \n" );
				if ( ! $oWatchlistBot->send() ) {
					print "Send failed \n";
					exit(1);
				}
			} else {
				$this->output( "Run weekly digest ...\n" );
				$oWatchlistBot->updateLog( );
				$emailsSent = $oWatchlistBot->run();
				//
				$oUser = User::newFromId(115748); //Moli.wikia
				$oUser->load();
				$oUser->sendMail( 'Global watchlist has finished', 'Global watchlist has finished', 'Wikia <*****@*****.**>', null, 'GlobalWatchlist' );

				$oWatchlistBot->updateLog( );
				$this->output( "Done!\n" );
			}
		}
		else {
			$this->output( "GlobalWatchlist extension is not installed.\n" );
			exit(1);
		}
	}