Commit graph

1969 commits

Author SHA1 Message Date
Peter Ovchyn
f136c2953c languages: More doc annotations for LanguageConverter related classes
Deprecated LinkHolderArray for public usage

Bug: T244709
Change-Id: Ic5b9e9237044b56cbb64e7c762f5d2de3b1de821
2020-02-11 17:32:12 +02:00
Peter Ovchyn
50e3bd4fac parser: Inject a LanguageConverterFactory through DI containers:
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
2020-02-04 14:42:03 +02:00
Peter Ovchyn
61e0908fa2 languages: Introduce LanguageConverterFactory
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
2020-02-03 11:38:03 +02:00
C. Scott Ananian
a20d4094f8 Deprecate/make private internal callbacks invoked inside Parser.php
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
2020-01-30 14:00:36 -05:00
C. Scott Ananian
70c4ea9b1a Make private Parser::incrementIncludeSize(), which is not used outside the class
Code search:
https://codesearch.wmflabs.org/search/?q=incrementIncludeSize&i=fosho&files=&repos=

Change-Id: I14da911be23ef2d806c876ebb9ac9cf1fe782e24
2020-01-30 13:08:47 -05:00
C. Scott Ananian
dc4fd76e69 Hard-deprecate Parser::doBlockLevels(), which Parsoid won't support
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
2020-01-30 12:58:13 -05:00
C. Scott Ananian
0fc8f7cf83 Hard-deprecate Parser::fetchTemplate()
This is a follow up to I6f7c3e31ff394781fbaaef267a2772de05f85bf2, which
deprecated Parser::fetchTemplate but forgot to include the wfDeprecated()
call.

Code search:
https://codesearch.wmflabs.org/search/?q=fetchTemplate%5C%28&i=nope&files=&repos=

Change-Id: I912b538e6e77c35498308c168316803ddde1f137
2020-01-30 12:50:19 -05:00
C. Scott Ananian
25f3b8ad68 Deprecate Parser::fetchTemplate() in favor of ::fetchTemplateAndTitle()
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
2020-01-28 20:00:54 -05:00
C. Scott Ananian
a8f3eb96ce Hard deprecate Parser::setFunctionTagHook()
This is not used in production code.

Code search:
https://codesearch.wmflabs.org/search/?q=setFunctionTagHook%7CmFunctionTagHooks&i=nope&files=&repos=

Change-Id: Ie03b1687d1c65be23213035d7cb4011ef763b69a
2020-01-28 16:20:40 -08:00
C. Scott Ananian
9f0adbdb81 Remove Parser::setTransparentTagHook()
The transparent tag hooks are not used anywhere in public git.

Codesearch link:
https://codesearch.wmflabs.org/search/?q=setTransparentTagHook%7CreplaceTransparentTags%7CmTransparentTagHooks&i=nope&files=&repos=

Depends-On: I0df0ca2fc7ed05dc6dc413bd0a6d38533b66e428
Change-Id: I8384f47bbcde7604efa41b83db0dbc4f429219a8
2020-01-28 16:20:40 -08:00
jenkins-bot
eaebf057f3 Merge "Remove $wgMaxGeneratedPPNodeCount" 2020-01-29 00:14:55 +00:00
C. Scott Ananian
e149a38d4f Remove $wgMaxGeneratedPPNodeCount
This no longer has any effect.  The getter and setter in ParserOptions
aren't used in any public git code, and so have been removed without
deprecation.

Bug: T204945
Followup-To: I727f003f9a42d0c92bcbcce8a8289d5af6cd1298
Change-Id: Id48effcba48d1ae1621a4e17a70e65b73f2473b7
2020-01-28 16:54:53 -05:00
C. Scott Ananian
0437877656 Whitelist aria-hidden attribute in Sanitizer
Bug: T204618
Change-Id: I34b9b729eccd7658d5165b6661e5fd45a733b36c
2020-01-28 21:54:16 +00:00
jenkins-bot
015d3d7a9b Merge "Hard-deprecate Sanitizer::escapeId()" 2020-01-26 22:22:29 +00:00
C. Scott Ananian
b79c1e22ad Hard-deprecate Sanitizer::escapeId()
Deprecated in MW 1.30; time to clean up any remaining uses.

