X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiPageSet.php;h=e68676a94e8e40fd10818010352d4b77762cf1a6;hp=c604322ed2063d4bb837382ea8aa52db675077d3;hb=91fd689add2a4067d3e306fd0a5a2d8a6ffaff1b;hpb=c1e9d63dfd68dcc1343840eaa8a395234ccba104 diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index c604322ed2..e68676a94e 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -77,6 +77,7 @@ class ApiPageSet extends ApiBase { private $mGeneratorData = []; // [ns][dbkey] => data array private $mFakePageId = -1; private $mCacheMode = 'public'; + /** @var array */ private $mRequestedPageFields = []; /** @var int */ private $mDefaultNamespace = NS_MAIN; @@ -1165,7 +1166,8 @@ class ApiPageSet extends ApiBase { $services = MediaWikiServices::getInstance(); $contLang = $services->getContentLanguage(); - foreach ( $titles as $title ) { + $titleObjects = []; + foreach ( $titles as $index => $title ) { if ( is_string( $title ) ) { try { $titleObj = Title::newFromTextThrow( $title, $this->mDefaultNamespace ); @@ -1184,6 +1186,16 @@ class ApiPageSet extends ApiBase { } else { $titleObj = $title; } + + $titleObjects[$index] = $titleObj; + } + + // Get gender information + $genderCache = $services->getGenderCache(); + $genderCache->doTitlesArray( $titleObjects, __METHOD__ ); + + foreach ( $titleObjects as $index => $titleObj ) { + $title = is_string( $titles[$index] ) ? $titles[$index] : false; $unconvertedTitle = $titleObj->getPrefixedText(); $titleWasConverted = false; if ( $titleObj->isExternal() ) { @@ -1196,7 +1208,7 @@ class ApiPageSet extends ApiBase { ) { // Language::findVariantLink will modify titleText and titleObj into // the canonical variant if possible - $titleText = is_string( $title ) ? $title : $titleObj->getPrefixedText(); + $titleText = $title !== false ? $title : $titleObj->getPrefixedText(); $contLang->findVariantLink( $titleText, $titleObj ); $titleWasConverted = $unconvertedTitle !== $titleObj->getPrefixedText(); } @@ -1244,24 +1256,13 @@ class ApiPageSet extends ApiBase { if ( $titleWasConverted ) { $this->mConvertedTitles[$unconvertedTitle] = $titleObj->getPrefixedText(); // In this case the page can't be Special. - if ( is_string( $title ) && $title !== $unconvertedTitle ) { + if ( $title !== false && $title !== $unconvertedTitle ) { $this->mNormalizedTitles[$title] = $unconvertedTitle; } - } elseif ( is_string( $title ) && $title !== $titleObj->getPrefixedText() ) { + } elseif ( $title !== false && $title !== $titleObj->getPrefixedText() ) { $this->mNormalizedTitles[$title] = $titleObj->getPrefixedText(); } - - // Need gender information - if ( - $services->getNamespaceInfo()-> - hasGenderDistinction( $titleObj->getNamespace() ) - ) { - $usernames[] = $titleObj->getText(); - } } - // Get gender information - $genderCache = $services->getGenderCache(); - $genderCache->doQuery( $usernames, __METHOD__ ); return $linkBatch; }