/**
  * Loads incoming redirects referring to the given entity ID.
  *
  * @param EntityId $id
  *
  * @return EntityId[]
  * @throws HttpError
  */
 private function getIncomingRedirects(EntityId $id)
 {
     try {
         return $this->entityRedirectLookup->getRedirectIds($id);
     } catch (EntityRedirectLookupException $ex) {
         $prefixedId = $id->getSerialization();
         wfDebugLog(__CLASS__, __FUNCTION__ . ": failed to load incoming redirects of {$prefixedId}: {$ex}");
         return array();
     }
 }
コード例 #2
0
 /**
  * @param EntityId $entityId
  *
  * @throws RedirectCreationException
  */
 private function checkExistsNoRedirect(EntityId $entityId)
 {
     try {
         $redirect = $this->entityRedirectLookup->getRedirectForEntityId($entityId, 'for update');
     } catch (EntityRedirectLookupException $ex) {
         throw new RedirectCreationException($ex->getMessage(), 'no-such-entity', $ex);
     }
     if ($redirect !== null) {
         throw new RedirectCreationException("Entity {$entityId} is a redirect", 'target-is-redirect');
     }
 }
コード例 #3
0
 /**
  * Load the sitelink using a SiteLinkLookup. Resolves item redirects, if needed.
  *
  * @param string $site
  * @param ItemId $itemId
  *
  * @return array[]
  */
 private function loadLinks($site, ItemId $itemId)
 {
     $links = $this->siteLinkLookup->getLinks(array($itemId->getNumericId()), array($site));
     if (isset($links[0])) {
         return $links;
     }
     // Maybe the item is a redirect: Try to resolve the redirect and load
     // the links from there.
     $redirectTarget = $this->redirectLookup->getRedirectForEntityId($itemId);
     if ($redirectTarget instanceof ItemId) {
         return $this->siteLinkLookup->getLinks(array($redirectTarget->getNumericId()), array($site));
     }
     return array();
 }