Code search:
https://codesearch.wmflabs.org/deployed/?q=escapeId%5C%28&i=nope&files=&repos=

Depends-On: Ic03a5da2e1d6b8f5656555420dd573a1d698b9cc
Depends-On: I311f44a5035f73c0fb2289f727eb39b73007429b
Depends-On: I76c5b539bae5572c4ac65f28fec9c0c36381348c
Depends-On: Id4cbfc3b113b1b04f949d485187e89ffe0b487f5
Depends-On: I7d5ba4930688ed7f011a4babed5986b8e40910a0
Depends-On: I964f83ce88fb9c66a7c59037c6066f4567bcf4c9
Change-Id: I89504cfdf8e02831d54a26900bfdc63a33b4eade
2020-01-26 22:05:45 +00:00
jenkins-bot
5e462e5efe Merge "Remove all traces of preprocessorClass from $wgParserConf" 2020-01-26 21:48:23 +00:00
jenkins-bot
f9a08c0c83 Merge "Remove Preprocessor_DOM, deprecated in 1.34" 2020-01-26 02:02:44 +00:00
jenkins-bot
32452dbbc1 Merge "Mark @internal a number of Parser methods not used outside MW core" 2020-01-26 01:40:19 +00:00
C. Scott Ananian
0eb9f18d8d Remove all traces of preprocessorClass from $wgParserConf
Bug: T204945
Followup-To: I727f003f9a42d0c92bcbcce8a8289d5af6cd1298
Change-Id: I23821686ad666728d7d196e089f40be4b76b7390
2020-01-25 13:15:16 -05:00
C. Scott Ananian
2d4aced658 Remove Sanitizer::attributeWhitelist()/setupAttributeWhitelist()
These method were deprecated in 1.34 and should never have been public
in the first place.  New private methods have replaced them.

Code search:
https://codesearch.wmflabs.org/deployed/?q=attributeWhitelist%5C%28&i=nope&files=&repos=

Change-Id: I363530b7edaced77f2c5b06721b1930d85e2e9dc
2020-01-25 13:06:19 -05:00
C. Scott Ananian
5cbb64f56a Remove Preprocessor_DOM, deprecated in 1.34
Remove the deprecated Preprocessor_DOM class, which was hard-deprecated
in 1.34.  This begins to simplify parser configuration and reduce redundant
code paths, but I've left two things for cleanup in a future patch:

1. The `preprocessorClass` configuration option to the parser, exposed
in `$wgParserConf`, ServiceWiring, ParserFactory, etc.  There is no reason
for this to be exposed as configurable, but I've left this clean up to a
future patch.

2. The `$wgMaxGeneratedPPNodeCount` configuration, exposed also in
ParserOptions.  Only Preprocessor_DOM calculated this count, and since
we are only using Preprocessor_Hash now, this configuration has no effect.
But since this value was exposed in ParserOptions and elsewhere, I've
deprecated where needed but left this clean up to a future patch.

Bug: T204945
Change-Id: I727f003f9a42d0c92bcbcce8a8289d5af6cd1298
2020-01-25 11:22:45 -05:00
C. Scott Ananian
b01642a27c Mark @internal a number of Parser methods not used outside MW core
These should not be considered a part of the public MW API.

Note that interwikiTransclude is used in maintenance scripts in the
Math extension, but that seems to be a reasonable use of an @internal
method.

Code search link:
https://codesearch.wmflabs.org/deployed/?q=limitationWarn%7CisCurrentRevisionOfTitleCached%7CinterwikiTransclude%7CargSubstitution%7CrenderImageGallery%7CgetFlatSectionInfo%7CmarkerSkipCallback%7CparseWidthParam&i=nope&files=&repos=

Change-Id: I50e52fd57ba3b5ad7cc7f2b21ec772374268179f
2020-01-25 16:12:04 +00:00
Thiemo Kreuz
ea01e7cfbb parser: Remove unused ParserAfterUnstrip hook
Introduced in 2015 via If83b062. Unfortunately the patch fails to mention
why the hook was introduced. A review comment asking for the missing
information was ignored.

