/** * Returns a LabelDescriptionLookup where terms are prefetched for the given * entity ids with a language fallback chain applied for the given language. * * @param Language $language * @param EntityId[] $entityIds Array of entity ids that should be prefetched. Only relevant * when a TermBuffer was set in the constructor. Default is no prefetching. * @param string[] $termTypes Array with one or more of the types 'label', 'alias' and * 'description'. Default is only 'label'. * * @return LabelDescriptionLookup */ public function newLabelDescriptionLookup(Language $language, array $entityIds = array(), array $termTypes = array('label')) { $languageFallbackChain = $this->languageFallbackChainFactory->newFromLanguage($language, $this->fallbackMode); $languages = $languageFallbackChain->getFetchLanguageCodes(); $labelDescriptionLookup = new LanguageFallbackLabelDescriptionLookup($this->termLookup, $languageFallbackChain); // Optionally prefetch the terms of the entities passed in here // $termLookup and $termBuffer should be the same BufferingTermLookup then if ($this->termBuffer !== null) { $this->termBuffer->prefetchTerms($entityIds, $termTypes, $languages); } return $labelDescriptionLookup; }
/** * @param ChangesList $list * @param ResultWrapper|array $rows * * @return bool */ public function doChangesListInitRows(ChangesList $list, $rows) { try { $titles = $this->getChangedTitles($rows); $entityIds = $this->idLookup->getEntityIds($titles); $this->buffer->prefetchTerms($entityIds, $this->termTypes, $this->languageCodes); } catch (StorageException $ex) { wfLogWarning(__METHOD__ . ': ' . $ex->getMessage()); } return true; }