/**
  * Main entry point for handling changes
  *
  * @todo: process multiple changes at once!
  *
  * @since 0.1
  *
  * @param Change $change
  *
  * @throws MWException
  */
 public function handleChange(Change $change)
 {
     $changeId = $this->getChangeIdForLog($change);
     wfDebugLog(__CLASS__, __FUNCTION__ . ": handling change #{$changeId}" . ' (' . $change->getType() . ')');
     $usagesPerPage = $this->affectedPagesFinder->getAffectedUsagesByPage($change);
     wfDebugLog(__CLASS__, __FUNCTION__ . ': updating ' . count($usagesPerPage) . " page(s) for change #{$changeId}.");
     $actionBuckets = array();
     /** @var PageEntityUsages $usages */
     foreach ($usagesPerPage as $usages) {
         $actions = $this->getUpdateActions($usages->getAspects());
         $this->updateActionBuckets($actionBuckets, $usages->getPageId(), $actions);
     }
     foreach ($actionBuckets as $action => $bucket) {
         $this->applyUpdateAction($action, $bucket, $change);
     }
 }
 public function testGetAffectedUsagesByPage_withDeletedPage()
 {
     $pageTitle = 'RandomKitten-2x5jsg8j3bvmpm4!5';
     $affectedPagesFinder = new AffectedPagesFinder($this->getSiteLinkUsageLookup($pageTitle), new TitleFactory(), 'enwiki', 'en', false);
     $itemId = new ItemId('Q1');
     $changeFactory = TestChanges::getEntityChangeFactory();
     $change = $changeFactory->newFromUpdate(ItemChange::UPDATE, $this->getItemWithSiteLinks($itemId, array('enwiki' => $pageTitle)), new Item($itemId));
     $usages = $affectedPagesFinder->getAffectedUsagesByPage($change);
     $this->assertCount(0, $usages);
 }