Exemplo n.º 1
0
 /**
  * Purge expired restrictions from the flaggedpage_config table.
  * The stable version of pages may change and invalidation may be required.
  */
 public static function purgeExpiredConfigurations()
 {
     if (wfReadOnly()) {
         return;
     }
     $dbw = wfGetDB(DB_MASTER);
     # Find pages with expired configs...
     $config = self::getDefaultVisibilitySettings();
     // config is to be reset
     $encCutoff = $dbw->addQuotes($dbw->timestamp());
     $ret = $dbw->select(array('flaggedpage_config', 'page'), array('fpc_page_id', 'page_namespace', 'page_title'), array('page_id = fpc_page_id', 'fpc_expiry < ' . $encCutoff), __METHOD__);
     # Figured out to do with each page...
     $pagesClearConfig = array();
     $pagesClearTracking = $titlesClearTracking = array();
     foreach ($ret as $row) {
         # If FlaggedRevs got "turned off" (in protection config)
         # for this page, then clear it from the tracking tables...
         if (FlaggedRevs::useOnlyIfProtected() && !$config['override']) {
             $pagesClearTracking[] = $row->fpc_page_id;
             // no stable version
             $titlesClearTracking[] = Title::newFromRow($row);
             // no stable version
         }
         $pagesClearConfig[] = $row->fpc_page_id;
         // page with expired config
     }
     # Clear the expired config for these pages...
     if (count($pagesClearConfig)) {
         $dbw->delete('flaggedpage_config', array('fpc_page_id' => $pagesClearConfig, 'fpc_expiry < ' . $encCutoff), __METHOD__);
     }
     # Clear the tracking rows and update page_touched for the
     # pages in $pagesClearConfig that do now have a stable version...
     if (count($pagesClearTracking)) {
         FlaggedRevs::clearTrackingRows($pagesClearTracking);
         $dbw->update('page', array('page_touched' => $dbw->timestamp()), array('page_id' => $pagesClearTracking), __METHOD__);
     }
     # Also, clear their squid caches and purge other pages that use this page.
     # NOTE: all of these updates are deferred via $wgDeferredUpdateList.
     foreach ($titlesClearTracking as $title) {
         FlaggedRevs::purgeSquid($title);
         if (FlaggedRevs::inclusionSetting() == FR_INCLUDES_STABLE) {
             FlaggedRevs::HTMLCacheUpdates($title);
             // purge pages that use this page
         }
     }
 }
 /**
  * (a) Update flaggedrevs page/tracking tables
  * (b) Pages with stable versions that use this page will be purged
  * Note: pages with current versions that use this page should already be purged
  */
 public static function onArticleDelete(Page $article, $user, $reason, $id)
 {
     FlaggedRevs::clearTrackingRows($id);
     FlaggedRevs::extraHTMLCacheUpdate($article->getTitle());
     return true;
 }