aboutsummaryrefslogtreecommitdiffstats
path: root/includes/editpage/EditPage.php
Commit message (Collapse)AuthorAgeFilesLines
* editpage: Refactor user right, rate limit and block checks to use AuthorityBartosz Dziewoński2025-04-051-22/+22
| | | | | | | | | | | | | | | | | | | | | Replace EditRightConstraint, UserBlockConstraint, and most of UserRateLimitConstraint with the new AuthorizationConstraint. Instead of many separate checks, everything is now handled by one authorizeWrite() call. Move 'editcontentmodel' rate limit to ContentModelChangeConstraint (by making it use authorizeWrite()). Keep 'linkpurge' rate limit in a separate check, renamed from UserRateLimitConstraint to LinkPurgeRateLimitConstraint, since the way it works in unusual and not portable to Authority without more refactoring in EditPage. AuthorizationConstraint needs some special handling to produce the idiosyncratic result codes required by EditPage, but luckily PermissionStatus gives us everything we need for that. Bug: T271975 Bug: T386346 Change-Id: Ic9f6f2fbd29efa3e349517013da540a363c263b5
* Namespace all remaining files in includes/skinJames D. Forrester2025-03-251-1/+1
| | | | | Bug: T353458 Change-Id: I3e829e35c93bcaae75e401b1801bddf93c0b416c
* Namespace all remaining files in includes/exceptionJames D. Forrester2025-03-251-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
* Namespace all remaining files in includes/recentchangesJames D. Forrester2025-03-201-1/+1
| | | | | Bug: T353458 Change-Id: I2ae4577de79832b082adca282ff73cfabc8f9392
* Namespace all remaining files in includes/loggingJames D. Forrester2025-03-191-2/+2
| | | | | Bug: T353458 Change-Id: Ibe1810f1c71316a9124e1dc6ae405097dafd5267
* Namespace all remaining files in includes/actionsJames D. Forrester2025-03-191-1/+1
| | | | | Bug: T353458 Change-Id: Id3ca24e22877e544b707a8a527a58e00cc1bc247
* Namespace all remaining files in includes/pageJames D. Forrester2025-03-181-3/+3
| | | | | Bug: T353458 Change-Id: I7a9c74f2106655d41ae029742090253f541bd4a6
* PageUpdatedEvent: Model revert causesdaniel2025-03-071-0/+2
| | | | | | | | | | | | | | | | Why: - Rollback and undo should not use the "edit" cause, since they are triggered by a dedicated user action. What: - Introduce constants for rollback and undo into PageUpdateCauses. - Set update cause in McrUndoAction, EditPage, WikiPage, and Rollbackpage. - Add test cases asserting the properties of the PageUpdatedEvent for manual reverts, undos, and rollbacks. Bug: T378936 Change-Id: If3174732846795e322ddd61257459395eb10e73e
* Re-apply "Drop all 49 remaining class_aliases from MediaWiki 1.40"Daimona Eaytoy2025-03-051-3/+0
| | | | | | | | | This reverts commit 1695950bccb1ca7eba98952753708ae7c4b76d8d and re-applies commit I8f3c2ea021d0f6e. Reason for revert: the remaining usages have been updated in Ida665f486eff384. Bug: T166010 Change-Id: I43f06e6872b264e43aef7fa7c2ac47159926a694
* Revert "Drop all 49 remaining class_aliases from MediaWiki 1.40"Ahmon Dancy2025-03-041-0/+3
| | | | | | | | | This reverts commit db47e7f7154a2121bce6d3d9e93a74486bf765f3. Reason for revert: Broke scap sync-world in beta, and possibly caused T387938 Bug: T166010 Change-Id: If608c3e27081bb36b284ad16a5b912dd51b3557e
* Drop all 49 remaining class_aliases from MediaWiki 1.40James D. Forrester2025-03-041-3/+0
| | | | | | | Bug: T166010 Depends-On: Iba93dd9749656e641c427e01790d7a14cd1a2dc2 Depends-On: I97ccc2c49ce09ca96192bf6ffdc833c1765c3faa Change-Id: I8f3c2ea021d0f6e574dde901f0bfd4a0408f5455
* editpage: Make BrokenRedirectConstraint provide its own error messageSomeRandomDeveloper2025-02-211-9/+6
| | | | | | | | | Generate the error message in the getLegacyStatus function in the constraint class instead of EditPage. The submit button label has to be passed to the edit constraint since the logic for determining it it resides in EditPage. Bug: T384399 Change-Id: Id2a9ab57198dfa4df07f91b067944e9f9fefb81a
* editpage: Make PageSizeConstraint provide its own error messageBartosz Dziewoński2025-02-211-26/+15
| | | | | | | | | | | | | | | | | | | | | | | | Instead of special-casing it in EditPage and in ApiEditPage, PageSizeConstraint sets the error message itself. Add some notes about T384399. I hope this change can serve as an example for further work on that task. Other changes: * Do not show the error on editor load, only on edit form submission. The error on load was added in 2006 when the maximum page size was first limited (aa2bde93 / SVN r13070), and should not be needed any more now that there shouldn't be any pages exceeding the limit in the database any more. In case there are, the user will still get the message when they try to save an edit. * Streamline the message (there's no need for emphasis in the message, since it's shown in a very prominent error box these days). * Use the same message in API errors. Preserve the API error code for compatibility. * Alphabetically sort some arrays and switch cases. Bug: T384399 Change-Id: I0892d1189e29013b9ff4325c8017bab524b84b7e
* EditPage: Preserve client-side tags after preview/show changesNeriah2025-02-051-0/+12
| | | | | | | Add preservation of client-side tags when using preview/show changes functionality, ensuring they are included in the final saved edit. Bug: T385260 Change-Id: Ia9680bd3ba4d790ecf89ebb5497f896c0b2cb893
* Add a warning when trying to create a double redirectSomeRandomDeveloper2025-01-171-0/+44
| | | | | | | | Shows a warning when trying to create a redirect that points to another redirect. Bug: T326056 Change-Id: Ieb51dde88ce6c23753f74191a85cd40f0bfbd864
* Remove 2-line PHPDocs that just repeat the types from the codethiemowmde2025-01-171-9/+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
* Remove trivial 1-line PHPDocs that just repeat the codethiemowmde2025-01-161-6/+0
| | | | | | | | | | | | | I assume these are all either auto-generated by an IDE or the language-level type declarations have been added later. In any case the comments don't add any new information to what the code already says. This is just extra clutter that makes the code harder to read, I would argue. There are many, many more comments like this. In this patch I intentionally focus on the most trivial 1-line comments. Change-Id: Ia294bf4ce0d8a77036842fe25884bc175c2b0e7d
* Use getRawVal instead of getValFomafix2025-01-091-3/+4
| | | | | | | | If the value is compared against a static ASCII string. The UTF-8 normalization of getVal is not needed here. Change-Id: Id85f1218a9d76b9ca69fb833348e531387089711
* Replace isset() with falsy checksUmherirrender2024-12-191-3/+3
| | | | | | | | | isset() should only be used to suppress errors, not for null check. When the property is always defined, there is no need to use isset. Found by a new phan plugin (2efea9f989) https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#isset Change-Id: I186e799256fbaf5ee77558bd146f9418dd5eaacc
* Merge "Remove unusual message keys for parser limit report"jenkins-bot2024-12-131-1/+1
|\
| * Remove unusual message keys for parser limit reportBartosz Dziewoński2024-11-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | As far as I can tell, no one ever used the "$key-value-text" or "$key-value-html" keys, only "$key-value": https://codesearch.wmcloud.org/search/?q=-value-(html|text)%22%3A&files=en.json https://global-search.toolforge.org/?q=.*&regex=1&namespaces=8&title=.*-value-%28html|text%29 They were added in 2013 (2b20038ce77ce8b939113a3edb7d25127c238d4e). Change-Id: I175e834e2b425f0ba1b8650ae44dbf65fb23fe6e
* | Merge "editpage: More consistently exclude unintended limit report entries"jenkins-bot2024-12-111-0/+13
|\|
| * editpage: More consistently exclude unintended limit report entriesBartosz Dziewoński2024-11-141-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some entries in the limit report are not supposed to appear in this table, because they require parameters other than the one or two numeric parameters supported by this code. RenderDebugInfo already has a list of them and special handling. However, excluding them relied on this check within the foreach loop: if ( !$keyMsg->isDisabled() && !$valueMsg->isDisabled() ) ... which will pass in qqx mode, or if the message key is defined on-wiki. Instead, exclude them based on a list, like in RenderDebugInfo. Bug: T379971 Change-Id: Ie0ccb2d7ddab0ac4ba30f27c908059f23fb387a1
* | Allow viewing source when a protected page exists but is emptyBartosz Dziewoński2024-12-111-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | This restores the original intent of ec1714baee (SVN r73875), lost somewhere during ContentHandler refactoring years ago. Test plan: View an empty protected page, a non-empty protected page, and a non-existent protected page. (Also test with the namespace protection for the 'MediaWiki:' namespace.) Bug: T249978 Change-Id: I454a55a3c09a8be2640218d6301aad00c76921c1
* | Rename brokenredirect i18n keySomeRandomDeveloper2024-12-021-1/+1
| | | | | | | | | | | | | | Rename the brokenredirect i18n key to edit-constraint-brokenredirect, as requested in patch 1090544. Follow-up to 1089205. Change-Id: I544fd9adc38f916f549d3fa1b7da51283a3beb68
* | Merge "Add a warning when trying to create a broken redirect"jenkins-bot2024-12-011-0/+30
|\ \
| * | Add a warning when trying to create a broken redirectSomeRandomDeveloper2024-11-261-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | Shows a warning when trying to create a redirect that points to a nonexistent page. Update api tests to create the targets before the redirects. Bug: T326057 Change-Id: Ib530f17527aa8e14b8865086faa8d9feff6116ef
* | | Merge "RevisionRecord: add convenience methods for main slot"jenkins-bot2024-11-281-6/+4
|\ \ \
| * | | RevisionRecord: add convenience methods for main slotdaniel2024-11-281-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When accessing slot content and meta-data, most code wants to only access the main slot. Add convenience methods for making this less awkward. Originally, the intent was for all code to support arbitrary slots. This hasn't happened, instead we spread SlotREcord::MAIN all over the code base. It seems better to adjust the interface of RevisionRecord to reality. Change-Id: I8603f95c8e39d6fc3522a47f74657798e7f7c061
* | | | Modernize status and error message handlingBartosz Dziewoński2024-11-281-34/+37
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use pretty error boxes instead of 'error' CSS class. * Use Status::getMessages() and display each error individually, instead of getWikiText(). The latter sometimes messes up the display of complex messages, such as customized AbuseFilter errors. * Add missing 'mediawiki.codex.messagebox.styles' (some of these pages already used pretty error boxes in other code paths). * Other minor fixes. Bug: T377384 Bug: T375287 Change-Id: If2299f98f23e9ad057bce56260e264507337e0b6
* / / Load codex messagebox styles on every action=editUmherirrender2024-11-271-3/+6
|/ / | | | | | | | | | | | | | | | | Edit page is using the message boxes to style errors or warnings. As edit page is using many dynamically content like live preview, just load the style always as some other styles. Bug: T380944 Change-Id: I43fdd5c0e37dba22c332d649dcd787a799139142
* | Merge "Use ParserOutput::getLinkList() internally"jenkins-bot2024-11-191-4/+6
|\ \
| * | Use ParserOutput::getLinkList() internallyC. Scott Ananian2024-11-151-4/+6
| |/ | | | | | | | | | | | | | | This replaces the internal uses of the deprecated ParserOutput::get* methods and isolates the ParserOutput internal representation from most of the users. Change-Id: I32df68714ffdf2f0745b974f47bc3ccceef1f41c
* / Don't copy POST query params when generating link/redirect URLsBartosz Dziewoński2024-11-161-1/+1
|/ | | | | | | | | | | | | | | | | | | | Use WebRequest::getQueryValues() instead of WebRequest::getValues() whenever the result is used to generate links or redirect URLs, so that only GET query params are copied and not POST params. This is the same change as I53e58c16cd1292d78b5775358fc180901f4ce203 (for T309907), but repeated in several more places. Two of these had bugs filed for it (T152920, T291852), others were as yet undiscovered. Some of my changes have no effect in practice (e.g. when the code is guarded by wasPosted()), but I'm changing them anyway to avoid perpetuating the bad pattern. Bug: T152920 Bug: T291852 Change-Id: I67fbf82a7ec084623595e6aff62c26dbcce8fa4d
* Use ContentLanguageCode service instead of heavy Language objectAmir Sarabadani2024-11-021-1/+1
| | | | | | | Improving coupling. Bug: T376565 Change-Id: I109662cc957e1a64396348d7c2f5d2eadedb9722
* Rename various $connectionProvider vars to $dbProviderAaron Schulz2024-10-281-4/+4
| | | | | | | This makes it clearer what kind of connections they refer to and is consistent with the vast majority of callers. Change-Id: I2c5499439731b73dad90b78e5ab1069d468fe3d3
* Use explicit nullable type on parameter argumentsUmherirrender2024-10-161-1/+1
| | | | | | | | | | | 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
* Namespace all remaining classes in includes/parserJames D. Forrester2024-10-151-1/+1
| | | | | Bug: T353458 Change-Id: If02cc9b1ff78e26c1cf8c91ee4695845eb133829
* Add namespace to IDBAccessObject and DBAccessObjectUtilsJames D. Forrester2024-09-271-1/+1
| | | | | Bug: T353458 Change-Id: I23cf7991f8792d4d000d1780463d8ce76dc0aee0
* Merge "Remove ParserOutput::getText() calls from core (runOutputPipeline)"jenkins-bot2024-09-061-6/+12
|\
| * Remove ParserOutput::getText() calls from core (runOutputPipeline)Isabelle Hurbain-Palatin2024-09-061-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the fourth patch of a series of patches to remove ParserOutput::getText() calls from core. This series of patches should be functionally equivalent to I2b4bcddb234f10fd8592570cb0496adf3271328e. Here we replace calls to getText where a ContentRenderer is available close by by temporary ParserOutput::runOutputPipeline that will eventually be replaced by a call to (probably) ContentRenderer (T371004). Doing this work in stages allows us to separate the work of "bring ParserOptions to the call site" from the work of "bringing ContentRenderer(ish) to the call site", since both need to be done for to make ParserOutput a value object (T293512). Change-Id: Ib4f9357293dc230df6e0ca2379a1e2a4cc1b91b7 Bug: T293512
* | Add missing documentation to class properties (frontend-related)Umherirrender2024-09-051-0/+10
|/ | | | | | | | | | Add doc-typehints to class properties found by the PropertyDocumentation sniff to improve the documentation. Once the sniff is enabled it avoids that new code is missing type declarations. This is focused on documentation and does not change code. Change-Id: Id75cb2e5fbee0fe7600f92473d876f23730d46b7
* Move remaining four classes in includes/content into Content namespaceJames D. Forrester2024-08-101-2/+2
| | | | | Bug: T353458 Change-Id: Ia0f3e22078550be410c4b87faf6aa4eabe6e270d
* editpage: Replace use of legacy error arraysBartosz Dziewoński2024-08-091-11/+12
| | | | Change-Id: I30c6da024f9e5e54d47d612568fcdae77693b46b
* editpage: Remove special case for block messages on previewBartosz Dziewoński2024-08-081-7/+1
| | | | | | | | | | | | | | | | | | | | | | | If you start editing a page, and then something prevents you from saving your edit while you were working on it, and you try to preview your changes, we usually display an error about it (and let you copy the wikitext you wrote, but don't allow continuing to edit). However, if you were prevented from saving by being blocked, this did not happen – the editor would pretend that everything is okay until you tried actually saving changes. There is even a comment elsewhere in this file about it: but that case did not actually trigger for blocks, only in other situations, e.g. when a page is protected during the edit. This special case was originally added in 2005 (ee1fc77f735b32dc39e5436770e0bbe0c0af9fb6 / SVN r7462), seemingly only to improve performance, but that reason has been lost in the many refactorings since (the blocks were checked anyway, the errors were just ignored afterwards). Change-Id: Ia7d8c26089f5124614d750ad3fe0bcabd8f2e60f
* EditPage, ApiEditPage: Use parantheses to be explicit about order of evaluationJames D. Forrester2024-07-291-1/+1
| | | | | | | Follow-up for 48c8cee1831429ac4c980f3a607e1d2daec35945, caught by the forthcoming release of MediaWiki-CodeSniffer. Change-Id: Ib75df401916e8a0d750844ec364c5ab8f92ff003
* Hard deprecate public access to EditPage::internalAttemptSave()DannyS7122024-07-211-6/+21
| | | | | | | | | | | As part of refactoring the edit save logic, remove this public entrypoint - the attemptSave() method is still available. Because the actual logic is still needed by core, we move it to a new private method, internalAttemptSavePrivate(), and call that from the deprecated internalAttemptSave() method. Bug: T157658 Change-Id: I79ccb85f645e15256c4b5867ef3997d10a611e53
* EditPage: refactor to create generateUndoEditSummary()Novem Linguae2024-07-171-51/+66
| | | | | | | | | | | | | | | This code was in a big method and had a single responsibility so was a good candidate for extracting into its own private method - Cut and paste a big block of code - Move `$disableAnonTalk = $services->getMainConfig()->get( MainConfigNames::DisableAnonTalk );` into the new method - Add docblock - Change #comment to //comment in the new method, for consistency within the new method - No-op Change-Id: I379bfa67a4518ca46da482578271471fa43ea4e2
* EditPage: improve variable namesNovem Linguae2024-07-171-10/+8
| | | | | | | | - rename $def_content to $defaultContent - rename $popts to $parserOptions - remove some line breaks Change-Id: I497c703652b094d5a69d71558037a2cc0b6683fd
* Move section-check logic to ExistingSectionEditConstraintDannyS7122024-07-121-12/+10
| | | | | | | | | Instead of conditionally adding it, move the check for the section being new or not into the constraint, to reduce the logic needed in EditPage::internalAttemptSave(). Bug: T157658 Change-Id: If16f5a097dd38c5206f748fa4fb8dc6e56cf09cb