Commit graph

52 commits

Author SHA1 Message Date
Aryeh Gregor
90d4f56fe4 Mass conversion of $wgContLang to service
Brought to you by vim macros.

Bug: T200246
Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
2018-08-11 22:44:29 -06:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
WMDE-Fisch
6f44e5b690 Add setting to control the creation of NullRevision on upload
When uploading multiple file revisions with fitting text revisions to
core the UploadRevisionImporter will create a unwanted NullRevision on
the file page.

This NullRevision originates from LocalFile:upload() and is added there
in recordUpload2 as part of the normal upload process. There it is meant
to leave a hint on the text revision history.

This whole area is in need of heavy refactoring. But since the issue is
blocking the current implementation of the FileImporter extension, a
parameter is added to control the creation of that NullRevision.

Bug: T193621
Change-Id: I57c947eb63a7627ab1eec850cdf5e076f5f62df5
2018-05-09 18:17:06 +02:00
Brad Jorsch
f09d66de2a import: Don't try duplicate detection when the sha1 is unavailable
Trying to compare a string field with 0 (cast from false) raises an
error in PostgreSQL, and we're expecting it to not detect duplicates in
that situation anyway.

Change-Id: Ibff6daee6bbec00e37532e03c9ece041ba612de0
2018-04-23 16:57:28 -04:00
jenkins-bot
092450edfa Merge "ImportStreamSource: Replace magic numbers with constants" 2018-04-18 19:52:45 +00:00
Thiemo Kreuz
f449e1ce7c Fix bad archive file names in ImportableUploadRevisionImporter
Bug: T176871
Change-Id: I61625a515a8d49dec33af49022506be2e019a23b
2018-04-16 19:30:07 +02:00
Bartosz Dziewoński
9c881ed4da ImportStreamSource: Replace magic numbers with constants
https://secure.php.net/manual/en/features.file-upload.errors.php

Also improve code comments.

Change-Id: I3bbe02f5cce39352659b33caba10e40afc5fe34a
2018-04-16 18:39:24 +02:00
Brad Jorsch
27c61fb1e9 Add actor table and code to start using it
Storing the user name or IP in every row in large tables like revision
and logging takes up space and makes operations on these tables slower.
This patch begins the process of moving those into one "actor" table
which other tables can reference with a single integer field.

A subsequent patch will remove the old columns.

Bug: T167246
Depends-On: I9293fd6e0f958d87e52965de925046f1bb8f8a50
Change-Id: I8d825eb02c69cc66d90bd41325133fd3f99f0226
2018-02-23 10:06:20 -08:00
addshore
e6c0dcc02e Factor OldRevisionImporter & ImportableOldRevision out of WikiRevision
This is to be used within the FileImporter extension to allow
adding custom loggers to this import process.

Change-Id: Ib094d4829764ccc8e5bd2619fb827d701ae06d43
2018-02-20 10:26:47 +00:00
addshore
25fbfd9b9c Factor UploadRevisionImporter & ImportableUploadRevision out of WikiRevision
This is to be used within the FileImporter extension to allow
adding custom loggers to this import process.

Change-Id: I4a6c573fc0a69b06d696cd2afca9226fb492a9bc
2018-02-20 10:26:42 +00:00
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +00:00
addshore
e5879da149 Pass $key into CommentStore methods and use MediawikiServices
This allows CommentStore to be added to MediaWikiServices
without the need of an aditional Factory.

This change includes a compatability layer to allow the behaviour
from 1.30 to continue to be used while deprecated.

CommentStore::newKey has been deprecated.
Keys are now passed into the public methods of CommentStore
where needed.
The following CommentStore methods have had their signatures changed
to introduced a $key parameter, but when used in conjunction with
CommentStore::newKey behaviour will remain unchanged:
  * CommentStore::getFields
  * CommentStore::getJoin
  * CommentStore::getComment
  * CommentStore::getCommentLegacy
  * CommentStore::insert
  * CommentStore::insertWithTemplate

