aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiEditPage.php
Commit message (Collapse)AuthorAgeFilesLines
* Use CsrfTokenSet as CSRF token sourcePetr Pchelko2021-07-121-1/+2
| | | | Change-Id: I079d2c802d9b48d6abf7f37fa9ef7dafac631345
* api: Replace deprecated User::getOption in ApiEditPageUmherirrender2021-07-061-1/+6
| | | | Change-Id: Ic20c8c6402d80ca8b5a426b3d10fbe3efb0e89a4
* api: Inject services into ApiWatchlistTraitUmherirrender2021-07-061-4/+13
| | | | | Bug: T259960 Change-Id: I73596f8c924ec4a02a7042608d19a35f82bb752a
* api: Replace deprecated WikiPage::factory in ApiEditPageUmherirrender2021-07-021-2/+9
| | | | Change-Id: Ic62d9144f64c32a3d403984a0e04f590c9a67188
* api: Inject services into ApiEditPageUmherirrender2021-06-301-13/+34
| | | | | Bug: T259960 Change-Id: Idf6eee7fed14495a8ab6e05a768fcb28178a4c2f
* Remove the fallback for create rights (covered in PM edit rights check).Roman Stolar2021-06-301-1/+1
| | | | | | | Remove key to i18n message, no longer being used. Bug: T272079 Change-Id: Id6566e5241b06ba377c2eca083221ee02556365f
* Use the edited page's title for magic words in action=edit error messagesBartosz Dziewoński2021-05-211-0/+2
| | | | | | | | | | | Allow specifying the title used for rendering error messages in ApiErrorFormatter. Then, specify one in ApiEditPage (and a few similar modules that deal with single pages) once we've figured out which page is being edited. Bug: T247661 Change-Id: Ic3d70efc23744ef6e90abc445f3babebf45c4697
* Add comment to fall-through cases in switchUmherirrender2021-04-151-0/+1
| | | | | | | | Fix new coming sniff PSR2.ControlStructures.SwitchDeclaration.TerminatingComment Bug: T182546 Change-Id: I3f8d43c730981d8faaa72910d7f3b58a14a8372f
* Clean up some logic in ApiEditPageDannyS7122021-04-121-24/+21
| | | | | | Should be a no-op Change-Id: I292aa153eb0bf4fdda099995073904c0c9c96d99
* Convert ChangeTags public interface to Authority.Petr Pchelko2021-02-241-1/+1
| | | | | Bug: T275507 Change-Id: I3b7f99391ab299df2b046a2878010cf6afe7fed7
* Safe-guard switch possibly doing bad comparisonsThiemo Kreuz2021-02-101-4/+5
| | | | | | | | | | | Old PHP versions are fine doing a `switch` with anything, even if the types don't match. This changed. More recent PHP versions start to bring up notices and such when a `switch` accidentially compares e.g. an object with an int. Bug: T255177 Bug: T258790 Change-Id: Ib415bd2fb394b95b02737b6df50e4e1fbbc440d3
* Merge "ApiEditPage: Document that it is extended"jenkins-bot2020-10-061-0/+7
|\
| * ApiEditPage: Document that it is extendedDannyS7122020-09-301-0/+7
| | | | | | | | | | | | | | To avoid future issues like T264200 Bug: T264200 Change-Id: I0eafbad96be5037fb7795559fe6a62e69d54f0c5
* | Revert "Revert "ApiEditPage: Show existing watchlist expiry if statusAmmar Abdulhamid2020-09-301-6/+13
|/ | | | | | | | | | | | | | | | | is not being changed."" This reverts commit 149e99f07230d041945871ddb6e0647ccc83dc21. It's not necessary to change the constructor now, the module is already using service locator to fetch RevisionLookup and ContentHandlerFactory. The WatchedItemStore can also be gotten from there, voiding the need for altering the constructor now. As Daniel said in T259960#6380471 dependency injection for API modules is good but not urgent. Bug: T261030 Bug: T264200 Change-Id: I16aa942cc800cd66a2cd538680a02b10cb0b1bfe
* Merge "Revert "ApiEditPage: Show existing watchlist expiry if status is not ↵jenkins-bot2020-09-301-22/+7
|\ | | | | | | being changed.""
| * Revert "ApiEditPage: Show existing watchlist expiry if status is not being ↵DannyS7122020-09-301-22/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | changed." This reverts commit 07e547f47cae761489a33e9ebb8a9b108298f34e. Reason for revert: LiquidThreads extends the ApiEditPage class, even though it shouldn't, and thus fails when the dependencies are not injected. Bug: T261030 Bug: T264200 Change-Id: Ib14f8a04bb6c723aa502a47ef9ccde6fe96a0ac7
* | Merge "ApiEditPage: Don't swap undo and undoafter parameters"jenkins-bot2020-09-301-4/+0
|\ \ | |/ |/|
| * ApiEditPage: Don't swap undo and undoafter parametersDov Alperin2020-09-211-4/+0
| | | | | | | | | | | | | | | | | | | | This made it impossible to correctly undo changes if revision IDs are out of order with respect to timestamps. Removes block of code responsible for creating this bug, and updates tests to reflect the change Bug: T190285 Change-Id: Id5837ed958023bdbf544ae0f79e2d5e05c94cc64
* | ApiEditPage: Show existing watchlist expiry if status is not being changed.Ammar Abdulhamid2020-09-291-7/+22
|/ | | | | Bug: T261030 Change-Id: I795db12aefeffb1cfbbe2ab00fbb19444df7d37b
* Merge "Remove requirement for ApiWatchlistTrait to be in ApiBase."jenkins-bot2020-09-111-1/+1
|\
| * Remove requirement for ApiWatchlistTrait to be in ApiBase.Ammar Abdulhamid2020-09-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This trait is not needed in ApiBase and its presence here is proving to be problematic. See I795db12. In this patch, the trait usage (more precisely the 'use statement') has been removed from ApiBase and accordingly the signatures of ApiWatchlistTrait::getWatchlistValue() and ::setWatch() have been altered to now require User object. With these changes, the abstract getUser() method in the trait is no longer needed, so it has been removed also. All core usages of the affected functions are fixed in this patch. The trait is used in only one extension according to codesearch tool, the extension will be fixed in Ic22e163. Bug: T262175 Bug: T248512 Follow-up: Ia18627b9824dca81f44f0571e8420d89b7626cf6 Change-Id: Idabcea71edfca9e7ed42000a258c99ff407873d4
* | API: Handle ContentHandler exception for content model mismatchAmmar Abdulhamid2020-09-041-0/+18
|/ | | | | | | | | | | | | | Ensure the content we are trying to save and the base content have identical content models before proceeding to save so as to forestall Exception that may be thrown by ContentHandler if it founds they're not. There are two cases where the models are allowed to differ: Edit that undoes content model change or edit that's meant to explicitly change the model. The logic for these is handled separately and may succeed or fail, but exception will not be thrown. Bug: T255700 Change-Id: I8782732bb0fc3059693cd7035b7ebb43fd71d333
* Use strict (in)equality with namespaces constants when LHS is definitely an ↵Ed Sanders2020-07-311-1/+1
| | | | | | integer Change-Id: I8fede00dfe1270d93c5d78d3c36e788cddfc8a99
* Merge "EditPage: handle undoafter param properly"jenkins-bot2020-07-141-1/+3
|\
| * EditPage: handle undoafter param properlyOstrzyciel2020-07-081-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is to fix issues with reverts being marked incorrectly, especially when using the undoafter param which, until this patch, wasn't really supported. Honestly, EditPage is such a mess that I'm not sure if this is good or not, but I did a lot of manual testing and it seems to work fine. WikiPage::doEditContent() now checks whether the provided original revision really has the same content as the new revision. This was previously the task of callers, but that doesn't make much sense to me because: * This task would fall on EditPage otherwise and it should be more focused on the UI side of things, without too much worrying about backend details. * This would require adding another parameter to WikiPage:: doEditContent(), $undoAfterId. It would be only useful for multiple- revision undos that are not top revisions. In all other cases it would be the same as $originalRevId. * An extra sanity check before applying the value to the PageUpdater won't hurt. Who knows what crazy ideas extensions might have. The test cases are almost identical to those written for McrUndoAction, so I decided to group them in a single file. This should cover most undo cases. Bug: T256915 Change-Id: I78641b3de0a012af932ea38265b695362f1f8491
* | Add watchlist expiry support to applicable APIsMusikAnimal2020-07-131-10/+31
|/ | | | | | | | | | | This introduces an ApiWatchlistTrait that refactors out common code across APIs that allow you to watch pages. Some methods have been migrated from ApiBase and changed completely, but codesearch suggests they aren't being used outside the API modules in this patch. Bug: T248512 Bug: T248514 Change-Id: Ia18627b9824dca81f44f0571e8420d89b7626cf6
* Fix SingleSpaceBeforeSingleLineCommentReedy2020-05-111-1/+1
| | | | Change-Id: I285af438ce484af40741489797f20455726ec110
* Soft deprecate Page interfaceArtBaltai2020-04-091-2/+2
| | | | | | | | Additionally, use Article::getPage() instead of relying on Page interface proxy method in ApiEditPage, forgotten before Bug: T239975 Change-Id: I01696a1b11b2ea5c3d94fcb9a42beea68eb7b804
* Replace isset() in if() conditions with ?? if possibleThiemo Kreuz2020-03-231-11/+5
| | | | | | | | | | | | | | | | The basic idea is: The sequence `$var ?? 'default'` either uses the value from the variable (or array element) if available, or falls back to the default value. The resulting value is then used in the if() condition. if ( $var ?? true ) means the variable should default to true, if not set. This is mostly a style change. In ApiEditPage the $params are impossible to not be set. Change-Id: Id67b81744fa21fe22a2d2377259e426aab67c479
* Merge "Remove usage of deprecated Revision from ApiEditPage"jenkins-bot2020-03-111-14/+30
|\
| * Remove usage of deprecated Revision from ApiEditPagePetr Pchelko2020-03-061-14/+30
| | | | | | | | | | Bug: T246284 Change-Id: Iee97229d2d5e2996077f86aa8b191a4ec0cd8e36
* | ApiEditPage: add baserevid parameterdaniel2020-03-111-2/+12
|/ | | | | | | | | | This adds a baserevid parameter for detecting edit conflicts, as an alternative to the less precise basetimestamp parameter. This is introduced for parity with and use by the new REST api. Bug: T230843 Bug: T34037 Change-Id: Id7565018f66860b5c2ba688777508db1b88700ae
* Fix some PHPStorm inspection warnings in includes/apiTim Starling2020-02-181-1/+0
| | | | | | | | | | Notably: * In ApiManageTags, I used a switch instead of a dynamic function name, so that the call graph will be correct. * In ApiImageRotate, checkTitleUserPermissions() has always returned void, this was an error introduced in 4e6810e4a2c1d821d8d108c Change-Id: Iea22616b8e7e2e0cc804619a54f8690898b2cb82
* Introduce ContentHandlerFactoryArtBaltai2020-02-071-3/+9
| | | | | | | | | | | | | | | | | Added: - ContentHandlerFactory Tests: - PHPUnit Changed - Calls of changed and deprecated - DI for some service/api Deprecated: - ContentHandler::* then similar to ContentHandlerFactory - ContentHandler::getForTitle - ContentHandler::$handlers Bug: T235165 Change-Id: I59246938c7ad7b3e70e46c9e698708ef9bc672c6
* Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNullJames D. Forrester2020-01-101-9/+9
| | | | Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
* ApiEditPage: Fix error message for edit conflictsBartosz Dziewoński2019-12-131-1/+1
| | | | | | | | | | | The 'editconflict' message is used by the normal edit form, and it expects a parameter (page name), which was never passed. 'edit-conflict' should have been used instead. This doesn't change the error code, which is mapped in ApiMessageTrait and it already has a case for 'edit-conflict'/'editconflict'. Change-Id: Ic95af27a67b95310b27ec344503d0a5cd88d79a2
* ApiEditPage: Test for bad redirect targetsBrad Jorsch2019-12-041-1/+15
| | | | | | | | Apparently everything downstream assumes callers already handled interwiki titles. Bug: T239428 Change-Id: Ie54f366986056c876eade0fcad6c41f70b8b8de8
* Fix new phan errors, part 5Daimona Eaytoy2019-10-181-0/+1
| | | | | | | | | | | | | Some of the errors are suppressed because they're phan false positives. The idea behind this is that they'll be fixed in a future version of phan, and we'll just have to remove the suppressions. Note: I'm disabling UnusedPluginSuppression so that we can start suppressing issues even if they're still disabled. The sniff should be re-enabled as soon as we upgrade phan. Bug: T231636 Change-Id: I0f7fa06a9e03fbb86c7a5eb6e50a850bb258a7f7
* phan: Disable enable_class_alias_supportUmherirrender2019-09-151-1/+1
| | | | | | It is enabled for b/c in extensions, but not needed in core Change-Id: I51dca12be9c77049f77563d9bf0edd07928c2300
* Remove usages of Title::get{Previous,Next}RevisionIdPetr Pchelko2019-09-131-5/+10
| | | | | | The methods were deprecated since 1.34. Change-Id: Ib95ac1ba36a8ffd6b71ed67642d8abb2e3538bae
* Unsuppress more phan issues (part 5)Daimona Eaytoy2019-09-011-0/+1
| | | | | | Bug: T231636 Depends-On: I6e5fba7bd273219b1206559420b5bdb78734aa84 Change-Id: I50377746f01749b058c39fd8229f9d566224cc43
* Unsuppress other phan issues (part 4)Daimona Eaytoy2019-08-311-3/+1
| | | | | | Bug: T231636 Depends-On: I58e67c2b38389df874438deada4239510d21654f Change-Id: I6e5fba7bd273219b1206559420b5bdb78734aa84
* Revert "Clean up ApiEditPage content handler undo logic"Anomie2019-08-191-2/+3
| | | | | | | | | | | | | | | | | | This reverts commit 01564dcbf76cd279c88320f96f0844cfadf4f7c9. Reason for revert: I find the empty case far clearer as to intention than this change, and I doubt this is such a hot path that optimization should take precedence over clarity. If we really want to get rid of the empty case, I'd have structured it somewhat clearly as if ( // always allow undo via api, T230702 !( $params['undo'] > 0 ) && // [something else here to explain this clause] $contentHandler->supportsDirectApiEditing() === false ) { But even that is IMO less clear. At the very least this seems to deserve more discussion. Bug: T230702 Change-Id: Icc16250faad31abf7308c4af9be2e7658540346c
* Clean up ApiEditPage content handler undo logicDannyS7122019-08-191-3/+2
| | | | | Bug: T230702 Change-Id: I79d528866c54f40c5adcffde8410b9e2d5336ea7
* api: Avoid usage of deprecated Revision::FOR_THIS_USER constantDerick Alangi2019-07-211-1/+1
| | | | Change-Id: I48b302ba3ea5762e2b576e972cf85d57cd73fb15
* Avoid usage of deprecated Revision::* constants, use RevisionRecordDerick Alangi2019-07-211-2/+4
| | | | Change-Id: I872fc89e5c02dd6a3ae9cd7e76640b95dc33f514
* Drop APIEditBeforeSave hookRazeSoldier2019-07-021-15/+0
| | | | | | | Removed the source code and the test code. Bug: T220656 Change-Id: I3674da6d9c33c08ec2f1774cb793b3a952480571
* Use (int) rather than intval()Reedy2019-02-251-3/+3
| | | | | Bug: T216969 Change-Id: I4c06716c83b69d128f26fa7f68736808aa2d3d64
* API: Spread autoblocks from action=edit and action=moveBrad Jorsch2019-02-191-1/+2
| | | | | | | | | | The code in EditPage and SpecialMovepage does this primarily in web UI code paths that aren't called by the API. EditPage also has a check in the internal code path used by the API, but ApiEditPage runs its own permissions check first and won't reach that code path. Bug: T216245 Change-Id: I6263c8b60a24f3195dba583463f1ce4b004f82f5
* Enforce partial blocksDayllan Maza2018-10-241-5/+1
| | | | | | | | | Enforce partial blocks and display a slightly different block notice depending on if the block is sitewide or not Bug: T197117 Depends-On: I675316dddf272fd0d6172ecad3882160752bf780 Change-Id: I8a3635a4a04a33912eb139b7b13c4bd874183d31