Commit graph

308 commits

Author SHA1 Message Date
Reedy
6aaaa070f3 Remove MimeMagic
Deprecated since 1.28

Change-Id: I793deb8669e353525464ccd840801e5015c545c8
2018-09-23 20:13:29 +00:00
daniel
4835a75ec5 Use RevisionRenderer for rendering ParserOutput
Bug: T174035
Bug: T174036
Change-Id: I1085b05d635dd954c143c8a398fae909632ba0a9
2018-09-11 15:25:39 +00:00
Fomafix
0a0d5cb7f7 Fix typos
Bug: T201491
Change-Id: I25a27d11faabe2f5fa02950c7a4fb58b13fb3662
2018-08-14 09:52:19 +00:00
Fomafix
73f94fd8cd Add type hint Language where possible
Also use ?? instead of ?: to check for null.

Change-Id: I058b61d7e06cdefecdafa82f60109cc386e2a809
2018-08-12 10:20:11 +02:00
jenkins-bot
216865344b Merge "rdbms: add IDatabase::lockForUpdate() convenience method" 2018-07-11 19:52:31 +00:00
Aaron Schulz
9eff263e8e rdbms: add IDatabase::lockForUpdate() convenience method
Change-Id: I238fd96407e1122e90058e2c4acf743044a267ec
2018-07-10 20:09:01 +01:00
Brad Jorsch
377ce5a469 Fix error in various deprecated selectFields() methods
When aliasing a field to null, it has to be aliased to the string 'NULL'
rather than PHP null.

Bug: T198687
Change-Id: I6096f306b97022da781eaabeb15e502f391673a9
2018-07-03 11:59:18 -04:00
Aaron Schulz
505a0e913a Make LocalFile file locking calls use Status::wrap
This avoids the assumption that a wrapper was set in the FileBackend.

Change-Id: I4d41d63b00e41476d885f714d17d1ba62b63b6ec
2018-06-14 07:30:07 +00: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
jenkins-bot
f93af41d45 Merge "Add setting to control the creation of NullRevision on upload" 2018-05-15 07:31:09 +00: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
WMDE-Fisch
2330c9afad Replace deprecated ObjectCache and CommentStore calls in filerepo
Change-Id: I0e863dc8e4bc6dac938a2ed437c2691aace19690
2018-05-07 11:00:23 +02:00
Thiemo Kreuz
645d96b0e1 Fix and improve PHPDoc type hints in FileBackend and FileRepo
Change-Id: I311b4a6777946b451d70c6fdb2133dbbd73f159f
2018-04-19 10:32:09 +02:00
Aaron Schulz
4358ee16e8 Fix LocalFileMoveBatch query that was incompatibile with Postgres
Bug: T160910
Change-Id: I7ed6acec08243ff8380d28bbe5d66610a77502dc
2018-04-12 00:23:41 -07:00
Brad Jorsch
9ceb2e08a0 Move image_comment_temp entries when the file is moved
Bug: T189985
Change-Id: I437102d62cb94fd3195ff06ee8185ce5a2dc941e
2018-03-18 11:37:05 -04: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
Aaron Schulz
d9ba7cd005 Make LocalFile check early if the revision store is available
This reduces the odds of having files without corresponding
wiki pages, given that the later is done in a deferred update.

Also made some documentation cleanups.

Bug: T187942
Change-Id: Iff516669f535713d37e0011e2d7ed285c667f1c5
2018-02-22 22:07:30 +00:00
Reedy
fbc0347466 Update MediaWiki\quietCall() -> Wikimedia\quietCall()
Bug: T182273
Change-Id: Id7d8e176fcd93040e30e46cb64fc6a3d36bc8230
2018-02-10 10:49:33 +00:00
Brad Jorsch
d4fb0ae7e9 Fix CommentStore->createComment() call in LocalFile.php
This was incorrectly changed in I3abb62a5, createComment() is not one of
the methods that was adjusted in that patch.

Change-Id: I9c26e0ad69ffc6fa5349a6975a4134efb3cf0eff
2018-02-09 12:43:30 -05: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
Reedy
c16af68fb6 Replace MimeMagic::singleton() calls
Change-Id: Ieed41b5d6b0f568fe2872e7754f2feae7868fe7a
2017-11-27 02:13:51 +00:00
jenkins-bot
b5370206ff Merge "Add action/user tracking to html cache purge jobs" 2017-11-09 22:33:48 +00:00
Brad Jorsch
c2f432625f Add deprecation notices for selectFields() methods deprecated in Idcfd1556
Now that WMF-deployed extensions have been updated to no longer call
them.

