Commit graph

1522 commits

Author SHA1 Message Date
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
Fomafix
0f1858321c Use PHP 7 '??' operator instead of if-then-else
Change-Id: I790b86e2e9e3e41386144637659516a4bfca1cfe
2018-06-12 23:14:18 +02:00
Fomafix
e1630b6a53 PHP: Use short ternary operator (?:) where possible
Change-Id: Idcc7e4fcdd4d8302ceda44bf6d294fa8c2219381
2018-06-11 11:26:35 +02:00
Max Semenik
1e680456b4 Get rid of call_user_func(_array)(), part 3
Also cleaned up nearby code in a couple places.

Change-Id: Ibf44ee7c0ceb739d7e79406e4ff39303c316e285
2018-06-10 02:21:24 +00:00
Max Semenik
8085c58a4b Replace call_user_func_array(), part 1
Uses new PHP 5.6 syntax like ...parameter unpacking and
calling anything looking like a callback to make the code more readable.
There are much more occurrences but this commit is intentionally limited
to an easily reviewable size.

Change-Id: Idcec077ef3fdf029b632cceafd0150851ad723e3
2018-06-04 23:39:04 -07: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
Umherirrender
e1a203603c Replace wfGetLB
@deprecated since 1.27

Change-Id: Ibdd49fdfc0d1511503e1ed2173a592c612996c53
2018-05-02 22:30:24 +02:00
jenkins-bot
733993fa54 Merge "Fix warning "ob_end_flush(): failed to delete and flush buffer" during uploads" 2018-04-27 02:37:31 +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
James D. Forrester
de6dab71e3 Remove $wgScriptExtension (deprecated and ignored since 1.25)
* Remove left-over mention of the .php5 entry points in docs.

* Remove dead logic in NoLocalSettings for php5 entry points.

* Remove dead match in WebRequest for php5 entry points (they'd
  redirect since 1.25, and not seen by PHP).

Change-Id: Ia0ee8588591860b8fe34030c8503f38e9bce31f3
2018-04-19 01:11:23 +01: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
Edward Chernenko
30d72ec3d0 Fix warning "ob_end_flush(): failed to delete and flush buffer" during uploads
Bug: T186565
Change-Id: Ia4b29611ccee4acac11717f5220ff9e0fdbd55a9
2018-04-02 00:39:59 +03: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
Fomafix
d59af4c341 Use PHP's implode() with the suggested order of arguments
https://secure.php.net/manual/en/function.implode.php defines the order
of arguments as

 string implode ( string $glue , array $pieces )
 string implode ( array $pieces )

Note:
  implode() can, for historical reasons, accept its parameters in
  either order. For consistency with explode(), however, it may be less
  confusing to use the documented order of arguments.

Change-Id: I03bf5712204e283f52d3ede54af9b9ec117d4280
2018-02-22 20:24:00 +01:00
jenkins-bot
89843b44ce Merge "Update suppressWarning()/restoreWarning() calls" 2018-02-11 22:06:29 +00:00
Reedy
fbc0347466 Update MediaWiki\quietCall() -> Wikimedia\quietCall()
Bug: T182273
Change-Id: Id7d8e176fcd93040e30e46cb64fc6a3d36bc8230
2018-02-10 10:49:33 +00:00
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +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
Gilles Dubuc
a9213ccb4c Add ability to proxy thumbnail requests to a service
Bug: T169144
Change-Id: I4af09a8b75e7158d6ff15f97e8f067b66ac33d5c
2018-02-01 10:07:32 +01: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
Gergő Tisza
7ef448e97a
Fix RepoGroup caching bug
'bypassCache' was renamed in I9f79e5942ced4ae13ba4de0b4c62908cc746e777
to 'latest' but the cache bypass code was not updated.

Also fix an unrelated phpdoc error.

Change-Id: I141b97300853c60092363a90af063c3fd4941d27
2018-01-02 18:26:46 -08: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