The hook was introduced exclusively for the Cite extension, see I0e136f9.
The Cite change got reverted a few days later via I1a71854. As far as I
can tell the hook (oddly specific and underspecified anyway) was never
used again, neither for Cite nor for anything else.

Now unused: https://codesearch.wmflabs.org/search/?q=ParserAfterUnstrip

I suggest to just remove it with no deprecation phase.

My team is currently working on Cite, essentially turning it upside down.
I'm not aware of a need for this hook.

Change-Id: If68a88d7afff60385ff1e33fd13716b20d01a313
2020-01-25 09:20:52 +01:00
jenkins-bot
8a19838915 Merge "ApiParse: Use the right Skin object for building section edit links" 2020-01-24 22:01:28 +00:00
Bartosz Dziewoński
965b788178 ApiParse: Use the right Skin object for building section edit links
Apparently the section edit links may depend on state that is
available through context in the Skin object, but not necessarily
through the global context, such as the current user and page title.

Allow ParserOutput::getText() to take a 'skin' option for this purpose.

Bug: T234868
Change-Id: Iaa83e5f801c7776bf8218d8ce7484e2485b227d4
2020-01-24 18:53:20 +01:00
James D. Forrester
0958a0bce4 Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNull
Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
2020-01-10 14:17:13 -08:00
James D. Forrester
4f2d1efdda Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse
Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
2020-01-10 09:32:25 -08:00
Aaron Schulz
6de44014de parser: further restrict "revisionid" by namespace in $wgMiserMode
Follows-up c537eb1868.

The restrictions used to only apply to "content" namespaces, which
is typically just NS_MAIN. Wikis like Commons and Wikidata use custom
values, NS_FILE and $LexemeNamespace, respectively.

Now, only yield the integer ID for user, project, and talk pages.
This means that NS_FILE, NS_CATEGORY, and other namespaces with
content intended for readers, only yield '' or '-' for this work.

Bug: T235957
Change-Id: Id0110c9ee91ad5750164e9a047bcd6d7621930c1
2020-01-06 11:16:51 -08:00
Kunal Mehta
99007e96c7 Use namespaced IPUtils class
Change-Id: I047e099a93203a59093946d336a143d899d0271f
2020-01-01 02:36:49 -08:00
jenkins-bot
9d8954a372 Merge "build: Upgrade phan to 0.9.0" 2019-12-09 16:15:27 +00:00
Daimona Eaytoy
ce0856b12f Fix more scalar types in docblocks
Change-Id: I574d4e261ab986e028c3ce26c4f0ec648b88a2ac
2019-12-08 17:59:08 +00:00
Daimona Eaytoy
598c4d7fcb build: Upgrade phan to 0.9.0
Scalar casts are still allowed (for now), because there's a huge amount
of false positives. Ditto for invalid array offsets.

Thoughts about the rest: luckily, many false positives with array offsets
have gone. Moreover, since *Internal issues are suppressed in the base
config, we can remove inline suppressions.

Unfortunately, there are a couple of new issues about array additions
with only false positives, because apparently they don't take
branches into account.

Change-Id: I5a3913c6e762f77bfdae55051a395fae95d1f841
2019-12-07 20:16:19 +00:00
Tim Starling
164a3ac1f0 Remove IE 6 security features from server-side code
* Deprecate WebRequest::checkUrlExtension() and have it always return
  true. This reverts the security fixes made for T30235.
* Remove IEUrlExtension. This is a helper for checkUrlExtension() which
  is not used in any extensions.
* Remove CSS sanitization code which is specific to IE6. This reverts
  the changes made to fix T57332, and related followups. I confirmed
  that the relevant test cases do not result in XSS on IE8.
* Remove related tests.

Bug: T232563
Change-Id: I7318ea4a63210252ebc64968691d4f62d79a63e9
2019-11-28 15:11:56 +11:00
jenkins-bot
597be4a78d Merge "parser: Inline private callback in LinkHolderArray::replaceText" 2019-11-22 16:47:46 +00:00
Umherirrender
b1a38362f3 Add missing @param and @return to documentation
Using @see is not enough description