Change-Id: I3abb62a5cfb0dcd456da9f4eb35583476ae41cfb
2018-02-05 15:34:12 +00:00
Umherirrender
3124a990a2 Use ::class to resolve class names in includes files
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I07a925c2a9404b0865e8a8703864ded9d14aa769
2018-01-27 20:34:29 +01:00
Amir Sarabadani
dc4089b268 Move methods for handling external usernames to a dedicated class
This makes things centralized to reduce maintenance cost and also
enables me to use this methods in Wikibase to handle RC injection

Bug: T185034
Change-Id: Ic8c602e316144ccb5b05c69a0cc607cd53e38912
2018-01-18 21:02:49 +01:00
Yifei He
6db33c1a4b [WikiImporter::notice] use wfDebug instead of echo in notice()
Make the default notice implementation of notice() function to
send the notice to wfDebug() instead of simply echo to prevent XSS

Bug: T177997
Change-Id: I9ffb597e0642afc1603cdd15e2d09c6f2584b448
2017-12-22 12:24:42 +08:00
Huji Lee
e74bfe13f6 Require indentation of CASE statements in PHP code
Bug: T182546
Change-Id: I91a9555893a08e4ec58da97c6cc4d1e70000ff6b
2017-12-10 22:07:50 -05:00
jenkins-bot
d0142faf25 Merge "Add missing @throws in Importers" 2017-12-06 12:49:50 +00:00
WMDE-Fisch
a2f68a58cd Add missing @throws in Importers
Change-Id: I02760e59d73f4278cca87483ab4578b6e76b2324
2017-12-06 12:38:08 +00:00
Brad Jorsch
96bd79b4a3 Avoid DB rows with usable names but ID = 0 by introducing "interwiki" usernames
Importing revisions in MediaWiki has long been weird: if the username on
the imported revision exists locally it's automatically attributed to
the local user, while if the name does not exist locally we wind up with
revision table rows with rev_user = 0 and rev_user_text being a valid
name that someone might later create. "Global" blocks too create rows
with ipb_by = 0 an ipb_by_text being a valid name.

The upcoming actor table change, as things currently stand, would
regularize that a bit by automatically attributing those imported
revisions to the newly-created user. But that's not necessarily what we
actually want to happen. And it would certainly confuse CentralAuth's
attempt to detect its own global blocks.

Thus, this patch introduces "interwiki" usernames that aren't valid for
local use, of the format "iw>Example".[1] Linker will interpret these
names and generate an appropriate interwiki link in history pages and
the like, as if from wikitext like `[[iw:User:Example]]`.

Imports for non-existant local users (and optionally for existing local
users too) will credit the edit to such an interwiki name. There is also
a new hook, 'ImportHandleUnknownUser', to allow extension such as
CentralAuth to create local users as their edits are imported.

Block will no longer accept usable-but-nonexistent names for 'byText' or
->setBlocker(). CentralAuth's global blocks will be submitted with an
interwiki username (see Ieae5d24f9).

Wikis that have imported edits or CentralAuth global blocks should run
the new maintenance/cleanupUsersWithNoId.php maintenance script. This
isn't done by update.php because (1) it needs an interwiki prefix to use
and (2) the updater can't know whether to pass the `--assign` flag.

[1]: '>' was used instead of the more usual ':' because WMF wikis have
many existing usernames containing colons.

Bug: T9240
Bug: T20209
Bug: T111605
Change-Id: I5401941c06102e8faa813910519d55482dff36cb
Depends-On: Ieae5d24f9098c1977447c50a8d4e2cab58a24d9f
2017-11-30 13:12:44 +11:00
Umherirrender
bd741b83bc build: Updating mediawiki/mediawiki-codesniffer to 13.0.0
Change-Id: Ia24dbf015f2b4781683ca980a460d0ac3e85674e
2017-09-25 17:31:56 +02:00
Brad Jorsch
01a10dba5a Remove reference to deprecated IDatabase->nextSequenceValue()
The method was deprecated and made unnecessary in Ib308190c.

