aboutsummaryrefslogtreecommitdiffstats
path: root/includes/parser
Commit message (Collapse)AuthorAgeFilesLines
* Fix impedance mismatch with Parser::getRevisionRecordObject()C. Scott Ananian2020-05-062-3/+9
| | | | | | | | | | | | | 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
* CoreParserFunctions::revisionuser - only call getUser on RevisionRecordDannyS7122020-05-051-1/+3
| | | | | Bug: T251952 Change-Id: Ib74f8546a955a41b119fce00ccaa9a0b635245ef
* Hook interface type fixes, to fix Phan errorsTim Starling2020-05-052-8/+6
| | | | | | | | Phan flagged a lot of incorrect type hints when run against the call site migration patch. Bug: T240307 Change-Id: I698de5536446c241b200430198b21b72763b0c69
* Update hook interfaces for recent additions and deprecationsDannyS7122020-05-057-6/+30
| | | | | | | | | | | | | | | | | | | | | | | | Changes since the interfaces were generated: 5 hooks added: * RevisionUndeleted * ParserBeforePreprocess * RollbackComplete * HtmlCacheUpdaterAppendUrls * HtmlCacheUpdaterVaryUrls 9 hooks deprecated: * ArticleRevisionUndeleted * ArticleRollbackComplete (soft deprecation) * UndeleteShowRevision * InternalParseBeforeSanitize * ParserFetchTemplate * ParserSectionCreate * ParserPreSaveTransformComplete * BeforeParserrenderImageGallery * ParserBeforeTidy Bug: T240307 Change-Id: Ib91b1d8e519e6cb3c74a6fe174fe2fd0103d6d30
* Update description of ParserFirstCallInitHook per hooks.txtDannyS7122020-05-011-1/+1
| | | | Change-Id: I900975ad73a64bf7b9d83df4ee728005d4fb5d70
* Replace uses and hard deprecate Revision::getSha1DannyS7122020-04-301-1/+8
| | | | | Bug: T251233 Change-Id: I815db5120094909b2820b8ca56d65a62f6af82d1
* Have CoreParserFunctions::getCachedRevisionObject return RevisionRecordDannyS7122020-04-301-14/+23
| | | | | | | | | | | | | | Private method, no need to worry about deprecation Most of its uses in the class called Revision methods that were identical to the RevisionRecord methods, and didn't need to change to reflect the new type being returned. Remove a use of Revision::getUserText Bug: T249393 Bug: T250579 Change-Id: Ide0dcd01caee3d3388038e6f40edda25528f55d8
* Revert "Correct capitalization of BeforeParserFetchTemplateAndTitle hook"Tim Starling2020-04-301-2/+0
| | | | | | | | | In the new hook system, it is invalid to have two hooks that differ only in case. This reverts commit afb5b38e15d9d864913164be9681c6417eb2f4e7. Change-Id: I160ece0a7bc68c748037b383137364b787be86a0
* Replace uses and hard deprecate Parser::getRevisionObjectDannyS7122020-04-283-9/+14
| | | | | | | | Also removes a use of Revision::getUserText Bug: T249384 Bug: T250579 Change-Id: I9c7763cc1d3442cd41d1ffc804fb18bfbd8be84f
* Merge "Hook interface doc comment followup"jenkins-bot2020-04-271-2/+2
|\
| * Hook interface doc comment followupTim Starling2020-04-211-2/+2
| | | | | | | | | | | | Mostly just narrower array types. A handful of other errors fixed. Change-Id: Ied79d9e389867911bf83696dbb47f43305f8be7b
* | Fix incorrect return type documentation for Parser::getRevisionUser()C. Scott Ananian2020-04-271-2/+5
| | | | | | | | Change-Id: I2ad51797d841e4cc2a433a27bbaa07b5a2f9a62c
* | deprecation: Remove DeprecationHelper::newArgumentWithDeprecation and change ↵Peter Ovchyn2020-04-271-10/+8
| | | | | | | | | | | | | | callers accordingly Bug: T245075 Change-Id: I0714b1c5d5a379cfe3ca473b72244d4d6bd1b7b8
* | Merge "Refactor magic word implementations out of Parser.php"jenkins-bot2020-04-222-367/+409
|\ \
| * | Refactor magic word implementations out of Parser.phpC. Scott Ananian2020-04-102-367/+409
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge "docs: Hook interface doc comment review"jenkins-bot2020-04-2131-134/+215
|\ \ \ | | |/ | |/|
| * | docs: Hook interface doc comment reviewapaskulin2020-04-2131-134/+215
| | | | | | | | | | | | | | | | | | | | | | | | Edited doc comments for hook interfaces to improve consistency and add type hints. Bug: T246855 Change-Id: I38fa802463cd6f39bf5946dbbeb1b3ebaea604b2
* | | Merge "Automatically generated hook interfaces"jenkins-bot2020-04-2131-0/+709
|\| |
| * | Automatically generated hook interfacesTim Starling2020-04-2031-0/+709
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add hook interfaces which were generated by a script which parses hooks.txt and identifies caller namespaces and directories. Hook interfaces are mostly placed in a Hook/ subdirectory relative to the caller location. When there are callers in multiple directories, a "primary" caller was manually selected. The exceptions to this are: * The source root, maintenance and tests, which use includes/Hook. Test hooks need to be autoloadable in a non-test request so that implementing test interfaces in a generic handler will not fail. * resources uses includes/resourceloader/Hook * The following third-level subdirectories had their hooks placed in the parent ../Hook: * includes/filerepo/file * includes/search/searchwidgets * includes/specials/forms * includes/specials/helpers * includes/specials/pagers Parameters marked as legacy references in hooks.txt are passed by value in the interfaces. Bug: T240307 Change-Id: I6efe2e7dd1f0c6a3d0f4d100a4c34e41f8428720
* | | Replace uses and hard deprecate Article:: and WikiPage::getRevisionDannyS7122020-04-201-1/+1
| | | | | | | | | | | | | | | | | | Bug: T250532 Bug: T239975 Change-Id: Ic8f2baa0ac805d5196a7107bdc7a1abb36eba139
* | | Merge "Replace uses and hard deprecate Revision::newFromTitle"jenkins-bot2020-04-201-2/+6
|\ \ \
| * | | Replace uses and hard deprecate Revision::newFromTitleDannyS7122020-04-181-2/+6
| |/ / | | | | | | | | | | | | | | | | | | Also fixed a use of ::newFromId in benchmarkParse and Parser Bug: T249183 Change-Id: I3219a72f1085836205dc497e2236b52db24d7c16
* | | Merge "Deprecate ParserOptions::getTidy() and ParserOptions::setTidy()"jenkins-bot2020-04-201-0/+2
|\ \ \
| * | | Deprecate ParserOptions::getTidy() and ParserOptions::setTidy()C. Scott Ananian2020-04-191-0/+2
| |/ / | | | | | | | | | | | | | | | | | | These options no longer have any effect. Bug: T198214 Change-Id: Icc3eaed7ab8a3070c4339b272d580328ba40912d
* / / Add ParserBeforePreprocess hookC. Scott Ananian2020-04-171-0/+1
|/ / | | | | | | | | | | | | | | | | 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
* | Deprecate ParserBeforeTidy hookC. Scott Ananian2020-04-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Untidy parser output should not be exposed outside mediawiki core. Callers should use ParserAfterTidy instead. Code search: https://codesearch.wmflabs.org/deployed/?q=ParserBeforeTidy&i=nope&files=&repos= https://codesearch.wmflabs.org/search/?q=ParserBeforeTidy&i=nope&files=&repos= Depends-On: Ia6bd94fc937a9bff77843e6734e88ba8991d04ec Change-Id: I4a0aae7b17fb522a5e4f90edad3a0b7137b270a6
* | Correct capitalization of BeforeParserFetchTemplateAndTitle hookC. Scott Ananian2020-04-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We deprecate the incorrect capitalization and add a new hook with the correct capitalization. There are very few users of this hook, and none in WMF-deployed code. WMF-deployed code search: https://codesearch.wmflabs.org/deployed/?q=BeforeParserFetchTemplateAndtitle&i=nope&files=&repos= Everything code search: https://codesearch.wmflabs.org/search/?q=BeforeParserFetchTemplateAndtitle&i=nope&files=&repos= It would be tempting to remove this hook entirely, but it seems to serve a valuable purpose in allowing page and template fetches at a specific "old" timestamp. (Extension:Memento and Extension:TimeTravel don't seem to have implemented this feature, however.) Change-Id: I501b0ee35b81fee424d45084088a6ed63c3dfd54
* | Deprecate infrequently-used parser-related hooksC. Scott Ananian2020-04-171-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following parser-related hooks have no users in deployed code: - InternalParseBeforeSanitize - ParserFetchTemplate - ParserSectionCreate - ParserPreSaveTransformComplete - BeforeParserrenderImageGallery Code search in WMF-deployed code: https://codesearch.wmflabs.org/deployed/?q=%5Cb%28InternalParseBeforeSanitize%7CParserFetchTemplate%7CParserSectionCreate%7CParserPreSaveTransformComplete%7CBeforeParserrenderImageGallery%29%5Cb&i=nope&files=&repos= Code search in all code: https://codesearch.wmflabs.org/search/?q=%5Cb%28InternalParseBeforeSanitize%7CParserFetchTemplate%7CParserSectionCreate%7CParserPreSaveTransformComplete%7CBeforeParserrenderImageGallery%29%5Cb&i=nope&files=&repos= Removing as many infrequently-used hooks as possible will aid our transition from the legacy parser to alternative parsers. Bug: T236809 Change-Id: I3a09fbe6436232ae0b417ad61b19f8df6d0485e0
* | Deprecate Parser::firstCallInit()C. Scott Ananian2020-04-171-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Make Parser::$mVariables privateC. Scott Ananian2020-04-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This was overlooked in a5afda55bfbdf7b18b21ad3b41ec281bf8f5130c, 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
* | Add RevisionRecord alternatives to Parser and ParserOptions methodsDannyS7122020-04-172-9/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Hard deprecate Parser::OutputType and Parser::OptionsC. Scott Ananian2020-04-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | These were deprecated earlier. Code search: https://codesearch.wmflabs.org/deployed/?q=-%3E%28OutputType%7COptions%29%5C%28&i=nope&files=&repos= Depends-On: I548a710cdfa0eedb5a28b4e0196839995f5de568 Depends-On: I08b0788461fae5fa48818aa2eda01c866499b30e Depends-On: I70e0ecb201d5ffdc3ccb75caf552a1dee4ad9e60 Depends-On: Ieea168b47e1a0f5b67d0e2db8503281e0f4743c8 Change-Id: I7e1902158e5bfa1a2466e2e30e13cb396228eab7
* | Deprecate old-style accessor/mutation methods of ParserC. Scott Ananian2020-04-161-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Hard-deprecate direct calls to Parser::__construct()C. Scott Ananian2020-04-162-13/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These were deprecated in 1.34, but let's put in some hard deprecation warnings for 1.35 since this class is certainly going to be refactored in the future to allow both the legacy parser and Parsoid to extend Parser as a base class. Access via the ParserFactory will be fine, but cut down on the number of different ways Parsers can be constructed and initialized. Code search: https://codesearch.wmflabs.org/deployed/?q=new%20Parser%5C%28&i=nope&files=&repos= https://codesearch.wmflabs.org/deployed/?q=getMockBuilder%5C%28%20Parser%3A%3A&i=nope&files=&repos= https://codesearch.wmflabs.org/deployed/?q=new%20Parser%3B&i=nope&files=&repos= Bug: T236811 Depends-On: Ib3be450c55e1793b027d9b4dae692ba5891b0328 Depends-On: I9d16513f8bd449a43b0a0afbd73651a5c0afa588 Depends-On: I74efda708470efeb82f8f80346ec1ee7e9fd8f2b Depends-On: I777475d0ab0144e53240173f501d6c8da35d33fb Change-Id: If36283ec0b78b188b61f658639105d1ed7653e0a
* | Merge "Deprecate $wgParserConf"jenkins-bot2020-04-161-1/+1
|\ \
| * | Deprecate $wgParserConfC. Scott Ananian2020-04-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge "Parser: Add type hints for objects, arrays and callables"jenkins-bot2020-04-161-25/+25
|\ \ \
| * | | Parser: Add type hints for objects, arrays and callablesFomafix2020-04-111-25/+25
| | |/ | |/| | | | | | | | | | | | | | | | | | | Also * remove unneeded reference &$user in getUserSig. * add missing false in Doxygen tags. Change-Id: Icc3860cda66918f56d9014d6c19c4be47d4b5464
* | | Merge "Remove ParserDiffTest"jenkins-bot2020-04-161-119/+0
|\ \ \ | | |/ | |/|
| * | Remove ParserDiffTestC. Scott Ananian2020-04-161-119/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This class was last used in ~2008 as @tstarling was developing the original wikitext Parser. It has since code-rotted and wouldn't work as a drop in for the Parser class any more anyway. We'll probably (re)invent something similar when we eventually switch Message rendering from the legacy parser to Parsoid, but this existing code isn't a good starting point for that; we'll need to tackle T236812 (splitting Parser into a base class) first. Last meaningful change to ParserDiffTest: 350b498b9ff2572b52e899ca475be9c2583fec56 Code search: https://codesearch.wmflabs.org/search/?q=ParserDiffTest&i=nope&files=&repos= Bug: T236811 Change-Id: I98f1ef8ad296791a810bd8b10343f8640fd23c5e
* | | Merge "doxygen: Changed Doxygen tags causing warnings during documentation ↵jenkins-bot2020-04-161-36/+36
|\ \ \ | |/ / |/| | | | | generation"
| * | doxygen: Changed Doxygen tags causing warnings during documentation generationHolger Knust2020-04-141-36/+36
| |/ | | | | | | | | | | | | | | | | | | | | Updated Doxygen markup in several .php files triggering warnings when mwdocgen.php is executed. Removed obsolete settings MSCGEN_PATH and TCL_SUBST from Doxyfile. The former would generate a warning in 1.8.16 while TCL support was removed in 1.8.18. Since TCL_SUBST was blank anyway, it was removed prior to getting to .18 in production. Increased DOT_GRAPH_MAX_NODES from 50 to 200 since Doxygen complained about it being too low for API and Maintenance. Bug: T248706 Change-Id: I9c67f0807d1b43089d351263d4f591dee5501f36
* | Merge "Upgrade phan to 0.10.2"jenkins-bot2020-04-161-2/+2
|\ \
| * | Upgrade phan to 0.10.2Daimona Eaytoy2020-04-161-2/+2
| |/ | | | | | | | | | | | | | | | | | | | | Amongst other things, this version of phan bundles taint-check, which is however disabled in the config file because there are lots of issues to be fixed. Upgrading phan alone now means that we can have a clean baseline for the taint-check upgrade. Bug: T248630 Change-Id: I8ab7ef9a9e73952098664176aad6c2b3b88095ee
* | Merge "ParserCache::get use WikiPage only as argument"jenkins-bot2020-04-151-60/+76
|\ \
| * | ParserCache::get use WikiPage only as argumentArtBaltai2020-04-121-60/+76
| |/ | | | | | | | | | | | | | | ParserCache work only with WikiPage,remove Article and Page interfaces Rename WikiPage property names and type hintings Bug: T248719 Change-Id: I08afded432b059f94538be574a4789e18e89bf03
* / Remove codepaths which ran parser in 'untidy' modeC. Scott Ananian2020-04-133-217/+31
|/ | | | | | | | Disabling tidy has been deprecated since 1.33. This cleans up the code paths which still used untidy output. Bug: T198214 Change-Id: I821ef3b8f59b272d983583d407b2f0794fe1e791
* Add a wfDeprecated to an overlooked code path where parser output is not tidyC. Scott Ananian2020-04-022-0/+5
| | | | | | | | | | 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
* Merge "Deprecate most public fields of Parser; make private those unused ↵jenkins-bot2020-04-011-23/+45
|\ | | | | | | outside core"
| * Deprecate most public fields of Parser; make private those unused outside coreC. Scott Ananian2020-03-311-23/+45
| | | | | | | | | | | | | | | | | | | | | | | | Fields which have at least one user outside of mediawiki-core (as reported by the 'everything' search in codesearch.wmflabs.org) have been deprecated; those which have no users have been immediately made private. Code search url for the fields made private: https://codesearch.wmflabs.org/search/?q=-%3E%28mFunctionSynonyms%7CmFunctionTagHooks%7CmStripList%7CmVarCache%7CmImageParams%7CmImageParamsMagicArray%7CmSubstWords%7CmConf%7CmExtLinkBracketedRegex%7CmUrlProtocols%7CmAutonumber%7CmLinkHolders%7CmDefaultSort%7CmTplRedirCache%7CmForceTocPosition%7CmTplDomCache%7CmOutputType%7CmLangLinkLanguages%7CcurrentRevisionCache%7CmProfiler%7CmLinkRenderer%29&i=nope&files=&repos= Bug: T248889 Change-Id: I28e88e574ec9f99231bd590e9a87fbc1c4349fa1