diff options
author | C. Scott Ananian <cscott@cscott.net> | 2020-05-06 12:38:07 -0400 |
---|---|---|
committer | C. Scott Ananian <cscott@cscott.net> | 2020-05-06 12:44:05 -0400 |
commit | 2712cb8330d8e9b4755d89b6909c5589ee6da8d3 (patch) | |
tree | be1904e8dd1daf6ac2b99ed96aca3e93b1eedd66 /includes/parser | |
parent | a449c5005ba3992e3f8f773c1778369f95d20b90 (diff) | |
download | mediawikicore-2712cb8330d8e9b4755d89b6909c5589ee6da8d3.tar.gz mediawikicore-2712cb8330d8e9b4755d89b6909c5589ee6da8d3.zip |
Fix impedance mismatch with Parser::getRevisionRecordObject()
Parser::getRevisionRecordObject() returns `null` if the revision is
missing, but it invokes ParserOptions::getCurrentRevisionRecordCallback()
(ie, Parser::statelessFetchRevisionRecord() by default) which returns
`false` as its error condition.
This reverts commit ae74a29af3116eb73a4cb775736b3acee0a65c59, and instead
fixes the bug at its root.
Bug: T251952
Change-Id: If36b35391f7833a1aded8b5a0de706d44187d423
Diffstat (limited to 'includes/parser')
-rw-r--r-- | includes/parser/CoreParserFunctions.php | 4 | ||||
-rw-r--r-- | includes/parser/Parser.php | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index 427c8ca7857c..a96d873a3b62 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -1394,9 +1394,7 @@ class CoreParserFunctions { } // fetch revision from cache/database and return the value $rev = self::getCachedRevisionObject( $parser, $t, 'vary-user' ); - - // TODO what can getCachedRevisionObject return other than RevisionRecord and null - if ( !( $rev instanceof RevisionRecord ) ) { + if ( $rev === null ) { return ''; } $user = $rev->getUser(); diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index e9698527167e..92c0c2df4659 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -5778,6 +5778,14 @@ class Parser { $this ); + if ( $rev === false ) { + // The revision record callback returns `false` (not null) to + // indicate that the revision is missing. (See for example + // Parser::statelessFetchRevisionRecord(), the default callback.) + // This API expects `null` instead. (T251952) + $rev = null; + } + if ( $this->mRevisionId === null && $rev && $rev->getId() ) { // We are in preview mode (mRevisionId is null), and the current revision callback // returned an existing revision. Ignore it and return null, it's probably the page's |