aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/page/UndeletePageTest.php
Commit message (Collapse)AuthorAgeFilesLines
* storage: Assert CategoryMembershipChangeJob via traitMáté Szabó2025-04-041-1/+10
| | | | | | | | | | | | | | | | | | | | | | 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
* Namespace all remaining files in includes/pageJames D. Forrester2025-03-181-0/+3
| | | | | Bug: T353458 Change-Id: I7a9c74f2106655d41ae029742090253f541bd4a6
* DomainEvents: Rename getOldRevision and getNewRevisiondaniel2025-03-151-2/+2
| | | | | | | | | | | | | 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-111-5/+5
| | | | | | | | | | | | Why: - clarify naming after modeling discussions What: - Rename PageEvent to PageStateEvent - Rename PageUpdatedEvent to PageRevisionUpdatedEvent. Bug: T388588 Change-Id: I987c93a443d364782e692e2cf71b878ccbc5a2fa
* DomainEvents: More clearly model null edits and dummy revisionsdaniel2025-02-261-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | 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
* PageUpdatedEvent: improve modeling of flagsdaniel2025-02-201-1/+2
| | | | | | | | | | | | | | | | 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
* DomainEvents: introduce ExpectCallbackTraitdaniel2025-01-301-10/+5
| | | | | | | | | | | | | 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
* Tests: assert updates on page lifecycle changesdaniel2025-01-241-18/+47
| | | | | | | | | | | | | | | | | | | | 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
* PageUpdatedEvent: explicitly model cause and performerdaniel2025-01-211-16/+10
| | | | | | | | | | | | | | | | | | | | | 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-211-1/+1
| | | | | | | | | | | | | | 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
* Ensure necessary updates are performed on import and undeletedaniel2024-12-121-0/+87
| | | | | | | | | | | | | | | | | | | | | | 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: Use namespaced classesUmherirrender2024-10-211-0/+1
| | | | | | | | 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
* Allow undeletion of IP revisions when temp accounts are enabledDreamy Jazz2024-05-231-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Why: * When wgAutoCreateTempUser['enabled'] is true, calling ActorStore ::acquireActorId for an IP address user will throw a CannotCreateActorException to prevent attributing actions to IP addresses. * When using Special:Undelete to undelete a page that has IP addresses who have made edits, the UndeletePage call to the ActorStore::acquireActorId causes an exception. * However, the revisions already existed so (similar to importing revisions) it does not represent a leak of the IP address. * As such, it should be possible to undelete a page with revisions performed by IP addresses. What: * Add ActorStore::getActorStoreForUndelete which works the same as ActorStore::getActorStoreForImport. Having methods that are named for undelete / import avoids the usage for other code that should use ::getActorStore instead. * Add RevisionStoreFactory::getRevisionStoreForUndelete which uses the ActorStore returned by ActorStore ::getActorStoreForUndelete. * Update the PageCommandFactory to take the RevisionStoreFactory and then call ::getRevisionStore for all but UndeletePage where the ::getRevisionStoreForUndelete method is called. Bug: T362019 Bug: T365669 Change-Id: Ia7c583c625843f4f400e1c4aa7ea360519e63c87
* tests: Use namespaced classesUmherirrender2023-12-111-0/+1
| | | | | | | 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-211-19/+0
| | | | | Bug: T342301 Change-Id: I5ea01f7ee103570165261bde0965c5b65e04c369
* Merge "Introduce ArchiveSelectQueryBuilder"jenkins-bot2023-09-071-10/+5
|\
| * Introduce ArchiveSelectQueryBuilderAmir Sarabadani2023-09-071-10/+5
| | | | | | | | | | | | | | Similar to RevisionSQB (Ifd690dc8f030) Bug: T344971 Change-Id: Ic520bcf09f4cc95ebd6a3990cff46dec5b7cd350
* | Merge "Make MediaWikiIntegrationTestCase::addCoreDBData a noop"jenkins-bot2023-09-071-4/+0
|\ \ | |/ |/|
| * Make MediaWikiIntegrationTestCase::addCoreDBData a noopDaimona Eaytoy2023-09-051-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | The method should never be called directly, so make it throw an exception. Nonetheless, mark it as deprecated and detect overrides in the constructor, so that anyone who tries to override this method will see a warning. Fix the few tests that were relying on the existence of the test page. Bug: T342428 Depends-On: Ic64ded5e2c0b59e7c888ece9566076058a125be4 Change-Id: I308617427309815062d54c14f3438cab31b08a73
* | Introduce RevisionSelectQueryBuilderAmir Sarabadani2023-09-061-9/+4
|/ | | | | | | | | Deprecating RevisionStore::getQueryInfo() and cleaning up a lot of code Also removing a brittle test that wasn't really testing anything. Bug: T344971 Change-Id: Ifd690dc8f030f86e3567a717eaeb830cb6dc703b
* tests: Migrate Database::select usages to SelectQueryBuilderAmir Sarabadani2023-07-171-3/+15
| | | | | Bug: T311866 Change-Id: I0324919f4e40f4e2db3dab1e9aacf74177170b20
* Drop revision_comment_tempAlexander Vorwerk2023-06-071-1/+0
| | | | | Bug: T299954 Change-Id: I85d21b1eff70a7d70e8ce14f25d66f7e7c76e5fe
* Reorg: Namespace the Title classJames D. Forrester2023-03-021-0/+1
| | | | | | | | | | | | | | | | | | | 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
* Use SlotRecord::MAIN instead of hard coded valueUmherirrender2023-01-031-1/+2
| | | | | | Makes it clear what about the value is (slot role name) Change-Id: I0dc195aa24c0e699a32d3b07e62d58e90cfac84d
* tests: Use Title::makeTitle instead of Title::newFromTextUmherirrender2022-09-231-1/+1
| | | | | | Avoid parsing known titles in tests to improve performance Change-Id: Ie240eb42479d19714e64cc4606e26073fadc2e13
* UndeletePage: Undelete associated talk pageDaimona Eaytoy2022-03-301-77/+67
| | | | | | | | | | | * Adds option to undelete associated talk page in the context of a subject page * If subject page undeletion fails, talk page undeletion is aborted * If restoring the associated talk page fails, a status with a warning message is returned Bug: T304962 Change-Id: I7b30863060974d4079639f57178062d359956c2e
* phpunit: use ->getServiceContainer() in integration testsAlexander Vorwerk2022-01-271-2/+1
| | | | Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
* tests: Replace usages of deprecated WikiPage::doDeleteArticleRealDaimona Eaytoy2022-01-171-2/+1
| | | | | | | | | Add a new helper to MediaWikiIntegrationTestCase, since deleting pages seems to be pretty common in tests. Some calls to WikiPage::factory were also updated to use WikiPageFactory. Change-Id: I5b5100273a00ac292a1900022ca79708fa254347
* Add perm checks to UndeletePage and make it a real serviceDaimona Eaytoy2021-10-041-4/+7
| | | | | | | | | | | | | Add entry in MediaWikiServices, add wiring code, inject all dependencies. Also add an alternative entry point with permission checks, like for DeletePage. The new service is no longer @unstable, and the relevant methods in PageArchive were deprecated. Bug: T290021 Change-Id: I452a98679f5bfea3f7367aacd5c930acffd32102
* Use fluent setters instead of optional params in UndeletePageDaimona Eaytoy2021-10-011-1/+1
| | | | | | | Also make $comment a required parameter, for symmetry with DeletePage. Bug: T290021 Change-Id: I0bb2c6b782bf4d61396657d367e182295f913f0e
* UndeletePage cleanup, part 1Daimona Eaytoy2021-09-211-6/+6
| | | | | Bug: T290021 Change-Id: Idaf25a209a65b9a36a0a24473c76523ee3a17e8d
* Move code from PageArchive to a new UndeletePage commandDaimona Eaytoy2021-09-211-0/+147
This is just moving code verbatim, removing now-unneeded stuff, and duplicating tests as well. Bug: T290021 Change-Id: I540ddaaa11dfabcf0b87b608b151b5e34d199fd8