aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/jobqueue
Commit message (Collapse)AuthorAgeFilesLines
* Namespace all remaining files in includes/jobqueueJames D. Forrester2025-03-209-11/+34
| | | | | Bug: T353458 Change-Id: I95690a312e356c45dbeed607d32fb0e4626690cf
* RefreshLinksJob: Don't retry job if "Revision x is not current" is returnedPaladox2024-11-151-1/+2
| | | | | | | | | There's no point in retrying a job when you get "Revision x is not current". It just causes log spam. Makes people think there's a problem when there isn't as it logs in the error channel. Bug: T379656 Change-Id: Iaa5bd006bf3f26277e81ad5bea1387ef4b925f68
* tests: Use namespaced classesUmherirrender2024-10-212-0/+2
| | | | | | | | Changes to the use statements and some additions are done automatically via script This also updates @covers tag for the namespaced classes Change-Id: I859ba6d05018c99710b744e2becab432410d3bca
* Merge "Use import actor store where needed in RC categorisation"jenkins-bot2024-10-031-3/+3
|\
| * Use import actor store where needed in RC categorisationDreamy Jazz2024-10-021-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - When temporary users are enabled, creating IP actors is disallowed apart from specific cases, such as importing revisions authored by anonymous users. - If such a revision includes a category link and wgRCWatchCategoryMembership is true, MediaWiki will fire a job to create a corresponding RC entry, which will attempt to attribute the RC to the anonymous IP that authored the imported revision and fail in doing so. What: - Track whether a category membership change job was triggered by an import, and allow RecentChange objects created by such jobs to create anonymous actors. Test Plan: 1. On a wiki with temporary accounts enabled and wgRCWatchCategoryMembership = true, import a revision via Special:Import that was authored by an anonymous user and contains a category link. 2. Verify that the import succeeds and that the corresponding RC entry shows up. Bug: T373318 Change-Id: I89abdca9c4ab8796a211df8b37c1bd7173a496e5
* | Add namespace to remaining parts of Wikimedia\ObjectCacheJames D. Forrester2024-09-271-0/+1
|/ | | | | Bug: T353458 Change-Id: I3b736346550953e3b2977c14dc3eb10edc07cf97
* tests: Remove unused JobQueueTest::$keyUmherirrender2024-09-051-2/+0
| | | | | | Added unused in 9cc7e6a39a Change-Id: I217b9c906972c1f335e8e7d2b340e86a4d92c5a1
* Remove ParserOutput::getText() calls from core (getRawText)Isabelle Hurbain-Palatin2024-08-191-1/+13
| | | | | | | | | | | | This is the first patch of a series of patches to remove ParserOutput::getText() calls from core. This series of patches should be functionally equivalent to I2b4bcddb234f10fd8592570cb0496adf3271328e. This first patch replaces the calls to getText to calls to ParserOutput::getRawText when the pipeline has no reason to be executed. Bug: T293512 Change-Id: I0ad53cd074ca9cf13e96e6b08179e13aeea180f4
* Add namespace to WikitextContentEbrahim Byagowi2024-08-061-0/+1
| | | | | | | It adds MediaWiki\Content namespace to WikitextContent and two classes related. Change-Id: Ib74e4c5b3edac6aa0e35d3b2093ce1d0b794cb6d
* Replace gettype() with get_debug_type() in debug/log/test outputBartosz Dziewoński2024-07-311-1/+1
| | | | | | | | | | | | | | | | | | | | | get_debug_type() does the same thing but better (spelling type names in the same way as in type declarations, and including names of object classes and resource types). It was added in PHP 8, but the symfony/polyfill-php80 package provides it while we still support 7.4. Also remove uses of get_class() and get_resource_type() where the new method already provides the same information. For reference: https://www.php.net/manual/en/function.get-debug-type.php https://www.php.net/manual/en/function.gettype.php In this commit I'm only changing code where it looks like the result is used only for some king of debug, log, or test output. This probably won't break anything important, but I'm not sure whether anything might depend on the exact values. Change-Id: I7c1f0a8f669228643e86f8e511c0e26a2edb2948
* Stop using LBFactory in UserEditCountInitJobTestthiemowmde2024-07-181-2/+1
| | | | | | | | I believe almost all other code was already updated to use the much more narrow ConnectionProvider instead. I believe this was just forgotten. Change-Id: I07ef12bed522eea263806b09c9b4c8cb56723334
* Merge "Use MainConfigNames constants in tests where possible"jenkins-bot2024-07-111-1/+1
|\
| * Use MainConfigNames constants in tests where possiblethiemowmde2024-07-101-1/+1
| | | | | | | | | | | | | | I believe this makes the code less brittle, and also makes it a bit more obvious what these strings are meant to represent. Change-Id: Ia39b5c80af4b495931d0a68fd091b783645dd709
* | Add namespace to the root classes of ObjectCacheEbrahim Byagowi2024-07-101-0/+1
|/ | | | | | | | | And deprecated aliases for the the no namespaced classes. ReplicatedBagOStuff that already is deprecated isn't moved. Bug: T353458 Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
* Merge "[ParsoidCachePrewarmJob] Use ParserOutputAccess"jenkins-bot2024-06-283-11/+19
|\
| * [ParsoidCachePrewarmJob] Use ParserOutputAccessC. Scott Ananian2024-06-173-11/+19
| | | | | | | | | | | | | | | | | | | | One more step in gradually replacing uses of ParsoidOutputAccess. This one was pretty easy, as ParsoidOutputAccess was pretty much directly calling ParserOutputAccess when provided with a ExistingPageRecord and RevisionRecord. Bug: T367074 Change-Id: I96161a64952e1809c0aec773d5a3dd4c71105657
* | Replace db with getDb for TestsWandji692024-06-231-4/+4
| | | | | | | | | | Bug: T316841 Change-Id: I29e535e8ee9b5641a4546d53b98cd5060d39681d
* | schema: Drop old pagelinks columnsAmir Sarabadani2024-06-181-3/+6
|/ | | | | | | It has been dropped in production already. Bug: T299947 Change-Id: I8ec1e7d9224c81d6494c39c78df9e4bdac38d377
* Move ParsoidOutputAccess::supportsContentModel() into Parsoid SiteConfigC. Scott Ananian2024-05-223-4/+8
| | | | | | | | | | 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
* Move various job classes to relevant component directoriesTimo Tijhof2024-05-101-98/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Motivation: * Remove need to hardcode out-of-component files in various places. Especially for Gerrit queries, this not only reduces effort but also makes these files more likely to show up in the first place. * Clarify component boundaries and ownership, e.g. when filing tasks with a stack trace. * Now rather than later, to avoid need for multiple class renames and aliases when PSR-4 namespaces are applied later (T166010). Background: Similar to how jobs in extensions belong to that extension, the same is true within core. There is a distinction between the JobQueue system, and individual jobs belonging to a specific feature or component, likewise for deferred updates, and special pages. To make a begin with this, I propose moving the job classes to their respective components for cases where component boundaries are already clear. E.g. due to exclusively being queued by that same component, being named/introduced by the same commit, being already documented as such in component descriptions on mediawiki.org. Bug: T364652 Change-Id: I73d6b97c6ca9f5abd29f4277d0f845426aa23bd0
* Remove auto-generated "Class ClassName" commentsthiemowmde2024-05-061-2/+0
| | | | | | | | This is most certainly auto-generated by some IDEs. Unfortunately there is nothing to learn from such comments. It's just noise. Especially in tests. Change-Id: Idf59332d96ca4718b6ce9d17b4da79a88641d4fd
* RefreshLinksJob: Migrate to StatsFactoryMáté Szabó2024-05-051-1/+52
| | | | | | | | Switch metrics emitted by RefreshLinksJob to use StatsFactory and add relevant tests. Bug: T359365 Change-Id: I8677d72ed92ccf21968353cdff942017d5962511
* Stop using LoadBalancer::getConnectionRef() so it can be hard-deprecatedAmir Sarabadani2024-04-301-1/+1
| | | | | Bug: T326274 Change-Id: I90493d7cd4c21fdc022bcc19765fc04d986a9c8f
* tests: Fix PSR2.Classes.PropertyDeclaration.Multiple errorsTaavi Väänänen2024-04-221-1/+7
| | | | Change-Id: Id4ac60a713391cf6360ff1995f20da94012ac1a0
* tests: Migrate to IDatabase::newUpdateQueryBuilderUmherirrender2024-04-141-6/+6
| | | | | Bug: T353219 Change-Id: Icecc444e6b4d6d2e9f4b13cda2931b10bb753318
* Migrate to IDatabase::newDeleteQueryBuilderUmherirrender2024-04-121-4/+21
| | | | Change-Id: Idf42d67c1b0b311f81a1d60a7a8a6f875f99e864
* tests: Fix @covers and @coversDefaultClass to have leading \Reedy2024-02-1611-14/+14
| | | | Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
* Replace more instances of unchecked MWExceptionDaimona Eaytoy2024-01-231-6/+1
| | | | | | | | Most (all?) of the remaining usages are caught somewhere and will be migrated later. Bug: T328220 Change-Id: I5c36693a5361dd75b4f1e7a0bab5ad48626ed75c
* tests: Use namespaced classesUmherirrender2023-12-112-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
* Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessaryJames D. Forrester2023-11-213-20/+0
| | | | | Bug: T342301 Change-Id: I5ea01f7ee103570165261bde0965c5b65e04c369
* Make ParsoidOutputAccess a wrapper over ParserOutputAccessSubramanya Sastry2023-10-131-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Updated ParserOutput to set Parsoid render ids that REST API functionality expects in ParserOutput objects. * CacheThresholdTime functionality no longer exists since it was implemented in ParsoidOutputAccess and ParserOutputAccess doesn't support it. This is tracked in T346765. * Enforce the constraint that uncacheable parses are only for fake or mutable revisions. Updated tests that violated this constraint to use 'getParseOutput' instead of calling the parse method directly. * Had to make some changes in ParsoidParser around use of preferredVariant passed to Parsoid. I also left some TODO comments for future fixes. T267067 is also relevant here. PARSOID-SPECIFIC OPTIONS: * logLinterData: linter data is always logged by default -- removed support to disable it. Linter extension handles stale lints properly and it is better to let it handle it rather than add special cases to the API. * offsetType: Moved this support to ParsoidHandler as a post-processing of byte-offset output. This eliminates the need to support this Parsoid-specific options in the ContentHandler hierarchies. * body_only / wrapSections: Handled this in HtmlOutputRendererHelper as a post-processing of regular output by removing sections and returning the body content only. This does result in some useless section-wrapping work with Parsoid, but the simplification is probably worth it. If in the future, we support Parsoid-specific options in the ContentHandler hierarchy, we could re-introduce this. But, in any case, this "fragment" flavor options is likely to get moved out of core into the VisualEditor extension code. DEPLOYMENT: * This patch changes the cache key by setting the useParsoid option in ParserOptions. The parent patch handles this to ensure we don't encounter a cold cache on deploy. TESTS: * Updated tests and mocks to reflect new reality. * Do we need any new tests? Bug: T332931 Change-Id: Ic9b7cc0fcf365e772b7d080d76a065e3fd585f80
* tests: Migrate more cases to SQBAmir Sarabadani2023-09-211-12/+10
| | | | | Bug: T344971 Change-Id: Ia69d82d6a6e623b9032240dc910fb47ff5887661
* Namespace TitleValue under \MediaWiki\TitleJames D. Forrester2023-09-181-0/+1
| | | | | | | One of the big ones, so doing this alone. Bug: T166010 Change-Id: I4c901d5c32696d8334ec30cede7d9b6f3d8d645e
* Reorg: Move WebRequest to includes\RequestAmir Sarabadani2023-09-112-0/+2
| | | | | | | This has been approved as part of RFC T166010 Bug: T321882 Change-Id: I6bbdbbe6ea48cc1f50bc568bb8780fc7c5361a6f
* JobQueue: Drop getWiki(), deprecated in 1.33James D. Forrester2023-08-241-16/+0
| | | | Change-Id: I38fdaf0cd8ca98534dcbf64e13925138f8174a0d
* Reorg: Move MWTimestamp to MediaWiki\UtilsAmir Sarabadani2023-08-191-0/+1
| | | | | Bug: T321882 Change-Id: I48c10343295c4eb3d9ef8037343b0070e928f040
* Deprecate MediaWikiIntegrationTestCase::$usersDaimona Eaytoy2023-07-251-9/+4
| | | | | | | | | | | | | | | | | This property shouldn't be needed in modern code, where most things can use Authority. So much so because TestUser adds a dependency on the database, but many tests that use TestUser don't even need the database. ApiTestCase, in particular, sets this property in setUp, thus adding a database dependency to all API tests, including those that don't need users or the database at all. Deprecate the property and replace existing usages in core. The one in ApiTestCase is much harder to migrate, but this patch replaces the array with an anonymous ArrayAccess class to allow lazy initialization and remove DB dependencies. Bug: T155147 Change-Id: I59c4ed1f6a7572d3a92387b15b8e56625bc376a2
* ParsoidCachePrewarmJob: enable deduplicationdaniel2023-07-121-0/+36
| | | | | | | | | | ParsoidCachePrewarmJob should be deduplicated by revision ID. Note that this is not 100% accurate: the same revision may requrie different renderings. However, we don't expect this to be relevant within the short period of time the job spec is in the queue. Bug: T341123 Change-Id: I56a9480132a01a158804a0fccd13b020c7103d08
* Migrate assertSelect() to SelectQueryBuilderTim Starling2023-06-281-36/+30
| | | | | | | | | | * Add MediaWikiIntegrationTestCase::newSelectQueryBuilder(), which creates a subclass of SelectQueryBuilder with assert methods. * Migrate most callers of assertSelect() to this new query builder interface. Bug: T311866 Change-Id: I7392b37988067020d5f684276320dae0a474631a
* Replace usages of deprecated MWExceptionDaimona Eaytoy2023-06-061-1/+1
| | | | | | | Use SPL exceptions instead when the exception is unchecked. Bug: T328220 Change-Id: Ia1e5edc2ef3269a44b670262b78b305d07559829
* objectcache,resourceloader,rdbms,jobqueue: Widen @covers annotationsTimo Tijhof2023-04-103-31/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follows-up I4c7d826c7ec654b, I1287f3979aba1bf1. We lose useful coverage and spend valuable time keeping these accurate through refactors (or worse, forget to do so). The theoretically "bad" accidental coverage is almost never actually bad. Having said that, I'm not removing them wholesale (yet). I've audited each of these specific files to confirm it is a general test of the specified subject class, and also kept it limited to those specified classes. That's imho more than 100% of the benefit for less than 1% of the cost (more because `@covers` is more valuable than the fragile and corrosive individual private method tracking in tests that inevitably get out of date with no local incentive to keep them up to date). Cases like structure tests keep `@coversNothing` etc and we still don't count coverage of other classes. There may be a handful of large legacy classes where some methods are effectively class-like in complexity and that's why it's good for PHPUnit to offer the precision instrument but that doesn't meant we have to use that by-default for everything. I think best practice is to write good narrow unit tests, that reflect how the code should be used in practice. Not to write bad tests and hide part of its coverage within the same class or even namespace. Fortunately, that's generally what we do already it's just that we also kept these annotations still in many cases. This wastes time to keep methods in sync, time to realize (and fix) when other people inevitably didn't keep them in sync, time to find uncovered code only to realize it is already covered, time for a less experienced engineer to feel obligate to and do write a low quality test to cover the "missing" branch in an unrealistic way, time wasted in on-boarding by using such "bad" tests as example for how to use the code and then having to unlearn it months/years later, loss of telemetry in knowing what code actually isn't propertly tested due to being masked by a bad test, and lost oppertunities to find actually ununused/unreachable code and to think about how to instead structure the code such that maybe that code can be removed. ------ Especially cases like LBFactoryTest.php were getting out of hand, and in GlobalIdGeneratorTest.php we even resorted to reminding people with inline comments to keep tags in sync. Change-Id: I69b5385868cc6b451e5f2ebec9539694968bf58c
* Allow setting a ParserOption to generate Parsoid HTMLC. Scott Ananian2023-03-261-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is an initial quick-and-dirty implementation. The ParsoidParser class will eventually inherit from \Parser, but this is an initial placeholder to unblock other Parsoid read views work. Currently Parsoid does not fully implement all the ParserOutput metadata set by the legacy parser, but we're working on it. This patch also addresses T300325 by ensuring the the Page HTML APIs use ParserOutput::getRawText(), which will return the entire Parsoid HTML document without post-processing. This is what the Parsoid team refers to as "edit mode" HTML. The ParserOutput::getText() method returns only the <body> contents of the HTML, and applies several transformations, including inserting Table of Contents and style deduplication; this is the "read views" flavor of the Parsoid HTML. We need to be careful of the interaction of the `useParsoid` flag with the ParserCacheMetadata. Effectively `useParsoid` should *always* be marked as "used" or else the ParserCache will assume its value doesn't matter and will serve legacy content for parsoid requests and vice-versa. T330677 is a follow up to address this more thoroughly by splitting the parser cache in ParserOutputAccess; the stop gap in this patch is fragile and, because it doesn't fork the ParserCacheMetadata cache, may corrupt the ParserCacheMetadata in the case when Parsoid and the legacy parser consult different sets of options to render a page. Bug: T300191 Bug: T330677 Bug: T300325 Change-Id: Ica09a4284c00d7917f8b6249e946232b2fb38011
* tests: Make some PHPUnit data providers staticTim Starling2023-03-242-2/+2
| | | | | | | | | | | | | Just methods where adding "static" to the declaration was enough, I didn't do anything with providers that used $this. Initially by search and replace. There were many mistakes which I found mostly by running the PHPStorm inspection which searches for $this usage in a static method. Later I used the PHPStorm "make static" action which avoids the more obvious mistakes. Bug: T332865 Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
* Reorg: Namespace the Title classJames D. Forrester2023-03-026-0/+6
| | | | | | | | | | | | | | | | | | | 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
* Reorg: Migrate WikiMap to WikiMap/ out of includesAmir Sarabadani2023-02-272-0/+2
| | | | | | | And WikiReference Bug: T321882 Change-Id: I60cf4b9ef02b9d58118caa39172677ddfe03d787
* BacklinkCache: Remove unused internal `clear()` methodTimo Tijhof2023-02-211-4/+3
| | | | | | | | | | Follows-up Ife77661308e042. Remove test call, which hasn't been needed in a little while because it's not a static cache, and services are already reset between tests. Change-Id: I3992e5ae27d8b28a3289d071e8d3f45286b6abf7
* Avoid deprecated usage of `Job::factory()`Derick Alangi2023-01-251-4/+20
| | | | Change-Id: Ia2b8b71159ed8d387ae31f921ddcfd0d9136118c
* Parsoid: cache warming job: add render reasondaniel2023-01-241-1/+7
| | | | | | | | | We want to be able to track what activity causes renders and cache writes. To achieve this, we need to plumb causeAgent and causeAction from DerivedPageDataUpdater through ParsoidCachePrewarmJob to ParserOptions. Change-Id: I0274ec3976a8ef48ccb99156fb4fbeec85048189
* Add dependency injection for Job classesdaniel2023-01-193-17/+102
| | | | | | | Introduces JobFactory Bug: T245900 Change-Id: I094cc9325e5eaf2717ae510ef988a72407195224
* Merge "tests: Handle dynamic created properties on test classes"jenkins-bot2023-01-131-1/+1
|\