aboutsummaryrefslogtreecommitdiffstats
path: root/includes/import
Commit message (Collapse)AuthorAgeFilesLines
* WikiImporter: Improve error message outputReedy2023-07-101-2/+3
| | | | | | Bug: T341434 Change-Id: I51e8fc6d44dddecfba8f7c47fcff9fffdf15e2b0 (cherry picked from commit c397e4ff70bbc604b54602dc315d5918f688622b)
* Work around argument corruption bug in XMLReader::openTim Starling2023-06-291-5/+16
| | | | | | | | | | | Use a static call to XMLReader::open() in PHP 8.0.0+. Remove the check for LIBXML_PARSEHUGE since it is always available in PHP 7.4+. The #ifdef was removed. Bug: T330464 Change-Id: I39f050c5d4e461923a84ebb8b3b1d92c021d2e7a (cherry picked from commit 7aeadbf81bba17051d8d9b52969d4ff398c6b0dd)
* WikiImporter: do not fail if upload entry in dump lacks 'text' tagFerran Tufan2023-02-201-0/+2
| | | | | | | | | If the text key does not exist (which is expected for uploads), the makeContent function throws an exception. Bug: T292348 Change-Id: Ib4946e98fc9c53f28cb7d26953985006508dd90a (cherry picked from commit f862ea57f09a4267a4e989aa4985a2301c29a5e6)
* stream wrapper: Declare $context class propertyUmherirrender2023-01-071-0/+3
| | | | | | | | | | | | Creation of dynamic property UploadSourceAdapter::$context is deprecated in php8.2 Prototyp says this property must exists https://www.php.net/manual/en/class.streamwrapper.php Bug: T314099 Change-Id: I8f8b42c2ea3351a3becdfac36248f6d371c32fe3 (cherry picked from commit 85ec890e7f3c651687509e99040075027063a1c8)
* When importing revision with same timestamp as latest revision, treat it as ↵Bartosz Dziewoński2022-10-251-1/+1
| | | | | | | | | | | | | | | | the new latest Elsewhere in MediaWiki, ties between revisions with identical timestamps are resolved by comparing their revision IDs (see RevisionStore::getRelativeRevision), and the revision being imported will necessarily have a higher ID than any existing one. Also, elsewhere in this file we already assume that "multiple revisions of the same page are imported in order from oldest to newest" (see code comment on line 142). Change-Id: I56f0e161e5438d5f77b7d53d4db7411f90f97d05 (cherry picked from commit 92474073a5d23b681007d78940b183d431978f0e)
* ImportStreamSource::newFromURL() Prevent passing null to fwriteReedy2022-08-161-1/+1
| | | | | | | HttpRequestFactory::request returns null on failure, not false Bug: T315309 Change-Id: Ifeee184abe9faa3e9b45f9cf8db84d35a104fdbb
* Fix broken user name vs. IP import logic in WikiImporterThiemo Kreuz2022-08-051-13/+10
| | | | | | | | | | | | | | | | | | | | | | 1. The code that processes $logInfo first calls setUserIP(), and then uncontitionally calls setUsername() with "Unknown user". Because both setters write to the same field (see I6687305) the IP was never stored. 2. Flip conditionals to prefer user name over IP. Usually this shouldn't make a difference. Only one of the two fields should be set. But if both are set the better logic is to store the name of the logged in user, instead of silently turning them into an anonymous one. I am not sure if this is actually related to the linked tasks, but might be. The bug was introduced in 2015 via Idf95263 (T121338). The setUserIP/setUsername problem exists since 2004, see https://phabricator.wikimedia.org/rMW436a0280. Bug: T11041 Bug: T236644 Change-Id: I1b8ed89a4190b55d3a9e4ecd9a83b0a042e493be
* Migrate use of ${var}-style string interpolationMáté Szabó2022-07-291-1/+1
| | | | | | | | The "${var}" and "${expr}" style string interpolations are deprecated in PHP 8.2. Migrate usages in core to "{$var}" as appropriate. Bug: T314096 Change-Id: I269bad3d4a68c2b251b3e71a066289d4ad9fd496
* import: UploadSourceAdapter::stream_read() don't pass null to strlen()Reedy2022-07-091-2/+3
| | | | | Bug: T312678 Change-Id: I4e523352120ede4cc216ae5035b52f4e83913103
* Hard deprecate WikiRevision::downloadSourceMatěj Suchánek2022-07-081-1/+2
| | | | | | It has been deprecated since 1.31 and it is unused. Change-Id: Ieb2273939fa5d4244ccf1fd4a653ec784167dfe1
* Hard deprecate access to WikiRevision::$fileIsTempMatěj Suchánek2022-07-051-2/+5
| | | | | | The property has been deprecated since 1.29. Change-Id: I04ab2fc7aac85f448ebef3bb5bc24aa5c617f233
* Merge "Remove unsed code snippets from ImportableOldRevisionImporter"jenkins-bot2022-05-211-11/+4
|\
| * Remove unsed code snippets from ImportableOldRevisionImporterThiemo Kreuz2022-04-251-11/+4
| | | | | | | | Change-Id: I20878f8958329d09b1d4ce88403063a62b70f89f
* | import: Soft-deprecate WikiRevision::getUserObj and related methodsThiemo Kreuz2022-05-153-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reasoning: * Not all code needs an actual User object. And even if, most code doesn't need it to be validated. That's expensive. Let the users decide. * setUserObj() is almost never called anyway. And the few places that call it go the extra mile and create a User object just to please this setter. We can avoid or at least postpone this. * All callers already fall back to getUser() when there is no getUserObj(). * For a while we try to replace the User class with much smaller interfaces, whenever possible. This is a chance to remove of one more. * A "user IP" is a concept that doesn't even exist in this code. The setter writes to the same property as setUsername(). This makes it very easy to use these methods wrong, and this indeed already happened in some places. Change-Id: I6687305a5be68e8a068f11482625a0a6bd9626f2
* | import: Fix incomplete type hint for WikiRevision::getUserObjThiemo Kreuz2022-05-153-5/+6
|/ | | | | | | | | | | | | This is almost always null. All callers expect this already and fall back to getUser(). It looks like setUserObj() is sometimes called with false. Luckily the users I can find use the ?: operator and behave the same, no matter if they get null or false. Let's fix it anyway to make the code less surprising. Depends-On: Id019f633a19f925faa1e5890a9b7818bb9e81a84 Change-Id: I128c21c60f6bb017521218933c22e6f1754e9133
* Use MainConfigNames instead of string literalsAryeh Gregor2022-04-113-3/+8
| | | | | | | | Part 1, proof of concept. Hundreds of files left to go. These changes brought to you in large part by vim macros. Bug: T305805 Change-Id: I44789091e9f6394c800a11b29f22528c8dcacf71
* phan: Remove PhanPossiblyUndeclaredVariable suppressionUmherirrender2022-03-301-0/+1
| | | | | | | | | Make phan stricter about conditional variable declaration Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T259172 Change-Id: I1f200ac37df7448453688bf464a8250c97313e5d
* Check return of parse_url for used url partsUmherirrender2022-03-291-0/+3
| | | | | | Found by phan (T304887) Change-Id: I3105a5fd4826f8667b5232834defc5ec93be32a1
* phan: Disable null_casts_as_any_type settingUmherirrender2022-03-211-0/+1
| | | | | | | | | | | 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
* Add various fallback values for null return valuesUmherirrender2022-03-091-1/+1
| | | | | | Found by phan strict checks Change-Id: I83187b5fd25b015d2c75e22d4b5202803653d743
* Consistently use `@deprecated since` rather `@deprecated`Reedy2022-03-061-1/+1
| | | | Change-Id: I301786f35cd6eb9c63fb72e0b64cffa9efd7b86b
* Replace some more usages of Wikimedia\(suppress|restore)Warnings()Reedy2022-02-241-2/+3
| | | | Change-Id: I2eb133a9e32116cd155f59086245bc4d15ecbfcc
* import: Use UserFactory in ImportableOldRevisionImporterUmherirrender2022-02-111-4/+11
| | | | Change-Id: I60b1b4cbc4d17ba068d8d3dfb81d38fea30fb9b3
* 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
* Suppress deprecation warnings from libxml_disable_entity_loader()Tim Starling2022-01-211-6/+12
| | | | | | | | | | As discussed in the task, there is no simple replacement for this function. Reduces core PHPUnit error count from 121 to 2. Bug: T268847 Change-Id: Ia8697e1c3ba369346b39ef50d94ea8b132eb9c80
* Refactor global variables to use MediaWikiServices insteadTChin2022-01-102-5/+7
| | | | | | | | | | | | Automatically refactors wg prefixed globals to use MediaWikiServices config using Rector. Doesn't include files that set globals or files that fail CI. Rector Gist: https://gist.github.com/tchin25/7cc54f6d23aedef010b22e4dfbead228 * This patch uses a modified source code rector library for our specific use case and the rector will have different effects without it. A writeup for future reference is here: https://meta.wikimedia.org/wiki/User:TChin_(WMF)/Using_Rector_On_MediaWiki Change-Id: I1a691f01cd82e60bf41207d32501edb4b9835e37
* Fix typos in comments (I-J)Siddharth VP2021-12-302-2/+2
| | | | Change-Id: Icaea2b6665cfc3b811d94f70c93452237f5e72bf
* Introduced PreparedUpdate to replace PreparedEditdaniel2021-12-201-6/+6
| | | | | | | | | | | | PreparedUpdate represents an in-progress edit. It can be used to access information about the edit from hooks that do to have access to the PageUpdater. Ideally, the PreparedUpdate or PageUpdater would be passed to the hook as a parameter. Handlers of legacy hooks may use WikiPage::prepareUpdate() to access it. Bug: T242249 Needed-By: I23324a31e06e7e6f28077085c0ade05db63e9a35 Change-Id: Id5ba40a21cc4547205adf2f3a1f725c3a69c24d8
* Merge "import/export: Add documentation for nullable arguments"jenkins-bot2021-10-201-9/+9
|\
| * import/export: Add documentation for nullable argumentsUmherirrender2021-10-161-9/+9
| | | | | | | | Change-Id: Id8e4553a054a36011433d5705c699d1c2730456e
* | WikiImporter: improve error handlingGergő Tisza2021-10-161-2/+11
|/ | | | | | | | | | | | This is an attempt at getting a more useful error message than "Import failed Expected <mediawiki> tag, got" (ie. XMLReader thinking that the root tag name is the empty string). E.g. with the dump file I'm debugging at the moment, after applying this patch I get "XML error at line 1: Extra content at the end of the document" instead. Change-Id: I365eebf78c30b644808eb5ac42d0946c8cf60778
* Migrate `WikiPage::doEditUpdates()` to using `PageUpdaterFactory`Derick Alangi2021-10-071-8/+22
| | | | | | | | WikiPage::doEditUpdates() has been deprecated. Using the PageUpdaterFactory's newDerivedPageDataUpdater() is the new way forward. Also, I made sure to have the `$options` array with the `causeAction` and `causeAgent` key/value pairs. Change-Id: I9f2c212d7c83a46799f9f947dc372dc364289680
* Change 'fromdbmaster' to WikiPage::READ_LATESTUmherirrender2021-09-262-2/+2
| | | | | | Constants are harder to misspell Change-Id: Ie1afcc8580cccf815df1cc97f05a5be81676d9f7
* Merge "Same code style and formatting for exists-style SQL queries"jenkins-bot2021-08-242-2/+2
|\
| * Same code style and formatting for exists-style SQL queriesThiemo Kreuz2021-08-122-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Queries that query a value "1" are expected to return either that "1" (possibly as a string), or false. It's safe to simply cast this to bool and use it as it is. Queries for COUNT(*) are expected to return that number, possibly as a string. It's not possible for such a query to return false. And even if, casting to 0 is fine. I found an existing code style where the table name and the "1" are on the same line as the selectField() method name, and applied it to all similar queries. Change-Id: I9453196281871c03ef03f653f43762eb9284342f
* | Merge "WikiRevision: ensure that $comment is a string"jenkins-bot2021-08-141-2/+2
|\ \
| * | WikiRevision: ensure that $comment is a stringDaimona Eaytoy2021-08-141-2/+2
| |/ | | | | | | | | | | | | It's documented as string only, but some code (possibly test code) is passing null, causing failures for I0e7e4a48b56c3e5fde56f50693fd0cdc19c30dd0. Change-Id: I07e2fc0c6249e8bcda3af99213fcf26f17e6df94
* / import: Remove unused debug callbackUmherirrender2021-08-131-17/+0
|/ | | | Change-Id: Iaa9360939a7151851c69667b411ae12daa381dbb
* Merge "Add missing spaces to imploded debug strings"jenkins-bot2021-07-281-3/+3
|\
| * Add missing spaces to imploded debug stringsMatěj Suchánek2021-07-281-3/+3
| | | | | | | | Change-Id: I32d921aaa3a5799777ff62b35608cbedcfff907d
* | build: Updating dependencieslibraryupgrader2021-07-221-1/+1
|/ | | | | | | | | | | | | | 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
* Don't allow null values for services in WikiImporterAlexander Vorwerk2021-07-141-18/+18
| | | | | | | | | The fallback to global state for the services injected into WikiImporter has been removed with Ide7693a411d, thus these services need to be injected and are not allowed to be null. Bug: T283530 Change-Id: Iff6e673f56c48bafad4f7dc5732e136b9359f149
* Remove fallback to global state in WikiImporterAlexander Vorwerk2021-07-121-23/+9
| | | | | Bug: T283530 Change-Id: Ide7693a411d76e11bd1611b2ffd269cb1f23799c
* Merge "Remove the fallback for create rights (covered in PM edit rights ↵jenkins-bot2021-06-301-7/+0
|\ | | | | | | check). Remove key to i18n message, no longer being used."
| * Remove the fallback for create rights (covered in PM edit rights check).Roman Stolar2021-06-301-7/+0
| | | | | | | | | | | | | | Remove key to i18n message, no longer being used. Bug: T272079 Change-Id: Id6566e5241b06ba377c2eca083221ee02556365f
* | Merge "Use IEC prefixes instead of SI prefixes for byte sizes (docs+backend)"jenkins-bot2021-06-291-1/+1
|\ \
| * | Use IEC prefixes instead of SI prefixes for byte sizes (docs+backend)Fomafix2021-06-281-1/+1
| |/ | | | | | | | | | | | | This change doesn't change any UI messages. Bug: T54687 Change-Id: Ia62899a2a6fe8910618c35cd667291e397ddb055
* / WikiImporter: Pass a user to WikiPage::prepareContentForEdit()DannyS7122021-06-271-1/+3
|/ | | | | | | | | | Need to rely on RequestContext::getMain() since no user is available nor is injecting one simple to do (the calling method, ::finishImportPage, is used as a callback and extensions can replace it with their own callbacks instead) Bug: T285447 Change-Id: I02e01e52909da51e7001b4acee43567ae645d9a7
* Fix 'instances' typoAlexander Vorwerk2021-06-031-1/+1
| | | | Change-Id: Iadcb20f76dc0d7623a60d9b8a63b097e6d5d7732
* WikiImporter: inject servicesZabeMath2021-05-242-34/+234
| | | | | | | | This patch injects services into WikiImporter. It also adds a WikiImporterFactory service for creating WikiImporter instances. Change-Id: I2966297e5728fca1ae8280361f1008cef6c6041b