aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/api
Commit message (Collapse)AuthorAgeFilesLines
* api: Remove deprecated ApiPageSet::get*TitlesUmherirrender2025-03-261-25/+2
| | | | | | | | | | | | | The following functions were removed: - ApiPageSet::getTitles - ApiPageSet::getGoodTitles - ApiPageSet::getMissingTitles - ApiPageSet::getGoodAndMissingTitles - ApiPageSet::getRedirectTitles - ApiPageSet::getSpecialTitles Bug: T339384 Change-Id: Iba8499c2d1b4a10b918f563069534b90fed7f6f9
* Namespace all remaining files in includes/skinJames D. Forrester2025-03-252-3/+3
| | | | | Bug: T353458 Change-Id: I3e829e35c93bcaae75e401b1801bddf93c0b416c
* Namespace all remaining files in includes/exceptionJames D. Forrester2025-03-255-8/+8
| | | | | | | | | In MediaWiki/Exception, to follow PSR-4 per plural vs. singular (this can be changed later if people really care). Also, move the couple of exceptions in here that were already namespaced in the MW-top-level into the new space. Bug: T353458 Change-Id: I12ed850ae99effb699a6d7ada173f54e72f0570e
* Merge "block: Don't modify an autoblock when the user specifies an IP"jenkins-bot2025-03-201-3/+20
|\
| * block: Don't modify an autoblock when the user specifies an IPTim Starling2025-03-201-3/+20
| | | | | | | | | | Bug: T389452 Change-Id: Id7a3f565821231647fe75a24e9ef7efeeb157c5d
* | Namespace all remaining files in includes/recentchangesJames D. Forrester2025-03-202-2/+2
|/ | | | | Bug: T353458 Change-Id: I2ae4577de79832b082adca282ff73cfabc8f9392
* Namespace all remaining files in includes/loggingJames D. Forrester2025-03-191-1/+1
| | | | | Bug: T353458 Change-Id: Ibe1810f1c71316a9124e1dc6ae405097dafd5267
* Namespace all remaining files in includes/filerepoJames D. Forrester2025-03-192-3/+3
| | | | | Bug: T353458 Change-Id: I35864ad9bd48701703c51367d62f8ebde963c52d
* Merge "ApiQueryBlock: Don't return page restrictions when pages were deleted"jenkins-bot2025-03-191-1/+2
|\
| * ApiQueryBlock: Don't return page restrictions when pages were deletedDayllan Maza2025-03-181-1/+2
| | | | | | | | | | | | | | | | * Special:Block and Special:BlockList ignore restrictions if the page has been removed. ApiQueryBlocks now matches that behavior Bug: T388511 Change-Id: I525fbf73eec6f4a62bd6244b2a14e71130c7e602
* | DomainEvents: Rename getOldRevision and getNewRevisiondaniel2025-03-151-4/+4
|/ | | | | | | | | | | | | 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
* Merge "DomainEvents: Rename PageEvent and PageUpdatedEvent"jenkins-bot2025-03-141-6/+6
|\
| * DomainEvents: Rename PageEvent and PageUpdatedEventdaniel2025-03-111-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | Why: - clarify naming after modeling discussions What: - Rename PageEvent to PageStateEvent - Rename PageUpdatedEvent to PageRevisionUpdatedEvent. Bug: T388588 Change-Id: I987c93a443d364782e692e2cf71b878ccbc5a2fa
* | Merge "fix(ApiParamValidator): PARAM_HELP_MSG_PER_VALUE for multi-string types"jenkins-bot2025-03-131-1/+34
|\ \
| * | fix(ApiParamValidator): PARAM_HELP_MSG_PER_VALUE for multi-string typesMichael Große2025-03-071-1/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In I53f9ae840c (commit 7c03a6f), the option was added to use PARAM_HELP_MSG_PER_VALUE to also document parameters for multi-string types, like templated parameters. See there for the reasoning. This change adds the support in ApiParamValidator for that. Follow-Up-To: I53f9ae840c0a7eee76c4b57f95390b5045707efd Change-Id: Ia8c1abdcb68823650582208caa9be3fa2c47daa8
* | | Merge "block: Increase page restriction limit in multiblocks mode"jenkins-bot2025-03-121-1/+1
|\ \ \
| * | | block: Increase page restriction limit in multiblocks modeTim Starling2025-03-121-1/+1
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | User consultations uncovered a need for restricting blocks to a list of more than 10 pages. With multiblocks, an admin in this situation could split up the block into several blocks, each with 10 pages, which is a tedious workaround. Discourage this by increasing the limit to 50. This was already implemented on the client side. Bug: T388505 Change-Id: I034b9e2fbf38e715255ca84065ec5a63534f86ad
* / | block: Fix failure to sanitize a range blocked with ApiBlockTim Starling2025-03-121-0/+16
|/ / | | | | | | | | Bug: T388097 Change-Id: I89baf1b190cf9adefba9a232f57c957a2345f8e5
* | Merge "block: Add localized duration to API responses"jenkins-bot2025-03-101-2/+7
|\ \
| * | block: Add localized duration to API responsesTim Starling2025-03-101-2/+7
| |/ | | | | | | | | | | | | | | | | | | | | | | * Add duration-l10n to BlockLogFormatter with a localized duration string * Add duration-l10n to ApiQueryBlocks * Fix bug in Language::formatDurationBetweenTimestamps() which caused it to be off by one hour if the specified timestamp straddled a daylight savings boundary. Bug: T388089 Change-Id: Ie88ca47053b2b9d6e3119aff5374e676d1835a44
* / ApiQuerySiteInfo: Expose same PHP Libraries as SpecialVersionReedy2025-03-081-1/+3
|/ | | | | Bug: T355722 Change-Id: Ica70fd7be1bd8f988d1d18c37d3571ab94256e3f
* block: DatabaseBlock constructor caller migrationTim Starling2025-03-048-88/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | There's about 100 callers of the DatabaseBlock constructor in core tests, most of them passing an address parameter which needs access to the global service container to parse. Many are passing the constructed object straight to DatabaseBlockStore::insertBlock(). So add insertWithParams() for their convenience, which has some handy shortcut parameters, has service access, and throws on failure. The calling code tends to be shorter than before. For unit tests trying to construct DatabaseBlock objects without a service container, direct construction of BlockTarget subclasses is warranted. Add a default to the $wikiId parameters for their convenience. MockBlockManager had its own 'target' parameter, mixed in with block options, carrying its own special idea of a target, which conflicted with DatabaseBlock's new 'target' parameter. Harmonise the parameters and fix the callers. Bug: T382106 Bug: T385966 Change-Id: I78b45a6003b62962211379c36da5587081f90f00
* DomainEvents: More clearly model null edits and dummy revisionsdaniel2025-02-261-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | 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-0/+12
| | | | | | | | | | | | | | 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
* Merge "block: Add test for block log expiry formatting"jenkins-bot2025-02-221-0/+16
|\
| * block: Add test for block log expiry formattingTim Starling2025-02-111-0/+16
| | | | | | | | | | | | | | | | Add a regression test for accidental conversion of block log expiry times from relative to absolute timestamps. Bug: T248196 Change-Id: Ie7db802c43b222260074c01bf70a3e9759cef845
* | Merge "PageUpdatedEvent: improve modeling of flags"jenkins-bot2025-02-201-3/+3
|\ \
| * | PageUpdatedEvent: improve modeling of flagsdaniel2025-02-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge "Generate machine-readable block info in BlockErrorFormatter"jenkins-bot2025-02-192-63/+3
|\ \ \
| * | | Generate machine-readable block info in BlockErrorFormatterBartosz Dziewoński2025-02-182-63/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, BlockErrorFormatter would only generate a human-readable error message for permission errors caused by blocks, and PermissionManager would build a PermissionStatus object out of them. Machine-readable block info was added later: UserAuthority would add a Block object to each one, then finally each API module (via ApiBlockInfoTrait) would generate block info from these Block objects. Now all of this happens in BlockErrorFormatter and PermissionManager. For compatibility with older code, remove the extra information when using the deprecated PermissionManager::getPermissionErrors() method. This is a small hack that can be removed together with that method in the future. The changes seem to make a workaround for T357063 in ApiQueryInfo unnecessary (tests added in c55d33ef11 still pass). Bug: T357063 Change-Id: Id121d51a24fbb1d8210e60bdd54c61b16938dd70
* | | | ApiQuerySiteinfo: Support $wgGroupInheritsPermissionsKevin Israel2025-02-191-2/+7
| |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I noticed that the "confirmed" group was missing from the API result on en.wikipedia.org. It is defined using $wgGroupInheritsPermissions, not $wgGroupPermissions. Rather than only using the latter, obtain lists of user groups and granted permissions from UserGroupManager and GroupPermissionsLookup respectively (and not just for filtering undefined groups out of the lists of changeable groups). Bug: T357846 Change-Id: I473868449dcf360afcba3c731ac7f282b623b1cd
* | | PageUpdater: make it easy to create dummy revisionsdaniel2025-02-141-11/+24
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | Creating dummy revisions was a fiddly multi-stage process. PageUpdater should just offer a method for doing it. Change how we create dummy revisions in: * LocalFile * MovePage * ImportReporter Bug: T198297 Bug: T384691 Change-Id: I4c7595ce24337ab637a4e0fdbb313fc77d452a15
* | Merge "Dummy revisions: add tests for event emission"jenkins-bot2025-02-131-0/+113
|\ \
| * | Dummy revisions: add tests for event emissiondaniel2025-02-101-0/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | ApiProtect: parse expiries using ExpiryDef::normalizeExpiryMusikAnimal2025-02-101-0/+12
| |/ |/| | | | | | | | | | | | | Also removes unnecessary use of global functions, and adds a test case for attempting to protect a page with a past expiry. Bug: T248196 Change-Id: I1738b338eb04b5a4cd10de962f05e172d0e7f90c
* | Revert "API: Use ExpiryDef for action=block expiry parameter"Tim Starling2025-02-101-14/+3
| | | | | | | | | | | | | | | | | | | | | | A block action done with the API no longer shows the relative timestamp in the log. So revert the parts of 257d6f3ba0517265471165cfdf4ba8576cc4 which switched ApiBlock to use ExpiryDef. The change to errorformat is not reverted. Bug: T248196 Change-Id: I3c277a5612e2c00d1120012354c4657c6fb02b47
* | ApiQueryInfo: Check for blocks against the requesting userThalia2025-02-051-0/+47
|/ | | | | | | | | | | | | | | | | | | | | | | | | Why: * When requesting information about an action that will cause a temporary user to be autocreated, permissions are checked against a placeholder temporary account. * Blocks are also checked against a placeholder temporary account, meaning that blocks are not checked against the IP address and other parts of the request object. * This causes incorrect block information to be returned, e.g. that there is no block when there is in fact a block against the IP address. * This is causing a bug in the mobile web editor, where the user only gets notified that they are blocked from editing after they submit the edit, instead of when the editor loads. What: * Check for blocks against the global session user in ApiQueryInfo::extractPageInfo. Bug: T357063 Change-Id: I942901f4f3a6845c2572623955e6a26d49954ca7
* build: Updating mediawiki/mediawiki-codesniffer to 46.0.0libraryupgrader2025-01-311-1/+1
| | | | Change-Id: I0f8a8cac36015bba52aea3ee2affd92f83d3574a
* Merge "API: Use ExpiryDef for action=block expiry parameter"jenkins-bot2025-01-291-3/+14
|\
| * API: Use ExpiryDef for action=block expiry parameterSam Wilson2025-01-291-3/+14
| | | | | | | | | | | | | | | | | | | | | | * Use the ExpiryDef validation for the action=block expiry parameter. * Change the errorformat used by Special:Block to get validation messages in HTML and the right language, and map these to form error messages. Bug: T384241 Bug: T248196 Change-Id: Ic7a080d02e317bbdddb609bf724e3c7c2c393983
* | block: Fix unblock by ID of self-blockTim Starling2025-01-271-0/+10
|/ | | | | | | | | | | | | | When unblocking by ID, ApiUnblock passed the target to BlockPermissionChecker as a string, but the check for self-unblock requires a UserIdentity. UnblockUser passed the $target constructor argument to BlockPermissionChecker, but that is always null when unblocking by ID. Fix both and add tests. Bug: T384716 Change-Id: I26a634cbed8789dd9fca48655f41fdd8c7066007
* Merge "ApiUnblock: Add support for multiblocks"jenkins-bot2025-01-141-24/+43
|\
| * ApiUnblock: Add support for multiblocksDayllan Maza2025-01-141-24/+43
| | | | | | | | | | | | | | | | | | | | * Re-purpose the existing id parameter to support block ID. If both id, and username are provided the request will fail * If a target has more than one block and a specific block is not provided it will fail with ipb_cant_unblock_multiple_blocks Bug: T378148 Change-Id: I04928d989e6764ac93ec243a5fec9c7fe2b0b9b0
* | Merge "block: Fix HideUserUtils error when user is hidden twice"jenkins-bot2025-01-141-2/+4
|\ \
| * | block: Fix HideUserUtils error when user is hidden twiceTim Starling2025-01-101-2/+4
| |/ | | | | | | | | | | | | | | | | | | | | * Add a limit to the HideUserUtils subqueries to avoid error "Subquery returns more than 1 row". We really want to know if at least one row exists. * Fix outdated doc comment * Add tests. Bug: T382399 Change-Id: Ib3bc22e0b3080b3ae6e1d2591ac7f2a1ef57c6b3
* / Fix private variable and docs to correct name of ChangeTagsStore, not ↵James D. Forrester2025-01-071-3/+3
|/ | | | | | ChangeTagStore Change-Id: I68be30cf4f682a587f19227ef08808f0995f600b
* block: Multiblocks block APITim Starling2024-12-161-4/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In ApiBlock: * Add an "id" parameter. If this is given, update the specified block. * Add a "newblock" parameter. If this is given, always add a new block, don't check if the target is already blocked. * If "reblock" is given and the target has more than one block, fail with an "ambiguous-block" error. Supporting changes: * Add BlockUserFactory::newUpdateBlock(), which takes a DatabaseBlock instead of a target union to act on. The block is passed through to the BlockUser constructor. * Rename the first parameter to BlockUser::placeBlock() from $reblock to $conflictMode, and style it like an enum. Add the CONFLICT_NEW value, to support the "newblock" API option. * In DatabaseBlockStore::newFromId(), add $fromPrimary, so that ApiBlock can pass data to BlockUserFactory with equivalent freshness to the LHS. Also: * In BlockUser, memoize prior blocks loaded from the DB * Move T287798 autoblock check to the memoized accessor. Just don't return autoblocks. * Move "TODO handle failure" comment in BlockUser to the called method. It really can't fail. * In DatabaseBlockStore::newFromId(), add an $includeExpired parameter and default to false although it was previously implicitly true. Based on a brief review of callers, I think this is beneficial. Bug: T378147 Change-Id: Iea5b77cb27006b33f3dde61660be5ad2c374a425
* Remove deprecated ApiBase::errorArrayToStatus()Bartosz Dziewoński2024-12-111-63/+0
| | | | Change-Id: I87cde531c3ba5a119a7c02c5240355b61be70ba9
* Add ApiQueryCheckCanExecute hookGergő Tisza2024-12-031-0/+24
| | | | | | Adds the equivalent of ApiCheckCanExecute for query modules. Change-Id: I88effab746544c4788b607059a2184ead5b1bbac
* PHPUnit: Use FQCN with leading backslash in @covers annotationFomafix2024-11-1940-46/+46
| | | | | | | | | | | https://docs.phpunit.de/en/11.4/annotations.html#covers recommends: > Please note that this annotation requires a fully-qualified class > name (FQCN). To make this more obvious to the reader, it is > recommended to use a leading backslash (even if this not required for > the annotation to work correctly). Change-Id: I7eb4b997346387e5799fa27a61ab317573124fd0