diff options
author | Tim Starling <tstarling@wikimedia.org> | 2025-02-17 12:36:00 +1100 |
---|---|---|
committer | Tim Starling <tstarling@wikimedia.org> | 2025-02-21 12:01:38 +1100 |
commit | 1edccf294ac00b304400738a812358e6da252403 (patch) | |
tree | 0f414904640a00b0739fae9a83226c2f640f1eb3 /tests/parser/ParserTestRunner.php | |
parent | c40e70a6f8368fc6785c35c739748e5e8d83a47d (diff) | |
download | mediawikicore-1edccf294ac00b304400738a812358e6da252403.tar.gz mediawikicore-1edccf294ac00b304400738a812358e6da252403.zip |
Split MessageParser out of MessageCache
MessageCache has enough to do without also being a parser. Split a
MessageParser class out of MessageCache and make it a service.
* MessageCache::parseWithPostprocessing() becomes MessageParser::parse()
because every caller wants postprocessing so it makes sense to use the
shorter name for this.
* MessageCache::parse() becomes MessageParser
::parseWithoutPostprocessing(). I changed the return type from
ParserOutput|string to ParserOutput, which is a followup to
I8a1fa84e650d920d07d74722d8059d5afeedec6b. Narrowing the return type
does not break b/c so it is possible to make this change for both
variants.
* In the new methods, a null title is always a convenience alias for a
placeholder title (Special:Badtitle). This reflects the convention in
Parser::setPage(). The old MessageCache::parse() retains its b/c
fallback to $wgTitle. MessageCache::transform() had the potential to
fall back to the title used in the previous call, a fragile mechanism
which I removed without deprecation.
* For consistency, allow a string language in all new methods.
* In EmailNotification, clean up an early attempt at global state
avoidance.
Change-Id: I05ab21508d5f8394189fd41ac6a2254ac0e0d785
Diffstat (limited to 'tests/parser/ParserTestRunner.php')
-rw-r--r-- | tests/parser/ParserTestRunner.php | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index 6f7dc2a5fe5f..22ea255b8d10 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -2944,13 +2944,9 @@ class ParserTestRunner { } // Optionally use mock parser, to make debugging of actual parser tests simpler. - // But initialise the MessageCache clone first, don't let MessageCache - // get a reference to the mock object. + // But initialise the MessageParser first so that it gets the original ParserFactory. if ( $this->disableSaveParse ) { - $services->getMessageCache()->parse( '', PageReferenceValue::localReference( - NS_SPECIAL, - 'Badtitle/title not set in ' . __METHOD__ - ) ); + $services->getMessageCache(); $services->disableService( 'Parser' ); $services->disableService( 'ParserFactory' ); $services->redefineService( |