Change-Id: I1729ac0b3a88270a4c2f064187a2472112aaeb1e
2017-09-01 12:28:39 -04:00
Brad Jorsch
11cf01dd9a Add comment table and code to start using it
A subsequent patch will remove the old columns.

Bug: T166732
Change-Id: Ic3a434c061ed6e443ea072bc62dda09acbeeed7f
2017-08-30 15:05:00 +10:00
Matthew Bowker
af1434ff2f Change WikiImporter to now requires the second parameter to be an instance of the Config class.
Prior to this change, the second parameter to WikiImporter was optional.  If the parameter didn't exist, it would get filled in with a MediaWikiServices::getInstance()->getMainConfig().  It would also emit a hard deprecation warning. This behavior has existed since 1.25.

Bug: T61113
Change-Id: Ic15cc103c7d2b7fb499f1632c0001b8a3dbdf778
2017-08-14 18:18:53 +02:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
Kunal Mehta
d1cf48a397 build: Update mediawiki/mediawiki-codesniffer to 0.10.1
And auto-fix all errors.

The `<exclude-pattern>` stanzas are now included in the default ruleset
and don't need to be repeated.

Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a
2017-07-22 18:24:09 -07:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
Mehmet Mert Yıldıran
4951c2b54f Add skipping to nth page option/ability for dump importing process
Usage: php importDump.php --skip-to 271500 /path_to/dumpfile.xml.gz

When importing a database dump and the import process crashes
(for random reasons) after a certain number of pages, the
"--skip-to" parameter allows restarting the import process at
a certain page instead of starting the import from scratch.

Change-Id: Ib36063b69d6846fc197800bba44287493b0632c0
2017-06-09 01:01:05 +03:00
addshore
165041b4e4 Add @since tags to WikiRevision
Change-Id: I02005184d2cb3fa50aa0a51221b40e7c621219d2
2017-03-25 00:53:09 +00:00
addshore
417bd2905c Deprecate WikiRevision::$user
This was introduced in 436a028086
but was not used there.
It also currently looks unused.

We could go ahead and just remove this now, as anything that wants
to set the $user when the property is removed would still succeed.
But lets adhere to the deprecation policy here.

Change-Id: Id47323bb1ff480a16b46107825ed5f2f861ad976
2017-03-21 23:10:40 +00:00
addshore
213acd8202 Deprecate WikiRevision::$importer
This was introduced in 9b3128eb2b
but was not used there.
It also currently looks unused, even when grepping for possible
magic usages of 'importer' and "importer".

We could go ahead and just remove this now, as anything that wants
to set the $importer when the property is removed would still succeed.
But lets adhere to the deprecation policy here.

Change-Id: I5ac16dd87a95be6a3cdd4b16988d37d1d6104749
2017-03-21 23:10:19 +00:00
addshore
fd30abb59a Deprecate WikiRevision::$fileIsTemp and fix $isTemp
Cleanup from 43d5d3b682

This commit introduces both $fileIsTemp $isTemp
It would appear that the intent was to have one property here
and it looks like both of these are meant to do the same thing.

It also looks as if both public properties are actually unused
(only used by the getter and setters)

As isTemp will now sometimes return true line 766 $autoDeleteSource
will be true in new cases.
As a result $tmpFile->autocollect(); will be called in more cases

Change-Id: I8014172fb9fd7a0e4a89d0872bafdf6c50f92646
2017-03-21 23:09:34 +00:00
addshore
11ed7a4255 Mark WikiRevision methods as public
Change-Id: If252103d4850d9c9f0607a225b7d345736658cc7
2017-03-15 14:53:19 +00:00
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
2017-02-21 18:13:24 +00:00
Yuriy Shnitkovskiy
85a52faa37 Removed deprecated usages of Interwiki methods in core
Change-Id: Ibd25968660466c44189ccb01df1d8bec6e1b207c
2017-01-10 12:19:31 +02:00
Subin Siby
1f8b491dd2 Disable statistics update on import with maintenance/importDump.php
Disable updating statistics in importDump.php to quickly finish imports from command line.

