aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/page
Commit message (Collapse)AuthorAgeFilesLines
* storage: Assert CategoryMembershipChangeJob via traitMáté Szabó2025-04-043-3/+27
| | | | | | | | | | | | | | | | | | | | | | Why: - As suggested on I14944639e00407f59380c8787fd2810c7d24a5c9, ChangeTrackingUpdateSpyTrait is a better place to assert on operations performed by ChangeTrackingEventIngress than DerivedPageDataUpdaterTest. What: - Add an expected number of enqueued CategoryMembershipChangeJobs to ChangeTrackingUpdateSpyTrait. - Update tests using the trait to specify the expected number of jobs. - Clear hooks in relevant tests to avoid test failures when extensions are loaded that attempt to call methods on the mocks set by ChangeTrackingUpdateSpyTrait. These tests currently fail if e.g. PageTriage, Echo or EventBus are loaded. Bug: T390636 Change-Id: I6fe6cb87cd5a16b1ed39e0998c49713704633d71
* page: Remove deprecated PageArchive::undeleteAsUserUmherirrender2025-03-261-55/+0
| | | | | Bug: T339394 Change-Id: I4c7dd048913ee3d62982ec3bcbdb37548bd56280
* DomainEvents: Model page state before/afterdaniel2025-03-251-3/+3
| | | | | | | | | | | | | | | | Why: - PageStateEvent models a change in page state, so it should provide access to the state before and after What: - add getPageRecordBefore() and getPageRecordAfter() to PageStateEvent - Move getPage() from PageStateEvent down to PageRevisionUpdatedEvent. - Add getPageId() to PageStateEvent. - Add getDeletedPage to PageDeletedEvent Bug: T388588 Depends-On: I76b09f2275a74d02e5701de2082d6b256d6b3b78 Change-Id: I94c52c0314e5dbe9adf82aab732f2e54ca42f686
* [OutputPage] replace ParserOutput::getText() options with ParserOptions, v2C. Scott Ananian2025-03-211-1/+3
| | | | | | | | | | | | | | | Suppress TOC, section edit links, and set wrapper div class via ParserOptions, instead of by passing options to ParserOutput::getText(). In the process deprecate the public OutputPage::parserOptions(), which is no longer used internally, and add OutputPage::addTOCPlaceholder() to DRY out some oft-repeated code. Bug: T350626 Depends-On: I6c12db1e0c42fe5b50ef43a9b6ff6804f44081ea Depends-On: I0d557951b8e17de05e8ceadeb6c18d3811bbdaa8 Change-Id: Iec19f9f08a4d88ea534ffa7b24e6e01ffbba2723
* Namespace all remaining files in includes/pageJames D. Forrester2025-03-1810-35/+51
| | | | | Bug: T353458 Change-Id: I7a9c74f2106655d41ae029742090253f541bd4a6
* DomainEvents: Rename getOldRevision and getNewRevisiondaniel2025-03-153-10/+10
| | | | | | | | | | | | | Why: - Use consistent naming scheme based on "before" and "after" to represent the change. What: - rename getOldRevision to getLatestRevisionBefore - rename getNewRevision to getLatestRevisionAfter Bug: T388588 Change-Id: I30078f606f457981987d95def5b2aaae181f0690
* DomainEvents: Rename PageEvent and PageUpdatedEventdaniel2025-03-113-15/+15
| | | | | | | | | | | | Why: - clarify naming after modeling discussions What: - Rename PageEvent to PageStateEvent - Rename PageUpdatedEvent to PageRevisionUpdatedEvent. Bug: T388588 Change-Id: I987c93a443d364782e692e2cf71b878ccbc5a2fa
* Merge "MovePage: emit PageMovedEvent"jenkins-bot2025-03-101-0/+14
|\
| * MovePage: emit PageMovedEventdaniel2025-03-041-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - We want to replace the PageMoveComplete and RevisionfromEditComplete hooks with equivalent events. - Subscribers need a way to follow page moves and need access to the old and the new title. What: - Introduce PageMovedEvent - Emit PageMovedEvent in addition to PageUpdatedEvent. Bug: T383423 Change-Id: I4d7eb1a0bcb71ac17b4f42971268c0912f4bc5a5
* | WikiPage: Emit PageUpdatedEvent when protection changesdaniel2025-03-071-9/+30
|/ | | | | | | | | | | | | Why: - All changes that cause a dummy revision to be created should trigger a PageUpdatedEvent. What: - Make WikiPage::doUpdateRestrictions use PageUpdater Bug: T198297 Bug: T384691 Change-Id: Ib3196c2d9b964d149d733688bfc7a8d2b5733f4e
* DomainEvents: More clearly model null edits and dummy revisionsdaniel2025-02-262-9/+49
| | | | | | | | | | | | | | | | | | | | | | | | Why: - Listeners that want to skip processing if the page content didn't change should generally not skip reconciliation requests. PageUpdatedEvent should offer getters that make this straightforward. What: - Add isNominalContentChange that will return false for dummy revisions but true for null edits. This is the preferred way for listeners to determine whether they can skip redundant processing of page content. - Rename isContentChange to isEffectiveContentChange, to distinguish it from isNominalContentChange. - Rename isRevisionChange to isRevisionHistoryChange, to make it clear that the change affects the sequences of revisions. - Add test cases to PageUpdaterTest asserting the expected update propagation for null edits and dummy revisions. - Change ingress objects so that: - the message cache is updated for null edits - module caches are not cleared for dummy revisions Bug: T383552 Change-Id: Idf6625d3e737e4a225648b0fd81cc929b095d315
* PageUpdater: allow dummy revisions to be minordaniel2025-02-241-1/+7
| | | | | | | | | | | | | | Why: - When introducing saveDummyRevision() in I1f8c0ac68b, we didn't account for the fact that most (but not all) dummy revisions should be marked as minor edits. What: - Add a $flag parameter to saveDummyRevision() Bug: T198297 Bug: T387067 Change-Id: I1db3ccc816cdb0e2a93593625306a9080b7204eb
* PageUpdatedEvent: improve modeling of flagsdaniel2025-02-202-4/+7
| | | | | | | | | | | | | | | | Why: - Improve consistency, naming, documentation and definition of flags. What: - remove direct access to flags, provide a separate getter for each flag instead. - Deprecate EDIT_SUPPRESS_RC in favor of EDIT_SILENT - Introduce EDIT_IMPLICIT to replace "automated" mode - Introduce FLAG_RECONCILIATION_REQUEST into PageEvent. - Introduce isReconciliationRequest into DomainEvent. Bug: T383552 Change-Id: I2bffbb5810376829f871e1840ca799a8d8232dda
* Dummy revisions: add tests for event emissiondaniel2025-02-101-1/+96
| | | | | | | | | | | Why: before we change how we do dummy revisions, we should have tests in place that check which events and hooks get fired, and how updates to other parts of the system propagate when dummy revisions are inserted. This protect us from unexpected changes in behavior. Bug: T198297 Bug: T384691 Change-Id: I1f8c0ac68b91f101699fe9a9cf9ccbada514030a
* Merge "DomainEvents: introduce ExpectCallbackTrait"jenkins-bot2025-01-302-20/+10
|\
| * DomainEvents: introduce ExpectCallbackTraitdaniel2025-01-302-20/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | Why: - Improve test readability by removing awkward boiler plate code for checking whether an event or hook was triggered. What: - Introduce ExpectCallbackTrait for asserting the number of times an event or hook was triggered. Bug: T376063 Change-Id: I97f83f38c0fd14c041525f8faa00cc164d7d1124
* | Merge "Use Remex/HtmlHelper to implement Parser::replaceTableOfContents"jenkins-bot2025-01-291-2/+2
|\ \ | |/ |/|
| * Use Remex/HtmlHelper to implement Parser::replaceTableOfContentsC. Scott Ananian2025-01-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is more robust and secure than the regular expression previously used to extract the <meta> tag. We also improve HtmlHelper slightly be adding the ability to replace an element with an 'outerHTML' string. Because our output is being run through Remex, there is a slightly larger degree of HTML normalization in the output than previously, which is visible in some small tweaks to test case outputs. Bug: T381617 Depends-On: I2712e0fa9272106e8cd686980f847ee7f6385b6f Change-Id: I4cb2f29cf890af90f295624c586d9e1eb1939b95
* | Tests: assert updates on page lifecycle changesdaniel2025-01-242-32/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - We want to refactor code that performs page lifecycle changes, such as edit, create, delete, import, etc. - The goal of the refactoring is to apply the observer pattern in order to remove direct dependencies from page related code on code that needs to be notified of the change. - Before we start refactoring, we should cover the current behavior in tests. What - Rename and clarify semantics of spy traits introduced earlier. - Add coverage for talk page notifications - Add coverage for resource loader module cache updates - Fix dirty entries in Title instance cache after deletion Bug: T378936 Change-Id: If06e2aa5bda84dfbee3278bf4a8d16064b6effc8
* | DeletePage: clear Title instance cachedaniel2025-01-241-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - Title::newFromText puts Title objects into a static cache array to avoid parsing the same title text multiple times. - After page deletion, objects in that cache may still reflect the state prior to deletion. What: - Make DeletePage call Title::clearCaches() - Also add checks for the same issue to MovePageTest. Change-Id: I26a4aab19212ba5182b6ef3e9873a994954b4072
* | PageUpdatedEvent: explicitly model cause and performerdaniel2025-01-212-33/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces the concept of a "cause" and "performer" into PageUpdatedEvent. Causes are e.g. "edit" or "import" or "move". The performer is the same as the author for edits, but not necessarily for undeletions, moves, etc. Note that cause and performer were already being tracked in DerivedPageDataUpdater for logging purposes. PageUpdatedEvent was modeling the cause using flags. This change formalizes the concept of "cause" and "performer" and ensures it is handled consistently. As an aside, this simplifies some test cases in DerivedPageDataUpdaterTest to avoid confused state. Bug: T383031 Bug: T383095 Change-Id: I79bde5604790636c91848f265fffd81d6348a8b4
* | DomainEvent: Support type hierarchiesdaniel2025-01-212-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: - It's useful to be able to listen to sets of compatible event types. What: - Make DomainEvents aware of a list of types they are compatible with. - Make EventDispatchEngine dispatch to all compatible listeners, registered for any of the supported types. - Move all page events to their own namespace Bug: T384330 Change-Id: I96bde2cfaf198e409a6ef3a24101ee7d02d57959
* | Remove 2-line PHPDocs that just repeat the types from the codethiemowmde2025-01-171-4/+0
|/ | | | | | | | | | | | | | | | Same as Ia294bf4 did for 1-line comments. This patch removes slightly more complex 2-line PHPDoc comments that don't add any new information to the code, but literally repeat what the code already says. They say "don't document the code, code the documentation", and we are doing this more and more. We just tend to forget to remove the obsolete comments. Note I'm also removing a line of text in a few cases when it's very short and literally says the same as the method name. Again, such comments add zero new information. Change-Id: I01535404bab458c6c47e48e5456403b7a64198ed
* ParserOutputAccess: add tracing spansChris Danis2025-01-061-1/+5
| | | | | | | | Example output: https://phabricator.wikimedia.org/F58134893 Bug: T340552 Change-Id: Ib9ee43f1b10655a674f32339d5ec139e4551fa0a
* Ensure necessary updates are performed on import and undeletedaniel2024-12-123-0/+191
| | | | | | | | | | | | | | | | | | | | | | In Ice76519 we lost the mechanism for triggering updates for the search index and message cache on import and undeletion. This change restores the trigger for these updates. To achieve this, the logic for instantiating PageUpdatedEvents is moved into DerivedPageDataUpdater. Perhaps the firing of the event can be moved into that class eventually. To improve consistency, the flags field in PageUpdatedEvent is changed from a bitmap corresponding to the flags field in PageUpdater to an array corresponding to the options array in DerivedPageDataUpdater. For regression testing, this change defines new test traits, one for each ingress. These traits define the expected behavior of each ingress in each relevant situation (edit, move, import, and undeletion). Bug: T381225 Bug: T381299 Change-Id: Ib0d1dd143160fb64d42cacfbc75fbb55f5614c1c
* tests: Don't throw exceptions on tearDown()Tim Starling2024-12-041-2/+2
| | | | | | | | | | Throwing an exception from tearDown() causes any other "after" test hooks to be skipped, which can cause distracting unrelated errors. PHPUnit provides assertPostConditions() as a safe place to put assertions that run after every test in the class. Bug: T354387 Change-Id: I8817fdccfd6716ad2456b17c1a32bbcecc971cb5
* WikiPage: Run ArticleProtect and ArticleProtectComplete for saltingDreamy Jazz2024-11-081-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: * WikiPage::doUpdateRestrictions allows users to protect non-existing titles (otherwise known as "salting"). * However, the ArticleProtect and ArticleProtectComplete hooks are not run when protecting non-existing titles. * The definitions of these hooks do not imply that they are only run for existing titles. ** In 46c5d3edad6b9f07aa49ca382912019f4081f7a0, the ability to protect non-existing titles using WikiPage::doUpdateRestrictions was added such that these hooks were not called. However, there are no comments suggesting that the hooks should not be called. ** The hooks are passed WikiPage instances, which can be for non existing titles. * Calling these hooks when salting a title should not cause any problems based on a codesearch and because the properties about the title being protected are accessed through WikiPage (which already handles non-existing titles). * Doing this will allow code to prevent title protection in specific cases using the ArticleProtect hook and also log when title protections occur using ArticleProtectComplete. What: * Update WikiPage::doUpdateRestrictions to run ArticleProtect and ArticleProtectComplete hooks for title protections as well as normal protections. * Indicate this in the RELEASE NOTES so that any third-party code is aware of this change. * Update tests for this change. Bug: T375502 Change-Id: I5a28ff9f4c5e931901a2aecfed5e5c85242aaae6
* Use ContentLanguageCode service instead of heavy Language objectAmir Sarabadani2024-11-022-2/+2
| | | | | | | Improving coupling. Bug: T376565 Change-Id: I109662cc957e1a64396348d7c2f5d2eadedb9722
* Merge "Use ++ and -- rather than += 1 and -= 1"jenkins-bot2024-10-231-1/+1
|\
| * Use ++ and -- rather than += 1 and -= 1Reedy2024-10-171-1/+1
| | | | | | | | Change-Id: I27b9a19ab952ede1267921bd042af0fe1c89e228
* | tests: Use namespaced classesUmherirrender2024-10-216-0/+9
|/ | | | | | | | 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
* Use explicit nullable type on parameter argumentsUmherirrender2024-10-162-2/+2
| | | | | | | | | | | 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
* Merge "[JsonCodec] Use wikimedia/json-codec to implement JsonCodec"jenkins-bot2024-10-161-2/+2
|\
| * [JsonCodec] Use wikimedia/json-codec to implement JsonCodecC. Scott Ananian2024-10-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds support for serializing/deserializing objects which implement the JsonCodecable interface from the wikimedia/json-codec library used by Parsoid. JsonCodecable allows customizing the encoding of objects of a given class using a class-specific codec object, and JsonCodecable is an interface which is defined and can be used outside mediawiki core. In addition json-codec supports deserialization in the presence of aliased class names, fixing T353883. Backward and forward compatibility established via the mechanism described in https://www.mediawiki.org/wiki/Manual:Parser_cache/Serialization_compatibility Test data generated by this patch was added in I109640b510cef9b3b870a8c188f3b4f086d75d06 to ensure forward compatibility with the output after this patch is merged. Benchmarks: PHP 7.4.33 PHP 8.2.19 PHP 8.3.6 BEFORE AFTER BEFORE AFTER BEFORE AFTER Serialize: 926.7/s 1424.8/s 978.5/s 1542.4/s 1023.5/s 1488.6/s Serialize (assoc): 930.2/s 1378.6/s 974.6/s 1541.9/s 1022.4/s 1463.4/s Deserialize: 1942.7/s 1961.3/s 2118.8/s 2175.9/s 2129.8/s 2063.5/s Deserialize (assoc): 1952.0/s 1905.7/s 2107.5/s 2192.1/s 2153.3/s 2011.1/s These numbers definitely do not have as many significant digits as written here. But they should be sufficient to demonstrate that performance is not impaired by this patch and in fact serialization speed improves slightly. Bug: T273540 Bug: T327439 Bug: T346829 Bug: T353883 Depends-On: If1d70ba18712839615c1f4fea236843ffebc8645 Change-Id: Ia1017dcef462f3ac1ff5112106f7df81f5cc384f
* | Add namespace to remaining parts of Wikimedia\ObjectCacheJames D. Forrester2024-09-271-0/+1
|/ | | | | Bug: T353458 Change-Id: I3b736346550953e3b2977c14dc3eb10edc07cf97
* Add namespace to IDBAccessObject and DBAccessObjectUtilsJames D. Forrester2024-09-273-1/+3
| | | | | Bug: T353458 Change-Id: I23cf7991f8792d4d000d1780463d8ce76dc0aee0
* tests: Use const for some static data in test filesUmherirrender2024-09-011-10/+10
| | | | Change-Id: Id7ccd48e3bf626095e2d3929831b5d87ed0be948
* Merge "Remove ParserOutput::getText() calls from core (direct pipeline)"jenkins-bot2024-08-242-2/+6
|\
| * Remove ParserOutput::getText() calls from core (direct pipeline)Isabelle Hurbain-Palatin2024-08-232-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the second patch of a series of patches to remove ParserOutput::getText() calls from core. This series of patches should be functionally equivalent to I2b4bcddb234f10fd8592570cb0496adf3271328e. This patch replaces the calls to getText where the legacy parser is called directly by creating a pipeline and invoking it on the generated. These should probably eventually use the Content framework to generate output instead of using Parser directly (T371008), which will also allow them to transparently support Parsoid. Bug: T293512 Change-Id: I45951a49e57a8031887ee6e4546335141d231c18
* | Merge "Migrate ParserOutputAccess metrics to statslib"jenkins-bot2024-08-231-3/+3
|\ \ | |/ |/|
| * Migrate ParserOutputAccess metrics to statslibYiannis Giannelos2024-08-231-3/+3
| | | | | | | | | | Bug: T359372 Change-Id: I5450251dff31d55a9a46b7fe885c27cd6ba083bf
* | Remove ParserOutput::getText() calls from core (getRawText)Isabelle Hurbain-Palatin2024-08-191-3/+2
|/ | | | | | | | | | | | 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
* Move remaining four classes in includes/content into Content namespaceJames D. Forrester2024-08-101-1/+2
| | | | | Bug: T353458 Change-Id: Ia0f3e22078550be410c4b87faf6aa4eabe6e270d
* Add namespace to WikitextContentEbrahim Byagowi2024-08-065-0/+5
| | | | | | | It adds MediaWiki\Content namespace to WikitextContent and two classes related. Change-Id: Ib74e4c5b3edac6aa0e35d3b2093ce1d0b794cb6d
* Replace deprecated LogFormatter::newFromRow/newFromEntryUmherirrender2024-07-291-1/+2
| | | | Change-Id: I453ce3148a46fcb9cc5c685cee92274e0cb4f98a
* page: Hard-deprecate PageArchive::undeleteAsUserUmherirrender2024-07-211-0/+2
| | | | | | Bug: T339394 Depends-On: Iccaf9a9ef141570ed315cb7caefba29a920c5527 Change-Id: Ib3015784e6e0b5e785c5d738268189f651ccdc12
* [HtmlOutputRendererHelper] Remove use of ParsoidOutputAccess::parseUncacheableC. Scott Ananian2024-07-191-4/+0
| | | | | | | | | This removes the last use of ParsoidOutputAccess in core, allowing it to be deprecated and eventually removed. Bug: T367074 Bug: T317018 Change-Id: Ica2c880e2e7c2b126aaea66a3e4be460b3f2234f
* Merge "Use MainConfigNames constants in tests where possible"jenkins-bot2024-07-114-16/+16
|\
| * Use MainConfigNames constants in tests where possiblethiemowmde2024-07-104-16/+16
| | | | | | | | | | | | | | 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
* | Merge "Add namespace to the root classes of ObjectCache"jenkins-bot2024-07-101-0/+2
|\ \