aboutsummaryrefslogtreecommitdiffstats
path: root/includes/parser/Hook
Commit message (Collapse)AuthorAgeFilesLines
* Namespace all remaining files in includes/filerepoJames D. Forrester2025-03-192-2/+2
| | | | | Bug: T353458 Change-Id: I35864ad9bd48701703c51367d62f8ebde963c52d
* Namespace all remaining files in includes/pageJames D. Forrester2025-03-181-1/+1
| | | | | Bug: T353458 Change-Id: I7a9c74f2106655d41ae029742090253f541bd4a6
* Remove unusual message keys for parser limit reportBartosz Dziewoński2024-11-141-2/+1
| | | | | | | | | | | As far as I can tell, no one ever used the "$key-value-text" or "$key-value-html" keys, only "$key-value": https://codesearch.wmcloud.org/search/?q=-value-(html|text)%22%3A&files=en.json https://global-search.toolforge.org/?q=.*&regex=1&namespaces=8&title=.*-value-%28html|text%29 They were added in 2013 (2b20038ce77ce8b939113a3edb7d25127c238d4e). Change-Id: I175e834e2b425f0ba1b8650ae44dbf65fb23fe6e
* Namespace all remaining classes in includes/parserJames D. Forrester2024-10-157-8/+8
| | | | | Bug: T353458 Change-Id: If02cc9b1ff78e26c1cf8c91ee4695845eb133829
* Standardise all our class alias deprecation comments for ease of greppingJames D. Forrester2024-03-191-4/+1
| | | | Change-Id: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
* Move Parser to Mediawiki\Parser namespaceSubramanya Sastry2024-02-1616-16/+16
| | | | | | | | Bug: T166010 Co-Authored-By: Daimona Eaytoy <daimona.wiki@gmail.com> Co-Authored-By: James Forrester <jforrester@wikimedia.org> Co-Authored-By: Subramanya Sastry <ssastry@wikimedia.org> Change-Id: I79b4e732c45095eedbaa80afa5eb7479b387ed8a
* Namespace ParserOutputJames D. Forrester2023-12-144-4/+4
| | | | | | | Most used non-namespaced class! Bug: T353458 Change-Id: I4c2cbb0a808b3881a4d6ca489eee5d8c8ebf26cf
* Namespace User under \MediaWiki\UserJames D. Forrester2023-09-191-1/+1
| | | | | Bug: T166010 Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
* Add Hook suffix to ParserModifyImageHTMLHookUmherirrender2023-04-161-1/+7
| | | | | | | Common naming convention for hook runner interfaces Bug: T334689 Change-Id: I3043454a502289e5ee2492f7bf2ab01e155c30ba
* Reorg: Namespace the Title classJames D. Forrester2023-03-024-4/+4
| | | | | | | | | | | | | | | | | | | This is moderately messy. Process was principally: * xargs rg --files-with-matches '^use Title;' | grep 'php$' | \ xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1' * rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \ xargs rg --files-with-matches 'Title\b' | \ xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1' * composer fix Then manual fix-ups for a few files that don't have any use statements. Bug: T166010 Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
* Drop more unused hard deprecated hooksAmir Sarabadani2022-12-011-34/+0
| | | | | | | None are used in WMF-deployed extensions and have been hard deprecated for multiple releases as well. Change-Id: I62cfa22291f81295b4908192de8657a750c6716d
* Drop unused deprecated hooksAmir Sarabadani2022-11-283-86/+0
| | | | | | | | Part one, none of these hooks are used in extensions deployed in production. I skipped any hook that has silenced its deprecation warnings. Change-Id: Idf1fd12cc61ca30867dc9f8aeb1701fe035fc5ff
* ParserGetVariableValueSwitchHook: Don't use the cache parameterC. Scott Ananian2022-08-161-0/+2
| | | | | | | | Don't expose the parser's internal caching mechanism; shenanigans with this parameter were deprecated in 1.35. Bug: T236813 Change-Id: Iea74946c806d536ce321cba9675a7fabc117e4f1
* Remove ParserGetVariableVarCacheHook, deprecated in 1.35C. Scott Ananian2022-08-121-26/+0
| | | | | | | | | This exposed internal cache mechanisms of the Parser, and appears to have been originally added in c08da372bcadcf4778e37a2b8f7792aee8561165 but is unused in any code indexed by codesearch. Bug: T236813 Change-Id: Iaa5da572d76b1d396ecc7e3d3eb29c8d7d4bcddd
* Create ParserFetchTemplateData hookC. Scott Ananian2022-03-281-0/+36
| | | | | | | | This is moved from TemplateData, but the interface isn't quite right. Filed T304899 to improve it in the future. Bug: T304740 Change-Id: Iadd1ed70b72fc282bd5addfc1654aa73322ea470
* Create ParserLogLinterData hookC. Scott Ananian2022-03-281-0/+36
| | | | | | | | | This hook was formerly defined by Extension:Linter and invoked by Parsoid, but as this part of Parsoid is moving into core the hook should now be defined by core as well. Bug: T304740 Change-Id: Iffd073e510202e5766632cc01d3585815289b7b4
* Merge "parser: Fix various scalar types to match documentation"jenkins-bot2022-03-181-1/+1
|\
| * parser: Fix various scalar types to match documentationUmherirrender2022-03-141-1/+1
| | | | | | | | | | | | Found by phan strict checks Change-Id: I0a1d1eeb6ee63ce8f6f6fd7dc6fe9273847609af
* | Pass a ConvertibleTimestamp to CoreMagicVariablesC. Scott Ananian2022-03-141-3/+3
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | This avoids a type mismatch found by phan strict checks (Ifc7fc64ac26a756f181b7d0155f13a6500114f5e) -- the passed timestamp from Parser was a string in unix format (ie, an integer as a string) but was declared as an integer. It was then passed to MWTimestamp::getInstance() which expected a string. However, the 'simple' fix for this issue still caused unnecessary conversions to/from timestamp format. We took the string (nominally in TS_MW format), ran a regexp against it to convert it to an MWTimestamp instance, then converted that MWTimestamp to UNIX format and exported that as a string, just to take that string and run four different regexps against it *again* to convert it back to an MWTimestamp instance so we can format it. Better to just pass the MWTimestamp directly. Only two wrinkles: 1. the ParserGetVariableValueTs hook expects to be passed a string in TS_UNIX format and then to be able to mutate it. Nothing in production uses that hook, so only do this conversion if the hook is registered. 2. Parsoid would like to use the definitions in CoreMagicVariables in the future as well. So pass the timestamp as the not-MW-@internal ConvertibleTimestamp class instead of directly as a MWTimestamp. Change-Id: Ib2c5fa45630c54c2716897370a0580ed48d27242
* Add a ParserModifyImageHTML hook for PageImagesTim Starling2021-12-151-0/+30
| | | | | | | | | | | | | PageImages is expensively loading and reparsing the lead section during LinksUpdate because the parser's image link hooks do not give enough context to tell whether the image is in the lead section. So, add a hook which allows PageImages to add a marker to image links. The marker can be associated with the section number in ParserAfterTidy. Bug: T296895 Bug: T176520 Change-Id: I24528381e8d24ca8d138bceadb9397c83fd31356
* build: Updating dependencieslibraryupgrader2021-07-221-1/+1
| | | | | | | | | | | | | | composer: * mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0 The following sniffs now pass and were enabled: * Generic.ControlStructures.InlineControlStructure * MediaWiki.PHPUnit.AssertCount.NotUsed npm: * svgo: 2.3.0 → 2.3.1 * https://npmjs.com/advisories/1754 (CVE-2021-33587) Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
* FileRepo::findFile - support AuthorityPetr Pchelko2021-05-261-1/+1
| | | | Change-Id: Ib42b7f7d5aa88447b4fb363f52062b08a1af30c3
* Use @deprecated annotation on hook interfaces, not functionsUmherirrender2021-05-171-2/+1
| | | | | | | | Use only one place to document the deprecation of hook interfaces/functions Bug: T282903 Change-Id: Ie7d2d7a50afe2897e5c2369f473a33ecaa821637
* Remove hooks that use Revision objectsDannyS7122021-04-301-32/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | All hooks were previously hard deprecated in 1.35. Affected hooks: * ArticleRevisionUndeleted - use RevisionUndeleted * ArticleRollbackComplete - use RollbackComplete * DiffRevisionTools - use DiffTools * DiffViewHeader - use DifferenceEngineViewHeader * HistoryRevisionTools - use HistoryTools * NewRevisionFromEditComplete - use RevisionFromEditComplete * PageContentInsertComplete - use PageSaveComplete * PageContentSaveComplete - use PageSaveComplete * ParserFetchTemplate - use BeforeParserFetchTemplateRevisionRecord * RevisionInsertComplete - use RevisionRecordInserted * TitleMoveComplete - use PageMoveComplete * TitleMoveCompleting - use PageMoveCompleting * UndeleteShowRevision - no replacement Includes a fix for setting the associated rev id of page protections, which previously was only done using $nullRevision which was a Revision object created if any hooks needed it; those hooks were hard deprecated and so for WMF prod the rev id was not being set. Bug: T247143 Depends-On: Idfa345193ae99fb2f1c9a8f8d28d8d540a6e3d62 Change-Id: I519167f76a5a3c1f5410415b2721462a3dcc3ec8
* parser: new BeforeParserFetchTemplateRevisionRecord hookC. Scott Ananian2021-02-053-1/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This new hook provides for the use case in T47096 (allowing the Translate extension to transclude a page from another language) by adding a new hook which would let us deprecate and replace two awkward legacy hooks (one with an embarrassing capitalization issue). The new hook is a little more tightly scoped in terms of what it allows and gives access to, and it uses the new RevisionRecord API. In addition, the new hook uses LinkTarget instead of Title per current best practices. (PageIdentity is not appropriate for reasons documented at the hook invocation site.) The original BeforeParserFetchTemplateAndtitle (sic) hook allowed redirecting the revision id of a template inclusion, but not the title. The only known current use is Extension:ApprovedRevs; the FlaggedRevs extension replaces the entire function using ParserOptions::setCurrentRevisionRecordCallback(). Extension:Translate would like to redirect the title as well, possibly recursively (for a limited number of hops) to handle fallback languages. That is, when invoked on Foo/fr, including Template:Bar would redirect to Template:Bar/fr -- and, if that doesn't exist, then Template:Bar/fr would redirect to its fallback language, say Template:Bar/en. It uses the top-level page title as context to set the desired page language. This would require 2 invocations of the hook; we've set the recursion limit to 3 to provide a little bit of future-proofing. The hook added in this patch uses RevisionRecord instead of int $rev_id, and thus can handle the case where the redirect is to a page which doesn't exist (by setting the RevisionRecord to a MutableRevisionRecord with the correct title and no main slot content) in the fallback language case above. The new hook deprecates BeforeParserFetchTemplateAndtitle and replaces ParserFetchTemplate as well (deprecated in 1.35). Code search: https://codesearch.wmcloud.org/search/?q=BeforeParserFetchTemplateAndtitle&i=nope&files=&repos= Bug: T47096 Change-Id: Ia5b5d339706ce4084c16948300e0e3418b11792e
* Remove documentation that literally repeats the codeThiemo Kreuz2020-10-271-1/+1
| | | | | | | | | | | | | | | For example, documenting the method getUser() with "get the User object" does not add any information that's not already there. But I have to read the text first to understand that it doesn't document anything that's not already obvious from the code. Some of this is from a time when we had a PHPCS sniff that was complaining when a line like `@param User $user` doesn't end with some descriptive text. Some users started adding text like `@param User $user The User` back then. Let's please remove this. Change-Id: I0ea8d051bc732466c73940de9259f87ffb86ce7a
* Merge "Document hook names in hook interfaces."jenkins-bot2020-10-0229-0/+87
|\
| * Document hook names in hook interfaces.daniel2020-09-2729-0/+87
| | | | | | | | | | Bug: T258665 Change-Id: Ifddbf57f8aa2e3eb0d5845601376cbafa08ed407
* | Merge "Remove fallback to $wgUser in FileRepo::findFileFromKey"jenkins-bot2020-09-251-0/+1
|\ \ | |/ |/|
| * Remove fallback to $wgUser in FileRepo::findFileFromKeyDannyS7122020-09-201-0/+1
| | | | | | | | | | Bug: T263033 Change-Id: I436b188dc5afbe32d7d9fe1be9739752c95c1230
* | Remove ParserBeforeStrip/ParserAfterStrip hooks, deprecated in 1.35C. Scott Ananian2020-09-202-50/+0
|/ | | | | | | | | Everything code search: https://codesearch.wmflabs.org/search/?q=ParserBeforeStrip%7CParserAfterStrip&i=nope&files=&repos= Bug: T250449 Bug: T250450 Change-Id: I91e6753a9159bb7f8d699c79fd20483c42be33aa
* Remove ParserBeforeTidy hook, deprecated in 1.35C. Scott Ananian2020-08-121-22/+0
| | | | | Bug: T198214 Change-Id: I2c8587862a4a7e4f0fe6007894edb1a0d38816e3
* Replace "@stable for implementation" with "@stable to implement"daniel2020-07-1325-25/+25
| | | | | | | | | | | For compliance with the new version of the table interface policy (T255803). This patch was created by an automated search & replace operation on the includes/ directory. Bug: T257789 Change-Id: I17e5e92e24c708ffc846945a136347670a3a20c7
* Hook: Mark abortable=false hooks as voidTimo Tijhof2020-06-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove the mention of 'return true' being legal. This is only allowed for compat with code from before MW 1.21, when I added hook aborting as well as tolerance for null to be the same as true. Since then, there is no reason to return null or return true. For early returns, an explicitly void 'return;' should be used instead. Returning anything else like null/true serves no purpose other than to confuse the reader. * Mark the interfaces as natively 'void' with return type hints. This means in core code that runs the hook, static analysis like Phan and in IDEs, it will be known that these onFoo()s never return a value, thus allowing them to detect if its return value is assigned or used in a conditional for any reason, which can be an easy mistake. It also means that in the future when extensions start using these interfaces in 'implements' statement, they will be required to mark their hooks as void. That migration is opt-in and still up ahead. This is not a breaking change even for all existing extensions where a return true/null may exist in an abortable hook since this only applies to code directly typed against the interface. The internal run() method doesn't care. Change-Id: Ib79289bd486ac97cec492e72f9a8dee70cf2f6c2
* Un-deprecate the ParserPreSaveTransformComplete hookC. Scott Ananian2020-06-011-1/+1
| | | | | | | | | | | Although it's true that Parsoid doesn't (yet) support this hook, and the $parser object referenced in the hook is likely going to be changed, this is a hook added in 1.35 (eb6c5f70d9a12b16c065941659d21a6323735b9b) to replace use of an even worse hook. So let's keep the lesser of the evils, at least for now. Bug: T236809 Change-Id: I8f866c3b9f1fc51848cfe9364635112371d18e3e
* 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
* Hook interface doc comment followupTim Starling2020-04-211-2/+2
| | | | | | Mostly just narrower array types. A handful of other errors fixed. Change-Id: Ied79d9e389867911bf83696dbb47f43305f8be7b
* 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
* 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