Ejemplo n.º 1
0
 /**
  * Dump list of entities
  *
  * @param EntityId[] $entityIds
  * @param int &$dumpCount The number of entities already dumped (will be updated).
  */
 private function dumpEntities(array $entityIds, &$dumpCount)
 {
     $toLoad = array();
     foreach ($entityIds as $entityId) {
         if ($this->idMatchesFilters($entityId)) {
             $toLoad[] = $entityId;
         }
     }
     $this->entityPrefetcher->prefetch($toLoad);
     foreach ($toLoad as $entityId) {
         try {
             $data = $this->generateDumpForEntityId($entityId);
             if (!$data) {
                 continue;
             }
             $this->preEntityDump($dumpCount);
             $this->writeToDump($data);
             $this->postEntityDump($dumpCount);
             $dumpCount++;
             if ($this->limit && $dumpCount >= $this->limit) {
                 break;
             }
         } catch (EntityLookupException $ex) {
             $this->exceptionHandler->handleException($ex, 'failed-to-dump', 'Failed to dump ' . $entityId);
         } catch (StorageException $ex) {
             $this->exceptionHandler->handleException($ex, 'failed-to-dump', 'Failed to dump ' . $entityId);
         }
     }
 }
 /**
  * @param EntityId[] $entityIds
  * @param bool $resolveRedirects
  *
  * @return EntityRevision[]
  */
 private function getEntityRevisionsFromEntityIds($entityIds, $resolveRedirects = false)
 {
     $revisionArray = array();
     $this->entityPrefetcher->prefetch($entityIds);
     foreach ($entityIds as $entityId) {
         $sourceEntityId = $entityId->getSerialization();
         $entityRevision = $this->getEntityRevision($entityId, $resolveRedirects);
         $revisionArray[$sourceEntityId] = $entityRevision;
     }
     return $revisionArray;
 }
 /**
  * Rebuilds EntityPerPageTable for specified pages
  *
  * @param ItemId[] $itemIds
  *
  * @return int
  */
 private function rebuildSiteLinks(array $itemIds)
 {
     $this->entityPrefetcher->prefetch($itemIds);
     $c = 0;
     foreach ($itemIds as $itemId) {
         if (!$itemId instanceof ItemId) {
             // Just in case someone is using a EntityIdPager which doesn't filter non-Items
             continue;
         }
         $item = $this->entityLookup->getEntity($itemId);
         if (!$item) {
             continue;
         }
         $ok = $this->siteLinkTable->saveLinksOfItem($item);
         if (!$ok) {
             $this->report('Saving sitelinks for Item ' . $item->getId()->getSerialization() . ' failed');
         }
         $c++;
     }
     // Wait for the slaves, just in case we e.g. hit a range of ids which need a lot of writes.
     wfWaitForSlaves();
     return $c;
 }