aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/unit/includes/parser
Commit message (Collapse)AuthorAgeFilesLines
* Introduce ParsoidExperimentalParserFunctionOutput config flagSubramanya Sastry2025-01-301-0/+1
| | | | | | | | | * Plumb this value into Parsoid's SiteConfig so that the Parsoid library code can access this. Bug: T373253 Bug: T385129 Change-Id: If119ff94e65325fc446ca068e0b2d2434c070a2e
* Add template expansion statistics to the Parsoid limit reportC. Scott Ananian2024-12-041-6/+2
| | | | | | | | | | Use the legacy parser's ::makeLimitReport() in ParsoidParser to ensure that a number of template-related statistics are included. Protect ParsoidParser with a check of $wgEnableParserLimitReporting like the legacy parser does as well. Bug: T380758 Change-Id: Ibd812676b55eee619f7dbacc476ba84d1b65d005
* Include ids in dummy parsoid arrayArlo Breault2024-11-111-2/+2
| | | | | | | | | | | | | | | | PageBundle defines "parsoid" as, @var null|array{counter?:int,offsetType?:string,ids:array<string,array>} Fixes an rt testing crasher, following up I186bf82ea1fa391a34e0ecdd9152289a18d97e14 Previously, the pb2pb transformation was fixing up the missing ids. I0f3bae4d52c6940ef8ef3d5efdf7a97c358f0e45 is related. Also, mw will be null until version 999. Change-Id: Idb2faf6f990f07de99074892a968e6bb921189f3
* Use explicit nullable type on parameter argumentsUmherirrender2024-10-161-3/+3
| | | | | | | | | | | Implicitly marking parameter $... as nullable is deprecated in php8.4, the explicit nullable type must be used instead Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a Break one long line in SpecialPage.php Bug: T376276 Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
* Namespace all remaining classes in includes/parserJames D. Forrester2024-10-157-14/+14
| | | | | Bug: T353458 Change-Id: If02cc9b1ff78e26c1cf8c91ee4695845eb133829
* Add namespace to remaining parts of Wikimedia\Mime and Wikimedia\StatsJames D. Forrester2024-09-271-1/+1
| | | | | Bug: T353458 Change-Id: If0137003ab625017d322d57870448a02569668c3
* Add namespace to remaining parts of Wikimedia\ObjectCacheJames D. Forrester2024-09-272-2/+2
| | | | | Bug: T353458 Change-Id: I3b736346550953e3b2977c14dc3eb10edc07cf97
* Merge "Parsoid SiteConfig: allow stat counters incremented by arbitrary values"jenkins-bot2024-08-191-0/+8
|\
| * Parsoid SiteConfig: allow stat counters incremented by arbitrary valuesC. Scott Ananian2024-08-191-0/+8
| | | | | | | | | | | | Bug: T354908 Bug: T369719 Change-Id: I9ad5cbb9e26138fda1965f3fa4a677c15cb41d07
* | Move Language and friends into Language namespaceJames D. Forrester2024-08-106-9/+9
| | | | | | | | | | Bug: T353458 Change-Id: Id3202c0c4f4a2043bf97b7caee081acab684155c
* | tests: Make use of ?? and ??= operators in test codethiemowmde2024-08-081-4/+1
|/ | | | | | | | | | I believe the more recent syntax is quite a bit more readable. The most obvious benefit is that it allows for much less duplication. Note this patch is intentionally only touching tests, so it can't have any effect on production code. Change-Id: Ibdde9e37edf80f0d3bb3cb9056bee5f7df8010ee
* Extract StatsFactory methods in parsoid SiteConfigYiannis Giannelos2024-07-101-0/+54
| | | | | | | | | * Its not very clean to import Wikimedia\Stats in parsoid * Mediawiki depends on parsoid * As a workaround we can extract the 2 methods we need in SiteConfig Bug: T354908 Change-Id: I696131cfba6ccc26ae1f705f216e221a7c3db175
* Add namespace to the root classes of ObjectCacheEbrahim Byagowi2024-07-101-1/+1
| | | | | | | | | And deprecated aliases for the the no namespaced classes. ReplicatedBagOStuff that already is deprecated isn't moved. Bug: T353458 Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
* tests: Use namespaced classes (2)Umherirrender2024-06-131-1/+1
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statement done manually Change-Id: I4ff4d0c10820dc2a3b8419b4115fadf81a76f7a2
* Make $headers['content-language'] a string instead of Bcp47CodeIsabelle Hurbain-Palatin2024-06-111-0/+8
| | | | | | | Page bundle headers should not contain objects, as they are supposed to represent plaintext HTTP headers. Change-Id: I2a87a8233b9e42cbafdba63bdf513abe00d826ce
* Merge "Move ParsoidOutputAccess::supportsContentModel() into Parsoid SiteConfig"jenkins-bot2024-05-221-0/+2
|\
| * Move ParsoidOutputAccess::supportsContentModel() into Parsoid SiteConfigC. Scott Ananian2024-05-221-0/+2
| | | | | | | | | | | | | | | | | | | | The `supportsContentModel` method is really querying Parsoid for the set of content models it supports, so it makes sense to put it in the Parsoid-specific SiteConfig service. This is part of the work to deprecate and remove ParsoidOutputAccess. Change-Id: I81eb2df8cef93ede95361a4e03185b3d58e5b84b
* | Parser: Inject service LanguageNameUtilsFomafix2024-05-201-0/+2
|/ | | | Change-Id: Ia9884f991550c96e4d9bbca9bfb882144716cd24
* Remove all @package commentsthiemowmde2024-05-102-2/+0
| | | | | | | | | | | | I don't think these do anything with the documentation generators we currently use. Especially not in tests. How are tests part of a "package" when the code is not? Note how most of these are simply identical to the namespace. They are most probably auto-generated by some IDEs but don't actually mean anything. Change-Id: I771b5f2041a8e3b077865c79cbebddbe028543d1
* Merge "Re-enable test after bumping Parsoid"jenkins-bot2024-04-221-4/+3
|\
| * Re-enable test after bumping ParsoidArlo Breault2024-04-191-4/+3
| | | | | | | | | | Follows-Up: I10b77b800dd23f00707011f545817182d3cb58b7 Change-Id: Id1b684876b6fbcafc96e4ae35cd9712720bad1c9
* | Merge "Skip test to bump Parsoid version"jenkins-bot2024-04-221-1/+2
|\|
| * Skip test to bump Parsoid versionArlo Breault2024-04-191-1/+2
| | | | | | | | | | | | | | The method was moved / renamed. Needed-By: I441699e7fe9827a5e06e4638ce88c685deb9b856 Change-Id: I10b77b800dd23f00707011f545817182d3cb58b7
* | Fix some line indentUmherirrender2024-04-201-2/+2
|/ | | | Change-Id: I8f82724197d20f9289d80e138d80310f1eab29f2
* Add __debugInfo to MediaWikiTestCaseTrait::createNoOpMockthiemowmde2024-04-101-1/+1
| | | | | | | | | | | I keep running into this whenever I use createNoOpMock. I think it's XDebug that's calling this method, and then PHPUnit flooding the console with extremely long stack traces. We pretty much never do anything custom with this method: https://codesearch.wmcloud.org/search/?q=__debugInfo&files=%5C.php%24 Change-Id: Ib2ab86fb243555f5e4449ed72cb032cb465e415d
* parser: Remove explicit StatsdDataFactory backward-compat logicDerick Alangi2024-03-261-2/+2
| | | | | | | | | | | | | This is a follow-up to: I0b683461212a357c7eb09ddec59c87539e323c65 and I40a8372a76f33c5f62ea73bb1180dd7c47412c89 which explicitly for backward compatibility reasons supports IBufferingStatsdDataFactory. Now that we've fully switched to StatsFactory together with the `copyToStatsdAt()` method, we're fine to fully remove this `instanceof` logic. Bug: T356815 Change-Id: I164d82904b6d3fb575cb973c14f9454569bf09ac
* Merge "HtmlOutputRendererHelper: fall back to page language"jenkins-bot2024-03-131-2/+32
|\
| * HtmlOutputRendererHelper: fall back to page languagedaniel2024-03-061-2/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | HtmlOutputRendererHelper should not crash hard if the ParserOutput has no language set. ParserOutput may come from a variety of places, we should be lenient about it not having a language. However, we should try harder to actually set a language on ParserOutput if we have one available. So this also updates PageBundleParserOutputConverter to keep the ParserOutput's language in sync wit the language header in the PageBundle. Bug: T349868 Bug: T353689 Bug: T359426 Change-Id: I2edf20dc3b199e22cda2f32bc858c21ca7d8f4bd
* | Merge "test: Add PHPUnit tests for ParsoidParserFactory"jenkins-bot2024-03-131-0/+68
|\ \
| * | test: Add PHPUnit tests for ParsoidParserFactoryDoğu Abaris2024-02-181-0/+68
| | | | | | | | | | | | | | | | | | | | | Covered: - `testCreate`: Test the create method to create a new Parsoid parser. Change-Id: I8aba66397e3beae5ddb765398a4ff83a606f4076
* | | test: Add PHPUnit tests for PageContentDoğu Abaris2024-03-081-0/+219
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | Covered: - Constructor initialization with correct dependencies. - Retrieve roles assigned to page content. - Check if the specified role exists in the page content slots. - Retrieve model name for specified role in page content - Handle exception for non-existent role when retrieving model - Retrieve content format for specified role in page content - Retrieve serialized content for specified role in page content - Handle exception for non-existent role when retrieving content Change-Id: Ia2129e37b15bb8c09c0b26e487a9e311e66b932f
* | build: Upgrade mediawiki/mediawiki-codesniffer to v43.0.0James D. Forrester2024-03-011-24/+24
| | | | | | | | | | Depends-On: I5349d3378b5acd04f0d7c60072a9b1e3dd8f2052 Change-Id: I3b7fd4c460418e72ed0c36febef75f41bad0afb1
* | Merge "[ParserOutput] Rename $mText to $mRawText and ::setText() to ↵jenkins-bot2024-02-211-1/+1
|\ \ | | | | | | | | | ::setRawText()"
| * | [ParserOutput] Rename $mText to $mRawText and ::setText() to ::setRawText()C. Scott Ananian2024-02-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ParserOutput::getText() is not a simple getter, but does transformations on the "text" of the ParserOutput; the simple getter is named ::getRawText(). To maintain consistency, rename ParserOutput::setText() to ::setRawText() and the property name ParserOutput::$mText to ::$mRawText so future readers are not confused. The JSON property name as it appears in the serialized ParserCache is left as 'Text' so that we don't have any forward- or backward- rollback issues. Change-Id: I3ef34814ab9473cc70d0a6806e8c5a4a02b73491
* | | [Parsoid\Config\SiteConfig] enable Parsoid support for disabling magic linksC. Scott Ananian2024-02-171-0/+5
| |/ |/| | | | | | | Bug: T145590 Change-Id: Ic35c964e1ae224ca6985ddc01ad9eda5671fb7b6
* | tests: Fix @covers and @coversDefaultClass to have leading \Reedy2024-02-164-8/+8
| | | | | | | | Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
* | tests: Add or fix Parser test namespacesReedy2024-02-168-7/+48
| | | | | | | | | | Bug: T357823 Change-Id: I1d07ff559f4607ba98bc834a1432e014f3ebdd35
* | tests: Add Tests to PHP namespacingReedy2024-02-162-2/+4
| | | | | | | | Change-Id: I849268172751d50292e93aa75abe8094873f56bc
* | Move Parser to Mediawiki\Parser namespaceSubramanya Sastry2024-02-163-1/+3
|/ | | | | | | | 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
* Allow filter: in inline CSS.Brian Wolff2024-02-131-10/+0
| | | | | | | | | | | | | | | | | This was banned because it could be used to load other files, including potentially local files, in IE9 and earlier. This browser is no longer relevant. Wikimedia sites stopped supporting the needed TLS versions for that browser 4 years ago. Modern browsers have redefined filter to mean something different. Generally the new filter is perfectly safe as long as we ban the url() function which we do. For context on why it was originally banned, see https://static-codereview.wikimedia.org/MediaWiki/66990.html Bug: T308160 Change-Id: Ic94f499dfe66e3cce12496893d0ecbee006bd243
* Move ParsoidRenderID to MediaWiki\EditC. Scott Ananian2024-02-071-71/+0
| | | | | | | | | This class belongs with the rest of the Parsoid output stash code. This class has been marked @unstable since 1.39 and thus the move does not need release notes. Change-Id: I16061c0c28b1549fbe90ea082cc717fee4a09a6e
* Add ParserOutput::{get,set}RenderId() and set render id in ContentRendererC. Scott Ananian2024-02-071-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Set the render ID for each parse stored into cache so that we are able to identify a specific parse when there are dependencies (for example in an edit based on that parse). This is recorded as a property added to the ParserOutput, not the parent CacheTime interface. Even though the render ID is /related/ to the CacheTime interface, CacheTime is also used directly as a parser cache key, and the UUID should not be part of the lookup key. In general we are trying to move the location where these cache properties are set as early as possible, so we check at each location to ensure we don't overwrite a previously-set value. Eventually we can convert most of these checks into assertions that the cache properties have already been set (T350538). The primary location for setting cache properties is the ContentRenderer. Moved setting the revision timestamp into ContentRenderer as well, as it was set along the same code paths. An extra parameter was added to ContentRenderer::getParserOutput() to support this. Added merge code to ParserOutput::mergeInternalMetaDataFrom() which should ensure that cache time, revision, timestamp, and render id are all set properly when multiple slots are combined together in MCR. In order to ensure the render ID is set on all codepaths we needed to plumb the GlobalIdGenerator service into ContentRenderer, ParserCache, ParserCacheFactory, and RevisionOutputCache. Eventually (T350538) it should only be necessary in the ContentRenderer. Bug: T350538 Bug: T349868 Followup-To: Ic9b7cc0fcf365e772b7d080d76a065e3fd585f80 Change-Id: I72c5e6f86b7f081ab5ce7a56f5365d2f75067a78
* tests: Use namespaced class names in @covers annotationsUmherirrender2024-01-271-6/+6
| | | | | | Assist from 8c9cb701e56226cac43fee2fa24b0d0e586f1733 Change-Id: I47897c499028d9e24c00ad0bc6ba7fd8002d9bc1
* Replace more instances of deprecated MWExceptionDaimona Eaytoy2024-01-191-21/+0
| | | | | Bug: T328220 Change-Id: Iba90f7f9b5766bccc05380d040138d74d5e9558a
* Namespace ParserOutputJames D. Forrester2023-12-141-1/+1
| | | | | | | Most used non-namespaced class! Bug: T353458 Change-Id: I4c2cbb0a808b3881a4d6ca489eee5d8c8ebf26cf
* tests: Use namespaced classesUmherirrender2023-12-111-0/+3
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statements and changes to docs done manually Change-Id: Ib326ae1e5c8409a98398c721e8b8ce42c73bd012
* Merge "Only cache expensive renderings"jenkins-bot2023-11-302-0/+111
|\
| * Only cache expensive renderingsdaniel2023-11-302-0/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pages that are fast to render can be omitted from the parser cache to preserve disk space and cache write operations. The threshold is configurable per namespace, so the tradeoff can be evaluated based on different access patterns. For example, pages that are accessed rarely, like file description pages on commons, may have a high threshold configured, while pages that are read frequently, like wikipedia articles, may be configured to be always cached, using a 0 threshold. Filtering is based on a time profile recorded in the ParserOutput. A generic mechanism for capturing the timing profile is implemented in the ContentHandler base class. Subclasses may implement a more rigorous capture mechanism. Bug: T346765 Change-Id: I38a6f3ef064f98f3ad6a7c60856b0248a94fe9ac
* | Move user options related classes into its own namespaceMartin Urbanec2023-11-292-2/+2
|/ | | | | | | | | | | | | There are a couple of user options related classes already, and the T321527 work on dynamic defaults is going to add even more. Let's move them into a separate namespace to make core a bit more organized. Old name is kept as an alias for compatibility purposes. Bug: T321527 Bug: T352284 Change-Id: I9822eb1553870b876d0b8a927e4e86c27d83bd52
* Add PHPUnit test for MagicWord classthiemowmde2023-11-212-0/+51
| | | | | | | This is much more trivial than e.g. MagicWordArray. Still deserves it's own test, in my opinion. Change-Id: I1c19c9c1e51fd210a3827a2200153686f7205eee