diff options
author | jenkins-bot <jenkins-bot@gerrit.wikimedia.org> | 2025-01-28 16:17:44 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@wikimedia.org> | 2025-01-28 16:17:44 +0000 |
commit | c64b2ac9bccaf5bc81878cd5aefd37900aa0c6a4 (patch) | |
tree | 9be3392fea6458c0e3b69389e4976f9b7ffd17ac /includes/parser | |
parent | 44ca2d893a20959c6a0835548e2325336bbd4ca3 (diff) | |
parent | db00055a0765eb4dc9f11ed563bb767925ca404f (diff) | |
download | mediawikicore-c64b2ac9bccaf5bc81878cd5aefd37900aa0c6a4.tar.gz mediawikicore-c64b2ac9bccaf5bc81878cd5aefd37900aa0c6a4.zip |
Merge "fix(Parser): Fix LinkTarget/PageReference confusion, strengthen types"
Diffstat (limited to 'includes/parser')
-rw-r--r-- | includes/parser/Parser.php | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index a200338f20f3..b2a1cb6440b8 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3506,6 +3506,10 @@ class Parser { * Get the semi-parsed DOM representation of a template with a given title, * and its redirect destination title. Cached. * + * The second element of the returned array may be a Title object, or may be + * the passed `$title` parameter, so if you need a `Title`, pass it a `Title` + * rather than a TitleValue. + * * @param LinkTarget $title * @param bool $inSolState Is the template processing starting in Start-Of-Line (SOL) position? * Prepreprocessing (on behalf of Parsoid) uses this flag to set lineStart property on @@ -3513,7 +3517,7 @@ class Parser { * this flag is a best guess since {{expands-to-empty-string}} can blind it to SOL context. * This flag is always false for legacy parser template expansions. * - * @return array + * @return array{0:PPNode|false,1:LinkTarget} [Template DOM, final template title] * @since 1.12 */ public function getTemplateDom( LinkTarget $title, bool $inSolState = false ) { @@ -3546,7 +3550,7 @@ class Parser { $dom = $this->preprocessToDom( $text, $flags ); $this->mTplDomCache[$titleKey] = $dom; - if ( !$title->isSamePageAs( $cacheTitle ) ) { + if ( !$title->isSameLinkAs( $cacheTitle ) ) { $this->mTplRedirCache[ CacheKeyHelper::getKeyForPage( $cacheTitle ) ] = [ $title->getNamespace(), $title->getDBkey() ]; } @@ -3633,7 +3637,7 @@ class Parser { /** * Fetch the unparsed text of a template and register a reference to it. * @param LinkTarget $link - * @return array ( string or false, Title ) + * @return array{0:string|false,1:Title} * @since 1.11 */ public function fetchTemplateAndTitle( LinkTarget $link ) { |