/**
  * @see UsageLookup::getUsagesForPage
  *
  * @param int $pageId
  *
  * @return EntityUsage[]
  * @throws UsageTrackerException
  */
 public function getUsagesForPage($pageId)
 {
     $usages = array();
     $title = $this->titleFactory->newFromID($pageId);
     $id = $this->siteLinkLookup->getItemIdForLink($this->clientSiteId, $title->getPrefixedText());
     if ($id !== null) {
         $usages[] = new EntityUsage($id, EntityUsage::SITELINK_USAGE);
     }
     return $usages;
 }
 public function testNewFromID()
 {
     $orignalTitle = $this->makePage('TitleFactoryTest-testNewFromID');
     $pageId = $orignalTitle->getArticleID();
     $factory = new TitleFactory();
     $title = $factory->newFromID($pageId);
     $this->assertEquals($orignalTitle->getFullText(), $title->getFullText());
 }
 /**
  * @param int[] $pageIds
  *
  * @return Title[]
  */
 private function getTitlesForPageIds(array $pageIds)
 {
     $titles = array();
     foreach ($pageIds as $id) {
         try {
             $title = $this->titleFactory->newFromID($id);
             $titles[] = $title;
         } catch (Exception $ex) {
             // No title for that ID, maybe the page got deleted just now.
         }
     }
     return $titles;
 }
 /**
  * Filters updates based on namespace. This removes duplicates, non-existing pages, and pages from
  * namespaces that are not considered "enabled" by the namespace checker.
  *
  * @param Traversable $usages A traversable of PageEntityUsages.
  *
  * @return ArrayIterator of PageEntityUsages
  */
 private function filterUpdates(Traversable $usages)
 {
     $titlesToUpdate = array();
     /** @var PageEntityUsages $pageEntityUsages */
     foreach ($usages as $pageEntityUsages) {
         try {
             $title = $this->titleFactory->newFromID($pageEntityUsages->getPageId());
         } catch (StorageException $ex) {
             // page not found, skip
             continue;
         }
         if ($this->checkPageExistence && !$title->exists()) {
             continue;
         }
         $key = $pageEntityUsages->getPageId();
         $titlesToUpdate[$key] = $pageEntityUsages;
     }
     return new ArrayIterator($titlesToUpdate);
 }