Bug: T144600
Change-Id: Ib827c068fb20cc03aab47e3106d489f18be1dac6
2017-01-03 20:26:09 +05:30
rlot
0480391371 Added $wgHTTPImportTimeout setting
Bug: T17000
Change-Id: Ic97ae4faec173c32af38df4554831dca7068226b
2017-01-03 07:34:58 +01:00
Subin Siby
2c4a6cc7e0 Remove incorrect deprecated notice from function WikiRevision::getText()
WikiRevision::getText() was wrongly marked deprecated in 1.21.
This has been fixed.

Bug: T152282
Bug: T61113
Change-Id: I3f0e0f7fe38bd4e2001efbe17cdba6bcc90b036f
2016-12-27 13:25:47 +05:30
addshore
b12086b618 Get ConfigFactory & MainConfig from MediaWikiServices
Change-Id: Iafdd7e00747060572463ffb05aae4543f3a06163
2016-11-23 00:12:38 +00:00
daniel
4aa4e7d796 Deprecfate WikiRevision::getText
Bug: T146162
Change-Id: I60249d687ac74baca146ed28d57c9a8ebcd79fba
2016-09-20 18:35:26 +02:00
Aaron Schulz
16266edff3 Change "slave" => "replica DB" in /includes
Change-Id: Icb716219c9335ff8fa447b1733d04b71d9712bf9
2016-09-05 21:01:01 +00:00
Aaron Schulz
a4d737f229 Remove web-request usages of deadlockLoop()
Add comment discouraging use of the method. There are no problems
with deadlocks/timeouts in these code paths according to WMF logs.

Change-Id: I5b21cc423df584efa881361063000e01932cc2ea
2016-07-26 18:44:41 -07:00
Brad Jorsch
b6fce440b7 Apply $wgMaxArticleSize more exactly
$wgMaxArticleSize is defined as "maximum article size in kilobytes",
however the way it was being used in WikiImporter and EditPage was
actually allowing 1023 bytes more than the limit. Other code using the
variable was limiting it to the specified value.

Change-Id: I85e4d2146643c5ac65f27cf464a51b28d68440b0
2016-06-27 11:45:13 -04:00
Aaron Schulz
3261508d4d Cleanups to WikiRevision
* Check for blank $source variable more properly.
* Avoid use of ugly File::DELETE_SOURCE flag.
* Remove now-unused $flags parameter to uploadOld().

Change-Id: I6bc610cfead0036700b4f9a82e13f2bd9ab10f32
2016-03-23 17:27:23 +00:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00
Reedy
1834ee3d8e Fix numerous class/function casing
Change-Id: I23982bfa0548c9ea3bdb432be7982f1563930715
2016-03-18 23:14:49 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Andrew H
c812fa3cb3 Add maintenance script importTextFiles.php
importTextFiles.php can be used to import pages from text files
containing wikitext.

Also, added $userObj to WikiRevision so that it can accept a User
object instead of just a username.

This is a GCI task.

Change-Id: I20eaf2005bdd3d041f55d8c0b108f001c064d638
2016-01-08 00:57:11 +00:00
jenkins-bot
ab0a02f640 Merge "Restore changes to WikiRevision that were lost in cdeba4cfc7c" 2016-01-06 17:42:28 +00:00
This, that and the other
2cc10db042 Import: Try to stop revisions getting created with rev_page = 0
It seems that when two simultaneous imports of the same page are started,
we get into the situation where $pageId is 0 (or at least something that
is transformed to 0 when inserted into the DB).

I can't reproduce this locally, so I can't tell you *why* this is
happening. But what is important is to stop it from happening.

Bug: T18674
Change-Id: I79406a1ef8e5db9a31f029438f8132ef590216fe
2016-01-03 21:56:02 +00:00
This, that and the other
ec1b05892b Restore changes to WikiRevision that were lost in cdeba4cfc7
The commit cdeba4cfc7 unintentionally "reverted" part of commits
0623aeb922 and b14d581dab.

Change-Id: I19334bd6b871ab0555c6db873a67e935011aaaa4
2016-01-04 00:55:35 +11:00