This will allow us to deprecate the ParserBeforeStrip and ParserAfterStrip
hooks by covering the one case where ParserBeforeStrip is called but
ParserBeforeInternalParse is not.
Bug: T250450
Change-Id: Ia298fecba77e97fc30dc30a09ac69a4239767d8c
Originally we created a Parser object on every request, and so care
was taken to make Parser construction lightweight. In particular,
all potentially costly initialization was moved into a separate
Parser::firstCallInit() method. Starting with 1.32, parser construction
has instead been done lazily, via the ParserFactory registered with
MediaWikiServices. The extra complexity associated with the old manual
lazy initialization of Parser is therefore no longer needed.
Deprecate Parser::firstCallInit() as part of a general plan to refactor
the Parser class to allow subclasses and alternate parser implementations.
Add some tests to assert that parsers are being created lazily, and are
not being created when they are not needed.
Bug: T250444
Change-Id: Iffd2b38a2f848dad88010d243250b37506b2c715
This was overlooked in a5afda55bf, probably
because casual inspection of
https://codesearch.wmflabs.org/deployed/?q=mVariables&i=nope&files=&repos=
made it look like extensions/AbuseFilter was using Parser::$mVariables.
But AbuseFilterParser (and AbuseFilterCachingParser) is its own thing, not
a subclass of Parser, and the (re)use of the $mVariables name for the
property is just coincidence.
Change-Id: I4debb11c804b2ef4f1b727d521f38f35de691708
The following Parser methods were deprecated in favor of new methods:
- ::fetchCurrentRevisionOfTitle (use fetchCurrentRevisionRecordOfTitle)
- ::statelessFetchRevision (use statelessFetchRevisionRecord)
- ::getRevisionObject (use getRevisionRecordObject)
The following ParserOptions methods were likewise deprecated:
- ::getCurrentRevisionCallback (use getCurrentRevisionRecordCallback)
- ::setCurrentRevisionCallback (use setCurrentRevisionRecordCallback)
To ensure backwards compatibility with calling the ParserOptions
CurrentRevisionCallback methods, while allowing extensions to call
the CurrentRevisionRecordCallback methods without worrying about if
other extensions also deployed have been updated, both
::getCurrentRevisionCallback and ::getCurrentRevisionRecordCallback,
if the respective option is still set to the default, check if the
other option is set and, if it is, convert the other option rather
than returning thed default.
It's not pretty, but it works, and will be hard deprecated shortly
and removed in 1.36.
Bug: T249384
Change-Id: I66cbcb963a96cc49c75ca72faa7e439ae6d6614d
Parser::Options(), Parser::OutputType(), and Parser::Title() have been
deprecated. All of these had incomplete replacements with either a
::get* method or a ::set* method (and in the case of Title, both).
Add the missing getters or setters where required.
Only Parser::Title() has been hard deprecated. Replacing the other
uses in deployed code requires the newly-added Parser::getOutputType()
or Parser::setOptions() methods, so we can't replace those methods in
our deployed code after this patch has been merged.
Code search:
https://codesearch.wmflabs.org/deployed/?q=-%3E%28OutputType%7CTitle%7COptions%29%5C%28&i=nope&files=&repos=
Bug: T236809
Change-Id: I0b4d5f170216597afb259cedbb13b8028d284715
This setting has been effectively constant since 2008. In modern code
we should be using a ParserFactory instead to customize Parser creation
and not calling the Parser constructor directly (T236811).
Because the ParserFactory is cached, which freezes the current value of
the content language and other options, we need to reset the ParserFactory
object when running parser tests (T248977). Thanks to
Peter Ovchyn <peter.ovchyn@speedandfunction.com> for first uncovering this
issue and suggesting a fix in I4203bf7719a8555a09b72cdb5b1ae7a6e1505acf.
Code search:
https://codesearch.wmflabs.org/deployed/?q=wgParserConf&i=nope&files=&repos=https://codesearch.wmflabs.org/deployed/?q=ParserConf&i=nope&files=&repos=
Bug: T248977
Bug: T236811
Depends-On: I97d58750c91b06eeca5d810509becdf53a39cc95
Depends-On: Idf59cd54146d31c1c32883f4318e6a0bf60e1a8a
Change-Id: I787f22ea9bf59a049b13631ba6974866a1300988
Disabling tidy has been deprecated since 1.33. This cleans up the code
paths which still used untidy output.
Bug: T198214
Change-Id: I821ef3b8f59b272d983583d407b2f0794fe1e791
This allows them to be more easily reused by other Parser implementations
(ie, Parsoid), and helps keep Parser.php compact.
Bug: T236813
Change-Id: I68fb1e786374e445b7df047934c532d7e10b8e94
We formally deprecated running the parser with tidy disabled in 1.33, but
I missed a hard-deprecation on this code path.
Be careful not to spam the logs with deprecation warnings triggered by
(deprecated) API requests, though.
Change-Id: I10f64e76ec0c5aee8b26fc00bc11ebb0e39f961b
This is preparatory work for I28e88e574ec9f99231bd590e9a87fbc1c4349fa1
which simply splits comma-separated lists into individual lines and
does minor documentation tweaks, so that the main body of the follow-up
patch is easier to review.
Bug: T248889
Change-Id: I196d047ce694fe0e8447bd96455c7fb1b75247e4
The reset state of the Parser $mStripList was made a public field,
presumably so it could be customized by extensions? But nobody seems
to have ever used this. Remove this unnecessary extension point.
Code search:
https://codesearch.wmflabs.org/search/?q=mDefaultStripList&i=nope&files=&repos=
Bug: T248889
Change-Id: I10fa521f62e6b9696ab6b96bcf7eb05091b35022
Ensure that the value returned is always also added to the cache, since
we (eventually) want to remove the hook's access to
$parser->mVarCache. Also don't allow monkeying with the value passed
as $magicWordId, even though it's a reference.
Code search:
https://codesearch.wmflabs.org/deployed/?q=ParserGetVariableValueSwitch&i=nope&files=&repos=
Bug: T236813
Depends-On: Ia12faefada7e4cf04f1a6b12b3ed1703bf28e437
Depends-On: Ia9e2e00c6b7d0e62cbe80c3b124165b691b1ff3d
Depends-On: I1e48fa47b8723958d543a69aaf9b62b872200dc5
Depends-On: If9a0885a8664c22473ade712364c2dd0a5c04e0b
Change-Id: I3d6b281f8e4e0bf68eefbf9767047527b4573b79
The existing magic word API (including hooks) gives implementers direct
access to $parser->mVarCache and full control of caching. Simplify the
implementation (prior to moving the magic word implementations out of
Parser.php) by always caching built-in magic words in $parser->mVarCache.
The cases which were skipping the cache don't vary anyway.
This behavior change is split from the rest of the refactoring in
I68fb1e786374e445b7df047934c532d7e10b8e94 to allow it to be deployed
separately, just in case there was some strange reason this would
cause regressions in practice.
Bug: T236813
Change-Id: I34a0d9a37e41c854c801d546427fc8cd0fe39dc4
All existing uses in our codebase are to OutputPage::enableOOUI.
Further, the implementation here in Parser::enableOOUI calls
OutputPage::setupOOUI() without arguments, which means that the skin
and the page directionality are not initialized correctly.
(OutputPage::enableOOUI() does this correctly). So even if anyone
*was* using Parser::enableOOUI... they shouldn't be.
Use $parser->getOutput()->enableOOUI() instead.
This was originally added in 2d50e28975 to
enable OOUI to be used from parser tags (T101666), but the current patches
for this (eg I29e876c768819413bf31499f067d545732e591b0) can just use
$parser->getOutput()->enableOOUI() instead.
Code search:
https://codesearch.wmflabs.org/search/?q=enableOOUI&i=nope&files=&repos=
Bug: T236809
Change-Id: I71be19c1d735fef5b781c68ef7ba47cafc37595d
This is needed to migrate an extension (AutoWIGO2) that uses ArticleSave
to a version of MW after that hook was removed. The extension was using
ArticleSave to do its own PST processing, which probably doesn't work
with PageContentSave, and wasn't really the right way to do it in the
first place. Surprisingly, there were no useful hooks in PST or its
callers.
Change-Id: If1b3d7ea130a2b77609afe206eedc8445e1ab9f9
As long as no parsing was started, and $this->startParse() was not
triggered at least once, the $this->mOptions property is null. This
does have a lot of consequences. I'm intentionally not fixing all of
them in this patch to not make it to big, only the most obvious ones.
This came up in I6714400 which was actually running into this issue.
This patch also removes a few comments that *literally* repeat what
the code already says. Such comments are not helpful, but clutter the
code, make it harder to read, and create error-prone redundancy.
Change-Id: Ic1ab18242b2f79d3da2a2e7c25e3af3e6907f7b4
isset() does two things: It checks if a variable (or array element)
is declared, *and* it checks if it is null. If a variable is null,
isset() fails as if the variable was not set. All these additional
null checks are dead code.
Change-Id: I71e8cc26dac839c9d081bf00b4164b7b5147e586
Follows-up d4045035b0.
This class was added to the MediaWiki\Special namespace, contrary to the
plan in T166010 which reserves that namespace for core special pages.
Instead, use MediaWiki\SpecialPage, following the directory in which it
is located.
Also, fix two bugs which prevented the introduction of a namespaced
class alias.
Bug: T166010
Change-Id: I6e31340aaae32a89beb7e45b79d76a7fea9808d2
1. into class Parser
2. into class LinkHoderArray
3. into class DefaultPreferencesFactory
Add more tests for DefaultPreferencesFactory:
1. testVariantsSupport verifies that converter with variants is used correctly.
2. Test testUserGroupMemberships verifies that membership is used correctly
Bug: T243320, T243321, T243317
Change-Id: I1e5c37e18332d0d32391c74c06e3d84862e48df8
Done:
* Replace LanguageConverter::newConverter by LanguageConverterFactory::getLanguageConverter
* Remove LanguageConverter::newConverter from all subclasses
* Add LanguageConverterFactory integration tests which covers all languages by their code.
* Caching of LanguageConverters in factory
* Make all tests running (hope that's would be enough)
* Uncomment the deprecated functions.
* Rename FakeConverter to TrivialLanguageConverter
* Create ILanguageConverter to have shared ancestor
* Make the LanguageConverter class abstract.
* Create table with mapping between lang code and converter instead of using name convention
* ILanguageConverter @internal
* Clean up code
Change-Id: I0e4d77de0f44e18c19956a1ffd69d30e63cf51bf
Bug: T226833, T243332
Parser::magicLinkCallback() and Parser::makeFreeExternalLink() are not
called from outside the parser and have been made private.
Parser::attributeStripCallback() did have one use outside MediaWiki core,
so it has been deprecated rather than made private. The one use inside
the parser has been converted to an anonymous callback.
Code search:
https://codesearch.wmflabs.org/search/?q=magicLinkCallback%7CmakeFreeExternalLink%7CattributeStripCallback&i=nope&files=&repos=
Change-Id: Id909b745f9dea1481d09de4747f4aa32648bf85b
This is an odd "partial parse" endpoint which won't be supported by
the unified Parsoid parser. Most places it appears in our codebase
it is just a name-check, mostly complaining about how broken it is.
It is not called by any WMF-deployed code.
Code search:
https://codesearch.wmflabs.org/search/?q=doBlockLevels&i=fosho&files=&repos=
Change-Id: Iad2a1e5ed593c1f6299b8b45e4390b415537c84c
This reduces the API surface of Parser, in preparation for further
refactoring of the Parser class. Parser::fetchTemplateAndTitle() was
introduced in MW 1.6.0 in 2007, so is always appropriate as a replacement.
Code search:
https://codesearch.wmflabs.org/search/?q=fetchTemplate%5C%28&i=nope&files=&repos=
Depends-On: I2865b12b55aa1412a861fb8db10239018a1d1580
Change-Id: I6f7c3e31ff394781fbaaef267a2772de05f85bf2