Change-Id: I04942ca1b95baa2126f2dcf4d0975536f4dd07c7
Depends-On: I300130c7b952a353ac28989d39d7f01366da2a37
Depends-On: Ia81bf6a655af800ce8ac19940d851e65746e1f77
Depends-On: I0d869aacaaad85cdd34361a611ac8348bdbb757d
Depends-On: I7b05a99e23da296a673eb0bd34f18344618c8be3
Depends-On: I42237e8e29497bbc56606f6ad01de3d525bf8b2a
Depends-On: If75d2e76c2f166bc40a544dd502da43171ce1e7b
Depends-On: I401809d2638b11e6c77a318fc8fbbc41fa639083
Depends-On: I5d62ad76fdb64a9c6efd228f27e9b5f512f17d5e
Depends-On: I488afaa991e3d26b638a4f588f70db455959eadf
Depends-On: Ibe82dadb0f2d1c5dbc38b96731c6e443c5469ff0
Depends-On: Id25b86dd415e2e3c6190a91faee2a3b815e50f61
2017-11-01 14:50:56 +00:00
Brad Jorsch
3488f49532 Replace selectFields() methods with getQueryInfo()
Several classes have a "selectFields()" static method to tell callers
which fields to select from the database. With the recent comment table
change and the upcoming actor table change, this pattern has become too
simplistic as a SELECT will need to join several tables to be able to
retrieve all the needed fields.

Thus, we deprecate the selectFields() methods in favor of getQueryInfo()
methods that return tables and join conditions in addition to the
fields.

Change-Id: Idcfd15568489d9f03a7ba4460e96610d33bc4089
2017-10-30 22:57:33 +00:00
Aaron Schulz
3247bae0e7 Add action/user tracking to html cache purge jobs
Change-Id: Ic7155a7303debfaf26b13cb836497ccbc89ea238
2017-10-30 10:47:30 -07:00
Aaron Schulz
8f829de5f0 Add action/user tracking to link refresh jobs
Change-Id: Ie7261eacddb869988b005ba2f17968df88c7003e
2017-10-23 11:06:16 -07:00
Brad Jorsch
919c024f5e LocalFile: Fix copy-paste error
No idea how that got through.

Change-Id: Ic7eebe624434005ff962f19eaa85cdf40e131284
2017-10-23 12:20:50 -04:00
jenkins-bot
3b4c53b795 Merge "Block same-file reuploads" 2017-09-25 19:22:53 +00:00
jenkins-bot
72bd7a4dec Merge "Bump LocalFile::VERSION to invalidate file page cache" 2017-09-20 09:50:06 +00:00
Brad Jorsch
d3642413a1 SECURITY: Fix handling of CommentStore and insertSelect
CommentStore->insert() takes the raw comment, not quoted, and returns
fields appropriate for passing as $a to IDatabase->insert() or $values
to ->update(). Such fields need to be passed through
IDatabase->addQuotes() to be appropriate for passing in $varMap to
IDatabase->insertSelect().

Change-Id: Ie64b279ee7cf9c8c396af385e46c826e0597ab1e
2017-09-19 09:32:29 +10:00
Reedy
41690888a2 Bump LocalFile::VERSION to invalidate file page cache
Bug: T175444
Change-Id: Ic0665d5554ed43c48d4fcdef087fbd33b597788c
2017-09-18 15:31:48 +00:00
Reedy
ab4e6fdd51 Return description fields for unprefixed image cache rows
Bug: T175444
Change-Id: I5560187d3850253095b695dc7a3cfc954fba9318
2017-09-18 14:13:05 +00:00
Matthias Mullie
6362adf3f5 Block same-file reuploads
When uploading a file, there are a few ways of checking for and blocking
(or at least warning about) duplicate uploads already.

However, it occasionally seems to happen that files get uploaded twice.
The exact same file, usually - submitted at (almost) the exact same time
(possibly some error in whatever submits the file upload, but still)

Given 2 uploads at (almost) the exact same time, both of them are stored,
even if they are the exact same files.
The last upload also ends up with a `logging` entry with `log_page = 0`.

I don’t believe such upload should go through: if we do find that a file
is an exact duplicate of something that already exists, I don’t see any
reason it should go through.

Note that with this patch, it will become impossible to reupload a file
with the exact same hash (which was possible before.)
If we still want to allow same-file reuploads while also blocking these
kind of race-condition same-uploads, we could make the check more strict
(e.g. also check timestamps, or check if page already exists, or …)

Bug: T158480
Change-Id: I76cbd2c64c3b893997f1f85974d6f82cbfe121e1
2017-09-18 15:44:11 +02:00
Brad Jorsch
33ba36c88a Replace more problematic uses of "SELECT *"
With the introduction of CommentStore, selects from various table
require certain joins or column aliases for proper operation.

