Commit graph

511 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
Umherirrender
40d3ce8d17 Reduce calls to MediaWikiServices::getInstance()
In some functions MediaWikiServices::getInstance() was called twices or
in loops. Extract the variable to reduce calls.

Change-Id: I2705db11d7a9ea73efb9b5a5c40747ab0b3ea36f
2018-08-18 06:02:39 +02: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
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
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
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00: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
8804df2da5 filerepo: clean up remote description cache keys
Hash the file name portion and make the string constant portions
more relevant to what the keys are actually used for (e.g. there
is no URL parameter in the key)

Bug: T198279
Change-Id: Idf6f97db26f5be291cdd3a50a91346677fe9c3e6
2018-06-27 08:25:47 +01: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
jenkins-bot
33912421c8 Merge "Replace deprecated ObjectCache and CommentStore calls in filerepo" 2018-05-07 18:21:42 +00:00
WMDE-Fisch
2330c9afad Replace deprecated ObjectCache and CommentStore calls in filerepo
Change-Id: I0e863dc8e4bc6dac938a2ed437c2691aace19690
2018-05-07 11:00:23 +02:00
Max Semenik
94e7349de4 Fix class/function case mismatches
Change-Id: I25632d4db5a451975cb7a678372d8675c28c0897
2018-05-05 22:16:04 +00: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
Brion Vibber
a28853d4e8 Fix for warning in ForeignAPIFile when no thumbnails
Remote audio files have no thumbnails, so this check in
ForeignAPIFile for thumbnails by iterating over the result
from FileBackend::getFileList() could throw a warning about
invalid input to foreach, as it may return null.

Change-Id: I07f37ed5a299e1a3c9a1e6bddcbc5582f99e5274
2018-02-07 10:39:03 -08: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
716814a5d5 Merge "Treat langtags in SVG switch case-insensitively" 2017-11-15 10:17:32 +00:00
Cormac Parle
f6620e2a75 Treat langtags in SVG switch case-insensitively
See https://tools.ietf.org/html/bcp47#section-2.1.1

Also implement matching of systemLanguage attribs as
specified in the SVG spec

Note that librsvg that we use for rendering pngs of svg
files has a bug, and matches languages in the following
way instead of what is implemented in SVG::getMatchedLanguage()

public function getMatchedLanguage( $userPreferredLanguage, array $svgLanguages ) {
  foreach ( $svgLanguages as $svgLang ) {
    if ($svgLang == $userPreferredLanguage) {
      return $svgLang;
    }
    $dashPosition = strpos( $userPreferredLanguage, '-' );
    if ( $dashPosition !== false ) {
      if (
        strtolower( substr( $svgLang, 0, $dashPosition ) ) ==
        strtolower( substr( $userPreferredLanguage, 0, $dashPosition ) )
      ) {
        return $svgLang;
      }
    }
    return null;
}

Bug: T154132
Change-Id: Ibff66a0844f0cecfae0260c6a7d20aeedc2849a2
2017-11-10 09:14:42 +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
Umherirrender
f739a8f368 Improve some parameter docs
Add missing @return and @param to function docs and fixed some @param

Change-Id: I810727961057cfdcc274428b239af5975c57468d
2017-09-10 20:32:31 +02: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
Matěj Suchánek
c2720d5686 Drop compatibility with PHP 5.3
Since 5.4, $this works inside closures.

Change-Id: I6987f76a1e33d6d7ab020a57186e5477186bbf2e
2017-09-02 20:39:13 +02:00