aboutsummaryrefslogtreecommitdiffstats
path: root/includes/specials/SpecialImport.php
Commit message (Collapse)AuthorAgeFilesLines
* specials: Use type declaration on undocumented private functionsUmherirrender2025-04-041-1/+1
| | | | Change-Id: Ib394792b10afabf5e0440cd3be34c1f2fd9cfe1d
* Namespace all remaining files in includes/exceptionJames D. Forrester2025-03-251-1/+1
| | | | | | | | | 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
* Special:Import: Load Codex style pack for message boxesJon Robson2025-03-051-9/+10
| | | | | Bug: T381811 Change-Id: If0b1f1f64a29623c93f38f35cd456550a062956a
* import: Don't swallow exceptions that are not safe to catchMáté Szabó2025-01-221-1/+7
| | | | | | | | | | | | | | | | | | | | | | Why: - Special:Import currently catches every subclass of Exception thrown by the import process and tries to render an error box for them. - DBError subclasses, aren't meant to be caught by most code however. If they left the main transaction round in an inconsistent state, further errors will occur if the default exception handler hasn't had a chance to perform cleanup. - Likewise, exceptions from wikimedia/request-timeout should also be allowed to bubble up as they indicate that a request-level timeout (enforced by Excimer in WMF prod) has expired and the request is to terminate as soon as possible. What: - Let DBErrors and TimeoutExceptions bubble up on Special:Import. Bug: T383933 Change-Id: Iae29d13534bd198823b4d8de0e8db20f43a97038
* Remove trivial 1-line PHPDocs that just repeat the codethiemowmde2025-01-161-3/+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
* Update help links to point to MediaWiki.org rather than MetaPppery2024-07-261-1/+1
| | | | | Bug: T366713 Change-Id: I8967d229306243fbbed8463667727c4115eb2a34
* SpecialImport: Convert to use AuthorityBartosz Dziewoński2024-07-181-36/+31
| | | | | | | | | | Authority::isDefinitelyAllowed() offers a slightly better way to check that the user has one of the two rights, and isn't blocked, but without checking permissions for specific page titles. That is what was intended when this complicated check was added in 33534edfbda600314339959edf53022301d95237 (SVN r85005). Change-Id: I5eab9706f4bce92648076a45deef0ae0137c1151
* SpecialImport: Fix unparsed wikitext in error messagesBartosz Dziewoński2024-07-041-4/+12
| | | | | Bug: T313059 Change-Id: Id8e1b7c2bab628b1570d3c90403767f783d565cf
* SpecialImport: Modernize error message stylingBartosz Dziewoński2024-07-041-6/+7
| | | | Change-Id: Ic6d0722072d3279ea1366e1d6359d72c12d0cea1
* SpecialImport: Set the `usernamePrefix` field as requiredFunc2024-05-241-1/+1
| | | | | | | | Answering the TODO: Yes, this form is separated from the interwiki one, so this field should be marked as required like the `xmlimport` field above. Change-Id: I6e7cc8060c3c1c3680d784d4d1f83273326b6cd9
* specials: Improve docs and `@ingroup` tags, fix file headersTimo Tijhof2024-05-151-3/+0
| | | | | | | | | | | | | | | | | | | | * Add relevant `@ingroup` to special pages that belong to a specific component and for which a doc group is already defined (defgroup), e.g. "Upload" for SpecialUpload, "JobQueue" for SpecialRunJobs. * Remove duplicate descriptions from file blocks in favour of class doc blocks. This reduces needless duplication and was often incorrect or outdated, and helps make file headers more consistently (visually) ignorable. Add missing `ingroup` to class blocks (and remove any from file blocks) as otherwise the file is indexed twice (e.g. in Doxygen) which makes navigation on doc.wikimedia.org rather messy. Ref https://gerrit.wikimedia.org/r/q/message:ingroup+is:merged Bug: T364652 Change-Id: I795c43b6d72782d457c963e352d7e1b022c2b641
* Standardise all our class alias deprecation comments for ease of greppingJames D. Forrester2024-03-191-3/+1
| | | | Change-Id: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
* Namespace HTMLForm and friendsJames D. Forrester2024-02-141-1/+1
| | | | | Bug: T353458 Change-Id: I09e66c3223018ec47e0549ee7f6a590b676f4eef
* Update name & email for bvibberBrooke Vibber2024-02-081-1/+1
| | | | | | | | | | | | | Updating name & email addresses for Brooke Vibber. Re-ran updateCredits.php as well so there are some new entries in there as well. There are a couple of files in resources/libs that will have to be changed upstream to keep tests happy, I will do patches later. :D Change-Id: I2f2e75d3fa42e8cf6de19a8fbb615bac28efcd54
* WikiImporter: Pass Authority for permissions instead of global contextBartosz Dziewoński2023-12-111-1/+1
| | | | | | | | | | | | | | | Pass Authority to WikiImporter constructor, instead of looking at the user from RequestContext::getMain(), and skipping this check if $wgCommandLineMode is true. Maintenance scripts now use UltimateAuthority, to match the original intent of skipping permission checks, see 2ed55f42 / r96311. The Authority parameter to WikiImporterFactory::getWikiImporter() is optional for now for backwards-compatibility. It should become required later after deprecation. Change-Id: Iea1d03dcdcbda2f9a9adbff1b0d319efd22c4d86
* ImportReporter: Deprecate using without setting contextBartosz Dziewoński2023-12-081-2/+2
| | | | Change-Id: Ife194ba4f077e63f86a95bd0d6ff782098c05040
* Namespace remaining 'specialpage' files under \MediaWiki\SpecialPageJames D. Forrester2023-09-181-1/+1
| | | | | | | SpecialPageFactory is already here, but none of the others were yet. Bug: T166010 Change-Id: I9689bf0a1ab329625e23669b99f019b96295fffd
* Remove redundant empty() constructs (3)Daimona Eaytoy2023-09-081-2/+2
| | | | | | | | | | | | | empty() only makes sense when the expression it checks is possibly undefined, otherwise it's equivalent to a truthiness check with the additional downside of suppressing errors when it's not wanted. Replace it with simple truthiness checks, using strict comparison when that seems to help with polymorphic variables. These were caught by a bespoke phan plugin. Change-Id: Ide262162553d2da7e5388d05e8731529c44591c1
* Use real type hints for services etc. in specials/ (A-M)Bartosz Dziewoński2023-08-291-5/+2
| | | | | | | | | | | | | | | Mostly used find-and-replace: Find: /\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?)[\s\*]+/\s*(private|protected|public) (\$[a-z]\w+;\n)((?=\s*/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?))\n|) Replace with: \3 \1 \4 Followed by some manual review to make sure I'm not changing too much, omitting some changes that looked too complicated and anything that caused test failures, and some whitespace fixes. Change-Id: I64a6d3bb24d38b9fe603f817c419292f385f2795
* 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
* Namespace SpecialImport under \MediaWiki\SpecialsJames D. Forrester2023-05-031-0/+17
| | | | Change-Id: I8b4cd11481d2be9aac6f6bd6c0bc45d6f8edc5ce
* Use str_starts_with/str_ends_with/str_containsUmherirrender2022-12-121-1/+1
| | | | | | | Use the new function in conditions to avoid creating substrings or to search the whole string Change-Id: Ibad6b1b447a4f62cceb34359231f88ebb967a90b
* SpecialImport: Replace custom JS with HTMLForm disable-ifTimo Tijhof2022-07-301-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | * Make use of the HTMLForm `disable-if` feature. This is documented in HTMLForm.php, and implemented by htmlform/cond-state.js using the same `$radios.filter( ':checked' )` and `setDisabled()` logic as was done here. * After enabling `disable-if` for HTMLForm in SpecialImport.php, one notable thing happens, which is that the individual radio buttons are wrapped and infused by OOUI. This would break the other hack in special.import.js relating to injecting the namespace selector in-between two adjacent radio inputs. This isn't natively supported in HTMLForm yet (afaik), and can be kept working by changing the CSS selector slightly to not rely on that implementation detail. It now works based on the default HTML rendering as done in PHP, regardless of whether it is infused or not. * Declare JS variables inline where possible. * Refactor the `sources` array to not involve extra DOM queries. Instead, list them as plain strings unconditionally and instead check for presence within the forEach. Change-Id: Ied90166a4a9deede220c7b8a9f9c1711ac69c72d
* Merge `mediawiki.special.import` into `mediawiki.misc-authed-ooui`DannyS7122022-06-231-3/+3
| | | | | | | | Tweak Special:Import code to only load the javascript after the permissions checks, to avoid unnecessary loading. Bug: T311191 Change-Id: Ifb055184e6abd7ca1e084dcdb3a5cf8af7a53b7c
* Use MainConfigNames instead of string literals, #2Aryeh Gregor2022-04-131-5/+6
| | | | | | | This covers all occurrences of /onfig->.*get( '/ in includes/. Undoubtedly there are still plenty more to go. Change-Id: I33196c4153437778496f40436bcde399638ac361
* phan: Disable null_casts_as_any_type settingUmherirrender2022-03-211-0/+3
| | | | | | | | | | | Make phan stricter about null types by setting null_casts_as_any_type to false (the default in mediawiki-phan-config) Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T242536 Bug: T301991 Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
* Change trivial use of getVal('action') to getRawValTimo Tijhof2021-08-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Per docs added in I18767cd809f67b, these don't need normalization as they are only compared against predefined strings, and besides are generally entered manually in a form, and even then would not require the kinds of Unicode chars that have multiple/non-normalized forms. In nearby areas to also fix some trivial cases: * getVal('title') obviously needs normalization. Use getText() to make this more obvious. * getVal() compared against simple string literals within the code obviously don't need normalization (e.g. printable === 'no'). * Change hot code in MediaWiki checking for whether 'diff' or 'oldid' are set to getCheck (which uses getRawVal) instead of getVal. As a bonus this means it now handles values like "0" correctly, which could theoretically have caused bad behaviour before. Change-Id: Ied721cfdf59c7ba11d1afa6f4cc59ede1381238e
* Revert "Use CsrfTokenSet as CSRF token source"Kunal Mehta2021-08-051-1/+1
| | | | | | | This reverts commit 0d75fdb4f73ddbf4ad5f29e14258d58e507d55b4. Bug: T287542 Change-Id: Iedd3461869f973f8d621a39e6ad4674cbb577551
* Use CsrfTokenSet as CSRF token sourcePetr Pchelko2021-07-121-1/+1
| | | | Change-Id: I079d2c802d9b48d6abf7f37fa9ef7dafac631345
* Use HTMLForm::setWrapperLegend and ::setSubmitTextMsg to set messagesUmherirrender2021-06-151-2/+2
| | | | | | | | setWrapperLegendMsg and setSubmitTextMsg are calling Message::text Replacing setSubmitText + Message::text with setSubmitTextMsg makes the code easier to read Change-Id: I73389991fea82e1927027dc95c3debc3d8c15939
* WikiImporter: inject servicesZabeMath2021-05-241-2/+11
| | | | | | | | This patch injects services into WikiImporter. It also adds a WikiImporterFactory service for creating WikiImporter instances. Change-Id: I2966297e5728fca1ae8280361f1008cef6c6041b
* SpecialImport: Avoid duplicate 'source' ID in formEd Sanders2021-02-241-2/+4
| | | | | | | There is still a duplicate wpEditToken ID, but that requires some upstream work to fix. Change-Id: Ibf891b4217567f5c1006dab9d6811fc2413905e4
* SpecialImport: Fix typo in name of 'mapping' inputEd Sanders2021-02-181-1/+1
| | | | | Bug: T275031 Change-Id: I733c538b849eff2de7dc0560970aa2f588c98704
* SpecialImport: Move namespace input next to radio option using JSEd Sanders2021-02-171-26/+2
| | | | | | | | | There doesn't appear to be a sensible way to do this using just PHP. As this is a progressive enhancement we can do it with JS instead. Bug: T274025 Change-Id: If9c14f9a06106bb0ebfb818e3c50659b6a39bd46
* Convert Special:Import to OOUIEd Sanders2021-01-271-333/+230
| | | | | | | Also include small style overrides to OOUIHTMLForm with own stylesheet. Bug: T108792 Change-Id: I77550ff40f51d4a748fed385cddcd70d5b64399e
* Inject services into SpecialExport/SpecialImportUmherirrender2020-10-211-6/+6
| | | | | | | | This covers only directly used services by this special page and pager Services used by the base class are not part of this patch set Bug: T259960 Change-Id: Ib6869d35afb8fc05709d42371c40ba8341af8f20
* Hooks::run() call site migrationTim Starling2020-05-301-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Migrate all callers of Hooks::run() to use the new HookContainer/HookRunner system. General principles: * Use DI if it is already used. We're not changing the way state is managed in this patch. * HookContainer is always injected, not HookRunner. HookContainer is a service, it's a more generic interface, it is the only thing that provides isRegistered() which is needed in some cases, and a HookRunner can be efficiently constructed from it (confirmed by benchmark). Because HookContainer is needed for object construction, it is also needed by all factories. * "Ask your friendly local base class". Big hierarchies like SpecialPage and ApiBase have getHookContainer() and getHookRunner() methods in the base class, and classes that extend that base class are not expected to know or care where the base class gets its HookContainer from. * ProtectedHookAccessorTrait provides protected getHookContainer() and getHookRunner() methods, getting them from the global service container. The point of this is to ease migration to DI by ensuring that call sites ask their local friendly base class rather than getting a HookRunner from the service container directly. * Private $this->hookRunner. In some smaller classes where accessor methods did not seem warranted, there is a private HookRunner property which is accessed directly. Very rarely (two cases), there is a protected property, for consistency with code that conventionally assumes protected=private, but in cases where the class might actually be overridden, a protected accessor is preferred over a protected property. * The last resort: Hooks::runner(). Mostly for static, file-scope and global code. In a few cases it was used for objects with broken construction schemes, out of horror or laziness. Constructors with new required arguments: * AuthManager * BadFileLookup * BlockManager * ClassicInterwikiLookup * ContentHandlerFactory * ContentSecurityPolicy * DefaultOptionsManager * DerivedPageDataUpdater * FullSearchResultWidget * HtmlCacheUpdater * LanguageFactory * LanguageNameUtils * LinkRenderer * LinkRendererFactory * LocalisationCache * MagicWordFactory * MessageCache * NamespaceInfo * PageEditStash * PageHandlerFactory * PageUpdater * ParserFactory * PermissionManager * RevisionStore * RevisionStoreFactory * SearchEngineConfig * SearchEngineFactory * SearchFormWidget * SearchNearMatcher * SessionBackend * SpecialPageFactory * UserNameUtils * UserOptionsManager * WatchedItemQueryService * WatchedItemStore Constructors with new optional arguments: * DefaultPreferencesFactory * Language * LinkHolderArray * MovePage * Parser * ParserCache * PasswordReset * Router setHookContainer() now required after construction: * AuthenticationProvider * ResourceLoaderModule * SearchEngine Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
* Fix some includes/specials/ Squiz.Scope.MethodScope.MissingReedy2020-05-181-1/+1
| | | | Change-Id: I9c19e5ce8d789847d0f019372738a2eecb4c37a6
* Special pages: Remove use of Title::getUserPermissionsErrors (part 2)DannyS7122020-02-141-17/+18
| | | | | | | | | SpecialChangeContentModel is not updated, since to avoid conflicts with I6eb38c4aec23619d7ec42ef12092edf9ff25c6fa which will remove the uses as part of T107174 Bug: T244929 Change-Id: Id0398fb3ed70d8cb03faab76991ea22cbe78fdb4
* Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNullJames D. Forrester2020-01-101-4/+4
| | | | Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
* Pass language to Status::getWikiTextUmherirrender2019-09-211-3/+4
| | | | | | Avoid use of $wgLang Change-Id: I9cd633a20c5c60e56a101a9a699eea6db8b8eef0
* Replace usages of deprecated User::isAllowed. Step 2.Petr Pchelko2019-09-111-4/+6
| | | | | | Bug: T220191 Depends-On: I509cd88355cfd0cc074f4135ec86399b4075f89f Change-Id: I2341e6f1d108c92924620fba3c64ec090cb09918
* Deprecate and replace usages of User:isAllowed{All,Any}Petr Pchelko2019-08-211-1/+5
| | | | | Bug: T220191 Change-Id: I197b8fadaa93e7b320fc19c10e3e09387fe09ad2
* Use HTTPS instead of protocol relative for WMF linksFomafix2019-05-171-1/+1
| | | | | | The WMF websites redirect from HTTP to HTTPS. Change-Id: I916c97697b4ffa9774eec9c8e6ab650a08bb6edd
* Fix calls to Title::getUserPermissionsErrors on SpecialImportAmir Sarabadani2019-04-151-2/+4
| | | | | | | Right now, it uses a deprecated way to set rigor causing it to read from master on GET, giving out errors Change-Id: I89bbe20080998bde2156680c631700b52f4e4712
* Collapse some nested if statementsReedy2019-04-041-4/+2
| | | | Change-Id: I9a97325d738d09370d29d35d5254bc0dadc57ff4
* Merge "Render namespace lists in the user's language"jenkins-bot2018-11-071-0/+1
|\
| * Render namespace lists in the user's languageErik Bernhardson2018-10-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Asking users to select from a list that is in a namespace other than their user language can be quite difficult. Transition a number of use cases. This was applied via a flag to avoid unexpectedly changing extensions also utilizing the namespace selector. Pages updated: * Special:Search * Special:Watchlist * Special:RecentChanges * Special:Contributions * Special:Import * Special:WhatLinksHere Bug: T174057 Change-Id: I3fdac72179a124849ef7ad1e0e54eb66396c3c6e
* | Use OutputPage::wrapWikiTextAsInterface() to add safe <div> wrappersC. Scott Ananian2018-10-171-2/+3
| | | | | | | | | | | | | | | | This ensures that broken messages can't break the <div> wrapper and that the output is tidy. Bug: T205624 Change-Id: I2511adf593a13528e205a82d9fcdc8a524d0a95f
* | Use OutputPage::addWikiTextAsInterface() instead of untidy addWikiText()C. Scott Ananian2018-10-171-1/+1
|/ | | | | | | | This change ensures that the output is tidy, and is necessary to support future parsers which will not be able to produce untidy output. Bug: T198214 Change-Id: I743f4185a03403f8d9b9db010ff1ee4e9342e062