/**
  * Initiates some needed classes.
  *
  * @access	public
  * @return	void
  */
 public static function init()
 {
     if (!self::$initialized) {
         global $dsSiteKey;
         self::$siteKey = $dsSiteKey;
         self::$DB = wfGetDB(DB_MASTER);
         self::$redis = RedisCache::getClient('cache');
         self::$initialized = true;
     }
 }
 /**
  * Main Executor
  *
  * @access	public
  * @param	string	Sub page passed in the URL.
  * @return	void	[Outputs to screen]
  */
 public function execute($subpage)
 {
     if ($this->wgUser->isAnon()) {
         $this->output->showErrorPage('globalwatchlist_error', 'error_gwl_logged_out');
         return;
     }
     $this->redis = RedisCache::getClient('cache');
     $this->templateGlobalWatchlist = new TemplateGlobalWatchlist();
     $this->output->addModules('ext.globalwatchlist');
     $this->setHeaders();
     switch ($subpage) {
         default:
         case 'globalwatchlist':
             $this->globalWatchlist();
             break;
         case 'settings':
             $this->globalWatchlistSettings();
             break;
     }
     $this->output->addHTML($this->content);
 }
Ejemplo n.º 3
0
 /**
  * In the event of a catastrophic Redis failure this script can be ran to populate all the backed up data on the master database back into Redis.
  *
  * @access	public
  * @return	void
  */
 public function execute()
 {
     $this->DB = wfGetDB(DB_MASTER);
     $this->redis = RedisCache::getClient('cache');
     /******************************/
     /* Lists                      */
     /******************************/
     $result = $this->DB->select(['gwl_watchlist'], ['count(*) as items'], null, __METHOD__);
     $total = $result->fetchRow();
     for ($i = 0; $i <= $total['items']; $i += 100) {
         $result = $this->DB->select(['gwl_watchlist'], ['*'], null, __METHOD__, ['OFFSET' => $i, 'LIMIT' => 100]);
         while ($row = $result->fetchRow()) {
             if ($row['global_id'] < 1 || empty($row['site_key'])) {
                 continue;
             }
             $this->redis->hSet('globalwatchlist:list:' . $row['global_id'], $row['site_key'], $row['list']);
         }
     }
     /******************************/
     /* Settings                   */
     /******************************/
     $result = $this->DB->select(['gwl_settings'], ['count(*) as items'], null, __METHOD__);
     $total = $result->fetchRow();
     for ($i = 0; $i <= $total['items']; $i += 100) {
         $result = $this->DB->select(['gwl_settings'], ['*'], null, __METHOD__, ['OFFSET' => $i, 'LIMIT' => 100]);
         while ($row = $result->fetchRow()) {
             if ($row['global_id'] < 1 || empty($row['site_keys'])) {
                 continue;
             }
             $this->redis->del($this->redisSitesKey);
             $siteKeys = unserialize($row['site_keys']);
             array_unshift($siteKeys, 'globalwatchlist:visibleSites:' . $row['global_id']);
             call_user_func_array([$this->redis, 'sAdd'], $siteKeys);
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * Constructor
  *
  * @access	public
  * @param	array	Configuration
  * @return	void
  */
 public function __construct()
 {
     global $dsSiteKey;
     $this->siteKey = $dsSiteKey;
     $this->redis = RedisCache::getClient('cache');
 }