Enable the php sniffs for now, but skip /tests/ to fix it later.
That avoids new issues in future patch sets

Change-Id: I49cb341a2880bfaeefb6bbfbb1717051ea3a4b16
2019-11-13 17:26:55 +01:00
jenkins-bot
097ad02261 Merge "REST compare: bundle section offset information" 2019-11-13 01:18:01 +00:00
jenkins-bot
320b350436 Merge "Use ctype_digit() instead of regular expressions" 2019-11-13 01:06:24 +00:00
Thiemo Kreuz
cf42131019 Streamline/fix code by using short ?: and ?? syntax
Change-Id: I27dc0c8a1a184571ed96abdea22af953510457cd
2019-11-11 11:17:13 +01:00
Tim Starling
8299d7ae8f REST compare: bundle section offset information
Bug: T236964
Change-Id: Ib97b0fa0de682404fb9df2ecef55a3526c54a31f
2019-11-11 16:25:35 +11:00
Thiemo Kreuz
00f2a8047f Use ctype_digit() instead of regular expressions
Because it's faster and make the code easier to read (hopefully, feel
free to disagree).

Change-Id: I59d9920dbc7893cbee4115002e15cf79679ce25a
2019-11-08 17:43:49 +01:00
jenkins-bot
2f17ac896e Merge "Improve efficiency of french-spacing regexp" 2019-11-07 08:21:22 +00:00
James D. Forrester
8255ecd074 Parser: Drop ::disableCache(), deprecated in 1.28
Change-Id: Ide0b28f821c55fb008e50c199032f1c34334ac1d
2019-11-05 17:07:00 -05:00
jenkins-bot
ee2751a70b Merge "Minor cleanups" 2019-11-05 10:46:25 +00:00
C. Scott Ananian
8dbc866e91 Hard deprecate Parser::disableCache()
Among deployed extensions, only used in the Quiz extension.

Full list of uses (some false positives):
https://codesearch.wmflabs.org/search/?q=disableCache&i=nope&files=&repos=

Depends-On: I956a88120d07d76d1afa9d06e95d31055f9b07f1
Change-Id: I6419754de6cbc01af07b6c0eafb8396bd720a58d
2019-11-04 21:22:11 +00:00
C. Scott Ananian
3397bd43e7 Parser: remove/make private historically-public methods
These were hard-deprecated in 1.34.  This continues work to clean up
the Parser API.

Bug: T236810
Change-Id: I0b2258a63d73370fd770612a6ca437509676d71c
2019-11-04 15:43:20 -05:00
C. Scott Ananian
cff5c92cb9 Parser: Add Title type hints
This reverts commit c16b0a533e0d7350bceca7ccbe490efa3e3ce4c4, now
that an appropriate period of time has passed since this behavior
was deprecated.

Bug: T235392
Change-Id: I076ae0dbfbbb8be731367e4641f9c8aacf7586e9
2019-11-04 14:08:26 -05:00
jenkins-bot
0ebeb72733 Merge "Simplify RemexStripTagHandler by extending NullTokenHandler" 2019-11-04 14:42:30 +00:00
Max Semenik
f1c9cf8879 Minor cleanups
* Identifier case
* Returning a void function result
* Unused variable
* Missing documentation

Change-Id: Ibfd2fc5ae1d91c7c9c6a34bcd4523384d3bca576
2019-11-03 17:10:23 -08:00
Tim Starling
68d87dba9f Remove Parser::serializeHalfParsedText() and helpers
It was deprecated in 1.31, It was a failed experiment, intended to
improve performance, but it never worked and makes the code
much more complex. I also removed two LinkHolderArray helpers which were
accidentally not marked deprecated -- codesearch confirms that they are
not called by anything.

Change-Id: I74754265dde388b590f0b4c995cb4a35a1318299
2019-11-01 15:22:29 +11:00
jenkins-bot
74a646c0f2 Merge "Parser: Remove ::getConverterLanguage(), deprecated in 1.32" 2019-11-01 01:55:28 +00:00