Change-Id: I2ecb6030bf253664c3227d69b5ed2277596a83f0
2017-09-13 13:09:51 +00:00
Brad Jorsch
035f4635ef Use CommentStore::getCommentLegacy with CommentStore::getFields
It doesn't matter when $wgCommentTableSchemaMigrationStage is
MIGRATION_OLD, but it'll fail when we start changing that to later
migration stages.

Follows up I3447a412.

Change-Id: I6c010cefedd99324080ec078b83159d12709c1b1
2017-09-11 10:33:29 -04:00
Kunal Mehta
8e87dd16b8 LocalFile: Fix setting $this->description after CommentStore changes
Bug: T175444
Bug: T175443
Change-Id: I3447a4129300c2c7dc0d585404e7747b6a5e2b77
2017-09-09 19:40:23 +00:00
jenkins-bot
a17d459d4b Merge "Handle comment truncation in CommentStore" 2017-09-05 18:39:21 +00:00
Kunal Mehta
0cb2a09b6d Always put type information before variable name for @var tags
Like other tags, @var should have the type information before the
variable name.

<https://docs.phpdoc.org/references/phpdoc/tags/var.html>

Change-Id: I9eca6957b1990fa8cc687103dc02ee38af5f9086
2017-09-04 11:06:51 -07:00
Brad Jorsch
6ec1a31502 Handle comment truncation in CommentStore
Since the caller doesn't (and shouldn't) know whether CommentStore is
using the old or the new schema, it should leave truncation of comments
to CommentStore.

Change-Id: I92954c922514271d774518d6a6c28a01f33c88c2
2017-09-01 15:03:45 -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
Thiemo Mättig
d14faa6bed Remove auto-generated "Constructor" documentation on constructors
Having such comments is worse than not having them. They add zero
information. But you must read the text to understand there is
nothing you don't already know from the class and the method name.

Change-Id: I994d11e05f202b880390723e148d79c72cca29f0
2017-07-10 10:15:51 +00:00
Gilles Dubuc
b8292cef01 Make file purging also purge old versions
Also fixes purging for repos with sha1 thumb URLs.

Bug: T169198
Change-Id: Ibb98ecce83d690cc46769644038b54e37aea0b0d
2017-06-30 10:49:25 +02:00
Umherirrender
be42e09aa8 build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0
The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment.
Will be fixed in next version, see T167168

Changed:
- Remove duplicate newline at end of file
- Add space between function and ( for closures
- and -> &&, or -> ||

Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
2017-06-26 17:14:31 +00:00
jenkins-bot
aae0c8d425 Merge "Perform input validation for file $page at some strategic locations" 2017-06-26 06:55:16 +00:00
Gilles Dubuc
c2ea52a545 Remove X-Content-Dimensions header
Reverts 84e4d75088, and parts of cdfe08439c and 4511f6fa9f.

Bug: T150741
Bug: T167034
Change-Id: I39cfcf2cb231b6dfef569968fba6f473da258916
2017-06-12 18:07:28 +00:00
Gilles Dubuc
2cab7c0f91 Process content headers when metadata is empty
The new width/height override means that files without
any metadata can get content headers.

Bug: T150741
Change-Id: I92199a4aa9e0408572ebf7d8e4c04cd0196f0d0a
2017-06-02 17:12:09 +02:00
Gilles Dubuc
84e4d75088 Use file width/height instead of metadata for getContentHeaders
This allows us to populate X-Content-Dimensions without touching the
existing metadata format. Which makes the migration of existing content a lot faster by
only having to run refreshFileHeaders.

Bug: T150741
Change-Id: I2c0f39b2b01f364c3fab997ccc2f874b7f101d8a
2017-05-23 19:18:58 +00:00
Gilles Dubuc
cdfe08439c Store original media dimensions as additional header
For storage repos that support headers (such as Swift), this will store the original
media dimensions as an extra custom header, X-Content-Dimensions.
The header is formatted to minimize its length when dealing with multipage
documents, by expressing the information as page ranges keyed by dimensions.

Example for a multipage documents with some pages of different sizes:
X-Content-Dimensions: 1903x899:1-9,11/1903x873:10

Example for a single page document:
X-Content-Dimensions: 800x600:1

Bug: T150741
Change-Id: Ic4c6a86557b3705cf75d074753e9ce2ee070a6df
2017-05-09 15:49:28 -07:00
Arlo Breault
e430aa19ab Perform input validation for file $page at some strategic locations
* Not a holistic solution, but these are the places that currently
   assume a natural number for $page.

Bug: T100453
Change-Id: Ic611e5379dc8d138034b62ff8d678dfc68ced023
2017-05-03 21:40:39 -04:00