/**
  * Prunes the wb_changes table.
  */
 public function prune()
 {
     while (true) {
         wfWaitForSlaves();
         $until = $this->getCutoffTimestamp();
         $this->messageReporter->reportMessage(date('H:i:s') . " pruning entries older than " . wfTimestamp(TS_ISO_8601, $until));
         $affected = $this->pruneChanges($until);
         $this->messageReporter->reportMessage(date('H:i:s') . " {$affected} rows pruned.");
         if ($affected === 0) {
             break;
         }
     }
 }
 /**
  * Fill the usage table with rows based on entries in page_props.
  *
  * @param int $fromPageId
  */
 public function fillUsageTable($fromPageId = 0)
 {
     do {
         $count = $this->processUsageBatch($fromPageId);
         $this->progressReporter->reportMessage("Filling usage table: processed {$count} pages, starting with page #{$fromPageId}.");
     } while ($count > 0);
 }
 /**
  * @param DatabaseBase $db
  * @param array &$continuation
  *
  * @return array[] An associative array mapping item IDs to lists of site IDs.
  */
 private function getSubscriptionsPerItemBatch(DatabaseBase $db, &$continuation = array())
 {
     if (empty($continuation)) {
         $continuationCondition = '1';
     } else {
         list($fromItemId, $fromRowId) = $continuation;
         $continuationCondition = 'ips_item_id > ' . (int) $fromItemId . ' OR ( ' . 'ips_item_id = ' . (int) $fromItemId . ' AND ' . 'ips_row_id > ' . $fromRowId . ' )';
     }
     $res = $db->select('wb_items_per_site', array('ips_row_id', 'ips_item_id', 'ips_site_id'), $continuationCondition, __METHOD__, array('LIMIT' => $this->batchSize, 'ORDER BY' => 'ips_item_id, ips_row_id'));
     if ($this->verbosity === 'verbose') {
         $this->progressReporter->reportMessage('Selected ' . $res->numRows() . ' wb_item_per_site records' . ' with continuation: ' . $continuationCondition);
     }
     return $this->getSubscriptionsPerItemFromRows($res, $continuation);
 }
 /**
  * Remove subscriptions for entities not present in in wbc_entity_usage.
  *
  * @param EntityId|null $startEntity The entity to start with.
  */
 public function purgeSubscriptions(EntityId $startEntity = null)
 {
     $continuation = $startEntity === null ? null : array($startEntity->getSerialization());
     $this->repoConnectionManager->forceMaster();
     while (true) {
         wfWaitForSlaves(null, $this->repoWiki);
         $count = $this->processDeletionBatch($continuation);
         if ($count > 0) {
             $this->progressReporter->reportMessage('Purging subscription table: ' . "deleted {$count} subscriptions, continuing at entity #{$continuation[0]}.");
         } else {
             break;
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * Generates a dump, writing to the file handle provided to the constructor.
  *
  * @param EntityIdPager $idPager an Iterator that returns EntityId instances
  */
 public function generateDump(EntityIdPager $idPager)
 {
     $dumpCount = 0;
     $this->preDump();
     // Iterate over batches of IDs, maintaining the current position of the pager in the $position variable.
     while (true) {
         $ids = $idPager->fetchIds($this->batchSize);
         if (!$ids) {
             break;
         }
         $this->dumpEntities($ids, $dumpCount);
         $this->progressReporter->reportMessage('Processed ' . $dumpCount . ' entities.');
         if ($this->limit && $dumpCount >= $this->limit) {
             break;
         }
     }
     $this->postDump();
 }
 /**
  * reports a message
  *
  * @since 0.4
  *
  * @param string $msg
  */
 protected function report($msg)
 {
     if ($this->reporter) {
         $this->reporter->reportMessage($msg);
     }
 }
 private function log($message)
 {
     wfDebugLog(__CLASS__, $message);
     $this->messageReporter->reportMessage($message);
 }
 private function log($message)
 {
     $this->messageReporter->reportMessage($message);
 }
 /**
  * @param string $msg
  */
 private function reportMessage($msg)
 {
     if ($this->reporter) {
         $this->reporter->reportMessage($msg);
     }
 }
 /**
  * Reports the exception to the MessageReporter defined in the constructor call.
  *
  * @see ExceptionHandler::handleException()
  *
  * @param Exception $exception
  * @param string $errorCode
  * @param string $explanation
  */
 public function handleException(Exception $exception, $errorCode, $explanation)
 {
     $msg = $exception->getMessage();
     $msg = '[' . $errorCode . ']: ' . $explanation . ' (' . $msg . ')';
     $this->reporter->reportMessage($msg);
 }