aboutsummaryrefslogtreecommitdiffstats
path: root/includes/editpage/Constraint
Commit message (Collapse)AuthorAgeFilesLines
* editpage: Refactor user right, rate limit and block checks to use AuthorityBartosz Dziewoński2025-04-056-274/+119
| | | | | | | | | | | | | | | | | | | | | 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
* Use type declaration on undocumented private functionsUmherirrender2025-04-021-1/+1
| | | | Change-Id: I0d8d2237500ed6f18439410c902d47c42e4119bc
* Namespace all remaining files in includes/changetagsJames D. Forrester2025-03-251-1/+1
| | | | | Bug: T353458 Change-Id: I3cf44dfe5425f2efb8409c83571c427447b053af
* editpage: Make BrokenRedirectConstraint provide its own error messageSomeRandomDeveloper2025-02-211-2/+8
| | | | | | | | | 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-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix broken redirect warning showing for special or interwiki targetsSomeRandomDeveloper2025-01-221-5/+5
| | | | | | | | | Using Title::exists does not account for special or interwiki pages which are also valid redirect targets. Using Title::isKnown instead does no longer cause the warning to appear when redirecting to a special page or an interwiki link. Bug: T384393 Change-Id: I35e4c72b0e21aaa36c1f8b1ac85fa819d353945e
* Add a warning when trying to create a double redirectSomeRandomDeveloper2025-01-171-0/+104
| | | | | | | | 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-173-18/+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-164-12/+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
* Merge "Rename brokenredirect i18n key"jenkins-bot2024-12-031-1/+1
|\
| * 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
* | Extract redirect target to a variableSomeRandomDeveloper2024-12-021-13/+18
|/ | | | | | | Extract the redirect target to a variable to avoid computing it multiple times, as discussed in patch 1090544. Follow-up to 1089205. Change-Id: I1603e8bd75c6e13055c0aa06fc435c34f60f11cf
* Add a warning when trying to create a broken redirectSomeRandomDeveloper2024-11-261-0/+89
| | | | | | | | 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
* Fix some more bool/null message paramsBartosz Dziewoński2024-11-031-1/+1
| | | | | | | | Found by Phan thanks to the type hints being added in I3e0df790ff9db2fa630f82408a7254a359fe61ca. Bug: T378876 Change-Id: I286a4a51e879bdf61f65c87dc078621c51045bee
* Remove meaningless @var documentation from constantsthiemowmde2024-10-091-1/+0
| | | | | | | | | A constant is not a variable. The type is hard-coded via the value and can never change. While the extra @var probably doesn't hurt much, it's redundant and error-prone and can't provide any additional information. Change-Id: Iee1f36a1905d9b9c6b26d0684b7848571f0c1733
* Replace a few more uses of deprecated Status / StatusValue methodsBartosz Dziewoński2024-08-221-7/+4
| | | | Change-Id: I017bcaffe6945d633d7387f9391803845369bfed
* Move Language and friends into Language namespaceJames D. Forrester2024-08-102-2/+2
| | | | | Bug: T353458 Change-Id: Id3202c0c4f4a2043bf97b7caee081acab684155c
* Move remaining four classes in includes/content into Content namespaceJames D. Forrester2024-08-105-5/+5
| | | | | Bug: T353458 Change-Id: Ia0f3e22078550be410c4b87faf6aa4eabe6e270d
* EditFilterMergedContentHookConstraint: fix docs typoDannyS7122024-07-211-1/+1
| | | | | Bug: T157658 Change-Id: I30829b61a992b9e6e9fde5d70f7fcf36bea56d5b
* Move section-check logic to ExistingSectionEditConstraintDannyS7122024-07-121-0/+13
| | | | | | | | | 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
* Move AS_REVISION_WAS_DELETED handling into constraintDannyS7122024-07-121-5/+22
| | | | | | | | Use the renamed ExistingSectionEditConstraint, and just make the content it gets nullable. Bug: T157658 Change-Id: I6e077f1e54ea05f77b431a7437c4a56c9dc56306
* Rename AutoSummaryMissingSummaryConstraintDannyS7122024-07-121-1/+1
| | | | | | | | | In preparation for also handling the AS_REVISION_WAS_DELETED failure in the constraint, rename it in a separate commit so that git can more easily track the change. Bug: T157658 Change-Id: Id55b40d8e327429fbaf45a96c0b00caaa9110da1
* editpage/Constraint: Resolve TODOs about `==` / `===`Bartosz Dziewoński2024-07-123-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | In all of these comparisons, both sides are strings (enforced by type hints), so we don't need to worry about type jugging, and only need to consider if it's possible for both sides to be numeric strings [1] before we change the `==` comparisons to `===`. AutoSummaryMissingSummaryConstraint.php: The return value of md5() is very unlikely to be a numeric string (and when it is, this code would work incorrectly, in effect only comparing a part of the hash). Seems safe to change it. MissingCommentConstraint.php: NewSectionMissingSubjectConstraint.php: The empty string is not a numeric string. Safe to change. [1] "If both operands are numeric strings [2] [...] then the comparison is done numerically." https://www.php.net/manual/en/language.operators.comparison.php [2] "A PHP string is considered numeric if it can be interpreted as an int or a float." https://www.php.net/manual/en/language.types.numeric-strings.php Change-Id: Id47f006797df9df392323610480196b1ce09a0f4
* EditPage::internalAttemptSave() - move more logic to constraintsDannyS7122024-07-112-4/+14
| | | | | | | | | Instead of conditionally adding the NewSectionMissingSubjectConstraint and MissingCommentConstraint based on creating a new section, always add those and have the constraints themselves just pass if not creating a new section Bug: T157658 Change-Id: Ie5bf352bd714b6b706445f4f02c986706f26bb1f
* Update property declarations to use type hints in editpage/Constraint/Doğu Abaris2024-07-1119-205/+74
| | | | | | This change improves type safety and code readability. Change-Id: I839bff97e10188af79d658b44caa5413f6c538ad
* Replace some uses of deprecated PermissionManager::getPermissionErrors()Bartosz Dziewoński2024-06-271-1/+1
| | | | | | | | | getPermissionStatus() does the same thing but better. A lot of things use the legacy error arrays though, we're nowhere near removing it. Change-Id: Iff60dbb0593329a584d003b2407bbf24d5b22aea
* Namespace Message, move to appropriate directoryJames D. Forrester2024-02-141-1/+1
| | | | | Bug: T353458 Change-Id: I088cbc53fbcdb974e5b05b45a62e91709dacc024
* Namespace includes/contextJames D. Forrester2024-02-082-2/+2
| | | | | Bug: T353458 Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
* EditPage: replace usage of User::pingLimiterdaniel2024-01-022-26/+50
| | | | | | Using RateLimiter::limit instead. Change-Id: Ia27cba5023994bfdc61f6d27702eeb98502d6dd4
* Use namespaced classesUmherirrender2023-12-111-2/+2
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statements and changes to docs done manually Change-Id: I443aada1c18c8628b02671aa9fd6f441961e5c2e
* Change EditPage 'edit' rights check to do per page instead of generalBrian Wolff2023-11-043-85/+62
| | | | | | | | | | | | | | Previously the edit rights check would fail if you didn't have edit rights in general. This made it difficult to write custom permission extensions that want to give users edit rights to a few specific pages while not giving rights in general. This check goes back to 2005 when the edit rights system was first introduced a2a28a34c1fc. Presumably per-page permissions didn't exist yet. Bug: T342515 Change-Id: Ibcf0e18c44912abdd02a676a551da3cc7ed22ee0
* Namespace User under \MediaWiki\UserJames D. Forrester2023-09-194-4/+4
| | | | | Bug: T166010 Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
* Reorg: Move Status to MediaWiki\Status\Amir Sarabadani2023-08-251-1/+1
| | | | | | | | | | This class is used heavily basically everywhere, moving it to Utils wouldn't make much sense. Also with this change, we can move StatusValue to MediaWiki\Status as well. Bug: T321882 Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3 Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
* rdbms: Move ReadOnlyMode and ConfiguredReadOnlyMode to rdbms libraryAmir Sarabadani2023-05-042-2/+2
| | | | | | | | | | | | The db/ directory does not have an owner and it's a mess in general. These classes don't depend on anything in core except the rdbms library. Let's simply move it there. In other words, Krinkle made me do it. Since the class was moved in I6202e52ba73 merged less than a week ago, no need to alias anything. Bug: T321882 Change-Id: I24ceeb8bf765a50f441270136acd612359d50aa2
* Reorg: Move ReadOnlyMode classes to db/Amir Sarabadani2023-04-282-2/+2
| | | | | | | | They are not suitable to go to rdbms library as they depend on mediawiki pieces, the second best place is the db/ directory. Bug: T321882 Change-Id: I6202e52ba7306d74261206c2ba7930c5f1a0a18e
* Reorg: Namespace the Title classJames D. Forrester2023-03-027-7/+7
| | | | | | | | | | | | | | | | | | | 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
* Reorg: Move HTML-related classes out of includes/ to Html/Amir Sarabadani2023-02-161-1/+1
| | | | | Bug: T321882 Change-Id: I5dc1f7e9c303cd3f5b9dd7010d6bb470d8400a18
* Various doc fixes about false on method arguments/return typesUmherirrender2022-11-101-1/+1
| | | | | | Doc-only changes Change-Id: I5177f582ae7ee70c357e9389fed14819faf79463
* EditPage: Disentangle edit summary and section titleBartosz Dziewoński2022-07-193-37/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, `$this->summary` was used for two different purposes. Usually it was just the summary. But when `$this->section` was 'new', then it was actually the section title most of the time – unless `$this->sectiontitle` was also set (in which case it took priority), and until it was replaced by the real edit summary (near the end of the processing, after copying the section title to the page content and before saving changes). Unsurprisingly some of the code didn't handle this duality correctly, causing T191722 and T311533. Now `$this->summary` is always the summary, and when `$this->section` is 'new', then `$this->sectiontitle` is always the new section title. The only place where this duality remains is in the input attributes and query parameters, where 'wpSummary' is still used for both the summary and the section title inputs (only one of them can appear, depending on whether `$this->section` is 'new'). It would be an unreasonable backwards-compatibility break to change this, and the code handling this is somewhat isolated from the rest of the logic. Bug: T191722 Bug: T311533 Change-Id: I5313ca9a045d112ece390b011a34192220e2abc1
* Fix edit API using summary as section title incorrectlyBartosz Dziewoński2022-06-132-5/+5
| | | | | | | | | 'summary' must only be used as the section title when 'sectiontitle' is not provided. Otherwise the provided section title must be used, even if it is empty. Bug: T54747 Change-Id: Id86d5cdd9e04cf1b2f3fbf243a4b250e2924cf87
* Use MainConfigNames instead of string literals, #4Aryeh Gregor2022-04-261-2/+3
| | | | | | | | | | | | | | | | | | | | | Now largely automated: VARS=$(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | \ tr "\n" '|' | sed "s/|$/\n/;s/'//g") sed -i -E "s/'($VARS)'/MainConfigNames::\1/g" \ $(grep -ERIl "'($VARS)'" includes/) Then git add -p with lots of error-prone manual checking. Then semi-manually add all the necessary "use" lines: vim $(grep -L 'use MediaWiki\\MainConfigNames;' \ $(git diff --cached --name-only --diff-filter=M HEAD^)) I didn't bother fixing lines that were over 100 characters unless they were over 120 and triggered phpcs. Bug: T305805 Change-Id: I74e0ab511abecb276717ad4276a124760a268147
* TempUser EditPage and permissionsTim Starling2022-04-261-1/+2
| | | | | | | | | | | | | | | | | | * Allow EditPage to create a user on page save. This has to be enabled in config and then activated by the UI/API caller. * Add an autocreate source for temporary users. * Allow editing by anonymous users via automatic account creation when $wgGroupPermisions['*']['edit'] = false. On an edit GET request, use an unsaved placeholder user to stand in for post-create permissions. * On preview or aborted save, the username to be created is stashed in a session and restored on subsequent requests. * On a (likely) successful page save, create the account. * Put regular non-temporary users in a "named" group so that they can be given additional permissions. * Use a different "~~~" signature for temporary users * Show account creation warnings on edit and preview. Change-Id: I67b23abf73cc371280bfb2b6c43b3ce0e077bfe5
* Improve error messages in EditFilterMergedContentHookConstraintDaimona Eaytoy2022-03-222-16/+45
| | | | | | | | | | | | Use multiple error boxes instead of a wikitext list of error messages, as the latter has several issues (as reported on phab). Also, remove the edit-error-* messages as they don't seem to add any value. Also, don't use the passed-in context, inject what the class actually needs instead (but keep the context for the hook). Bug: T303060 Bug: T230229 Change-Id: I2806e57826e7ab062b45dd1d9972b05fd6baeafb
* Fix uses of (error|warning|success)box in corestang2022-03-201-6/+2
| | | | | | | Replace HTML class for boxes with "mw-message-box-" style. Bug: T300358 Change-Id: Iddb0fd3ae859714fb03d3a6d4586f8525becaac6
* Fix various documentation related to null types (part II)Umherirrender2022-03-081-1/+1
| | | | | | | | | The functions returning null or the class property is set explict null. Some function should not accept null or return null. Found by phan strict checks Change-Id: Ie50f23249282cdb18caa332f562a3945a58d86ff
* Move property initialisation out of the constructorThiemo Kreuz2022-01-271-2/+1
| | | | | | | | | When the value is a constant, the initialization can be done way up together with the property declaration. I believe this makes the code easier to read because it's not spread out so much. Change-Id: I5af482feccb746c144c0f318e119165cf5a56cbe
* Fix typos in comments (I-J)Siddharth VP2021-12-301-2/+2
| | | | Change-Id: Icaea2b6665cfc3b811d94f70c93452237f5e72bf
* Fix typos in comments (A-B)Siddharth VP2021-12-261-1/+1
| | | | Change-Id: I852453fbeeebdc4e34c0b35c0fdca4b4ab74fde9
* Cleanup mixed space/tab line indentUmherirrender2021-09-041-1/+1
| | | | Change-Id: I833052a656b1ce419c0929f6f0514f2a33c2c4cc
* build: Updating dependencieslibraryupgrader2021-07-2222-53/+53
| | | | | | | | | | | | | | composer: * mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0 The following sniffs now pass and were enabled: * Generic.ControlStructures.InlineControlStructure * MediaWiki.PHPUnit.AssertCount.NotUsed npm: * svgo: 2.3.0 → 2.3.1 * https://npmjs.com/advisories/1754 (CVE-2021-33587) Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426