Commit graph

6559 commits

Author SHA1 Message Date
Brad Jorsch
02d6dc2e4f API: Use ApiBlockInfoTrait in ApiQueryUsers and AllUsers
For efficient bulk querying, this means that
ApiQueryBase::showHiddenUsersAddBlockInfo() needs to return everything
needed by DatabaseBlock::newFromRow().

Since we're rewriting it anyway, we may as well also move
ApiQueryBase::showHiddenUsersAddBlockInfo() out into a trait of its own.

Bug: T232021
Change-Id: I9c5b17a232ecbfbffefc7e40608cf5684ce8a644
2019-09-18 19:44:01 +00:00
daniel
bdc6b4e378 LocalFile: avoid hard failures on non-existing files.
Some methods on LocalFile will fatal if called on a non-existing file.
ApiQueryImageInfo did not take that into account.

This patch changes LocalFile to avoid fatal errors, and ApiQueryImageInfo
to not try and report information on non-existing files.

NOTE: the modified code has NO test coverage! This should be fixed
before this patch is applied, or the patch needs to be thoroughly tested
manually.

Bug: T221812
Change-Id: I9b74545a393d1b7a25c8262d4fe37a6492bbc11e
2019-09-18 09:18:44 +00:00
Petr Pchelko
0df763f71d Use UserIdentity instead of User in REST
Change-Id: Ia6a517c6a64664be2363492108f9497fc949f299
2019-09-18 14:45:01 +10:00
jenkins-bot
88d9cc22d3 Merge "objectcache: Escape dots from cache keys in StatsD metrics" 2019-09-18 02:54:32 +00:00
jenkins-bot
a1d6452fd2 Merge "Break PreferencesFormOOUI->PermissionManager dependency" 2019-09-17 20:32:10 +00:00
jenkins-bot
009a6e3fa9 Merge "Use TextFormatter in the REST API" 2019-09-17 18:57:09 +00:00
Petr Pchelko
57cffc9e57 Break PreferencesFormOOUI->PermissionManager dependency
Depends-On: Id0f0bdb39b9e0be4d7c38c229371be04bb5aec5c
Change-Id: I9209cf26a27ab66306f61937b620bfe05c2045b0
2019-09-17 08:34:53 -07:00
jenkins-bot
24ed66642f Merge "Make WatchedItemQueryService depend on PermissionManager" 2019-09-17 10:11:26 +00:00
DannyS712
3a2c7d1b5d Deprecate $wgSysopEmailBans
Bug: T232169
Change-Id: Iba2493eb2f49d32c5aa1b4da53c9c221847fb125
2019-09-17 08:23:04 +00:00
Tim Starling
8b1a6cc58a Use TextFormatter in the REST API
* Add ResponseFactory::createLocalizedHttpError(), which generates a
  JSON response body from a MessageValue
* ResponseFactory::__construct() accepts an array of TextFormatter
  objects. For ease of testing, the array may be empty. The integrated
  ResponseFactory has a TextFormatter for English, and one for
  $wgContLang if that is different.
* Use createLocalizedHttpError() to show helpful error messages for
  errors generated by Router.

Change-Id: I897a0aee42227916c568333ab384966f1b87f599
2019-09-17 16:03:14 +10:00
jenkins-bot
e27d974043 Merge "services: Do not use deprecated ReflectionType::__toString() in tests" 2019-09-17 00:40:49 +00:00
jenkins-bot
f97d13a10c Merge "Title::getTalkPage(): Restore behavior of interwiki-prefixed & fragment-only titles" 2019-09-16 23:16:16 +00:00
jenkins-bot
cfd56e52d9 Merge "Add namespace restrictions to meta=siteinfo&siprop=namespaces API result" 2019-09-16 22:47:52 +00:00
Máté Szabó
eafbacb43c services: Do not use deprecated ReflectionType::__toString() in tests
The \MediaWikiServicesTest::provideGetService() PHPUnit data provider
method uses the ReflectionType::__toString() method to obtain the
return type of service instantiator callables as a string.

In PHP 7.4, calling this method generates an E_DEPRECATED notice.
The solution is to use ReflectionType::getName() instead, available
since PHP 7.1.[1]

This patch updates the method to use ReflectionType::getName()
if it is available, and fall back to ReflectionType::__toString()
otherwise.

---
[1] https://github.com/php/php-src/blob/php-7.4.0RC1/UPGRADING#L395

Bug: T233012
Change-Id: I69b97f75795e6c4e005bf1a23fb798f7e52da2fd
2019-09-16 21:14:07 +02:00
Petr Pchelko
ffeeee69f7 Make WatchedItemQueryService depend on PermissionManager
Bug: T220191
Change-Id: I714d2b33b83dab230a8168765d5523cb14971371
2019-09-16 09:39:43 -07:00
jenkins-bot
3bbda79f1f Merge "Revision: Inject Logger instead of LoggerSpi" 2019-09-15 06:59:15 +00:00
jenkins-bot
e2f0ee49d0 Merge "Log DNS blacklist matches with info level, non-matches with debug level" 2019-09-14 20:16:10 +00:00
Timo Tijhof
9244cdb977 objectcache: Escape dots from cache keys in StatsD metrics
Bug: T232907
Change-Id: Ia61256e24fe35803e69a83a1ca235e18297c75cd
2019-09-14 18:16:55 +00:00
Martin Urbanec
c64d6c4379 Log DNS blacklist matches with info level, non-matches with debug level
Bug: T230822
Change-Id: I036b38ac322181fdba4e9e6c1ff539f79b5bb79c
2019-09-14 18:49:30 +02:00
Aaron Schulz
20c645945c Make doTestLockCalls() faster
This was mostly doing many runs just to test for random lock errors in
versions of Windows from a few years back. Just do three quick rounds.

Change-Id: I2ec2a8ce66a5c14bfc9338b60f8a57b2de8eaece
2019-09-13 22:41:13 -07:00
Timo Tijhof
fe3c418925 Storage: Use a more descriptive WAN cache keyclass in 'SqlBlobStore'
In order to make statistics from WANObjectCache more useful,
each kind of key should generally have a unique first make*Key
component. This usually corresponds 1:1 to a call to make*Key,
unless the same key format is duplicated in muliple places.

In this case, change ('BlobStore', 'address', …, …)
to ('SqlBlobStore-blob', …, …).

Bug: T197849
Change-Id: Iba3ae1bf947d6f56c72df2cf3f2160d458d38c66
2019-09-14 02:22:01 +00:00
jenkins-bot
e80ff96c37 Merge "filebackend: rename and simplify header sanitizing methods in SwiftFileBackend" 2019-09-14 00:12:05 +00:00
jenkins-bot
a2c5e9eadf Merge "Expose LinksUpdate recursive flag with a getter" 2019-09-13 20:04:40 +00:00
jenkins-bot
e81b3603dc Merge "Make DefaultPreferencesFactory depend on PermissionManager." 2019-09-12 21:03:30 +00:00
DannyS712
c711cb207f Add namespace restrictions to meta=siteinfo&siprop=namespaces API result
Bug: T73952
Change-Id: I6b4484fa9170ce39953a37eae2ffb859118fd1e5
2019-09-12 16:40:12 +00:00
jenkins-bot
1af7f36b4f Merge "Replace usages of deprecated User::isAllowed. Step 2." 2019-09-12 12:33:03 +00:00
jenkins-bot
f2574fd1a7 Merge "Make SpecialBlankPageTest independend from the language" 2019-09-12 12:00:06 +00:00
Thiemo Kreuz
0f4869cadc Make SpecialBlankPageTest independend from the language
I would like to argue this is best practice. This also currently blocks
https://gerrit.wikimedia.org/r/521480

Change-Id: I8477f8280038c383c35bebf559ba2b5841748821
2019-09-12 13:10:52 +02:00
Petr Pchelko
7b4eafda0d Replace usages of deprecated User::isAllowed. Step 2.
Bug: T220191
Depends-On: I509cd88355cfd0cc074f4135ec86399b4075f89f
Change-Id: I2341e6f1d108c92924620fba3c64ec090cb09918
2019-09-11 16:00:03 -07:00
Derk-Jan Hartman
9ce26a564d Fix XMP parser errors due to trailing nullchar
JPEG files can have trailing \0 chars at the end of the XMP value. Use
trim() to remove these from the string value.

Bug: T118799
Change-Id: Id4ab223ef432e5d2c0dd3b4e332320db02422700
2019-09-11 22:34:33 +00:00
Petr Pchelko
5ccb1a42c7 Make DefaultPreferencesFactory depend on PermissionManager.
Bug: T220191
Change-Id: I3f5c4340501d59b5ca63b096364b5cc8388cff80
2019-09-11 15:34:26 -07:00
jenkins-bot
f9242d74f8 Merge "Pass the user and request into BlockManager::getUserBlock" 2019-09-11 18:58:32 +00:00
David Causse
b2ac2a41dd Expose LinksUpdate recursive flag with a getter
knowing if recursion is enabled might help extensions implementing
LinksUpdate hooks to take some decisions.
E.g. CirrusSearch would like to know if a particular update needs to go to a
priorized queue or not (template transclusion).

Change-Id: I0a0de0d4621ed302b4fb550a1ddecd4ac8c5775a
2019-09-11 16:55:39 +02:00
jenkins-bot
1e2cce13ea Merge "Allow users who are partially blocked to delete revisions." 2019-09-11 08:24:11 +00:00
Thalia
5fffa5c07a Pass the user and request into BlockManager::getUserBlock
Blocks are checked from the User object. Specifically,
User::getBlockedStatus instantiates a BlockManager and calls
BlockManager::getUserBlock. However, checking the block often depends
on knowing more about the state than the User should know. As a result,
the global user and request objects were passed into the block manager
on construction.

Whether the global request object should be passed into a service
constructor is still up for debate, so this moves the check for the
global state back to User::getBlockedStatus for now. (Note that it
reintroduces the problem of the User knowing more about state than it
should.)

This change also makes clearer the cases in which
BlockManager::getUserBlock is called from the User.

Different blocks may be sought, depending on the user and their
permissions. The user may be:
(1) The global user (and can be affected by IP blocks). The global
    request object is needed for checking the IP address, the XFF
    header and the cookies.
(2) The global user (and exempt from IP blocks). The global request
    object is needed for checking the cookies.
(3) Another user (not the global user). No request object is available
    or needed; just look for a block against the user account.

Cases #1 and #2 check whether the global user is blocked in practice;
the block may due to their user account being blocked or to an IP
address block or cookie block (or multiple of these). Case #3 simply
checks whether a user's account is blocked, and does not determine
whether the person using that account is affected in practice by any
IP address or cookie blocks.

Bug: T231919
Change-Id: I3f51fd3579514b83b567dfe20926df2f0930dc85
2019-09-11 08:23:54 +01:00
David Barratt
6b43064e5c Allow users who are partially blocked to delete revisions.
Currently, users who are partially blocked are prevented from deleting
revisions. The system should check to see if the user can edit the page.

Bug: T228486
Change-Id: Id08dfab9b0ebe9721d3552564ee9f9d1e1a4805a
2019-09-11 08:14:48 +01:00
Daimona Eaytoy
f3262ed390 Add a dedicated Exception for SessionOverflow
Instead of setting a custom property and checking via isset + count.

Change-Id: I087eeb2eee414218bbd6023ad1703fde22292281
2019-09-10 08:27:29 +00:00
jenkins-bot
6b89d180d9 Merge "Move callers away from Title::GAID_FOR_UPDATE" 2019-09-10 03:32:37 +00:00
Timo Tijhof
a52e796473 Revision: Inject Logger instead of LoggerSpi
For consistency with other services and entry points.
The caller decides on the channel name. This also narrows the
surface area for the DI layer by only requiring LoggerInterface
which is significantly lighter and easier to mock than an entire
LoggerProvider/Spi.

Change-Id: Ia71f2e1c0a1a08c9edf0736eb627c5d4a2dde8d5
2019-09-10 03:24:18 +01:00
Reedy
dd71a77512 Make most special pages class names match filename
Change-Id: I3a9f932acb7d9cf44a984b5d97f9fbc6b8670f7d
2019-09-10 02:47:08 +01:00
jenkins-bot
7f1b20d832 Merge "Mark passing non ObjectFactory spec to ApiModuleManager as deprecated" 2019-09-09 20:25:30 +00:00
jenkins-bot
5a451fd01b Merge "Fix use of GenderCache in ApiPageSet::processTitlesArray" 2019-09-09 20:20:13 +00:00
Aaron Schulz
a5c7fd0db2 Move callers away from Title::GAID_FOR_UPDATE
These callers just need to load some data from DB_MASTER.
Subsequent code needing that latest title data should also use the
required flags, rather than relying on flakey global cache state.

Change-Id: I53248ea4b5bf1cd953f956c41b8244831ec5ef04
2019-09-09 13:19:08 -07:00
mainframe98
7b2fb55711 Mark passing non ObjectFactory spec to ApiModuleManager as deprecated
With Iee04afc27283547dd68d6db93f44ac2e0ebf1258, passing both the $class
and $factory parameter is deprecated in favor of just passing an
ObjectFactory spec as the third parameter.

Change-Id: I7b04d82c9daba52f5dc5e6c528739336279c7550
2019-09-09 21:59:03 +02:00
Umherirrender
91fd689add Fix use of GenderCache in ApiPageSet::processTitlesArray
Title::getPrefixedText was called before the GenderCache was set up,
which lazy loads the cache for each title,
resulting in one query per user title

Splitted the foreach to fill the cache at a better location

Added a test for ApiPageSet to test that the gender cache is filled

Bug: T200238
Change-Id: I7972dd1bf3731a92328caab20e70d7b9b82c1f7c
2019-09-09 19:54:07 +00:00
mainframe98
eb8823743c Use ObjectFactory to create API modules
This will allow constructing API modules that need services.

This overhauls some of the internals of the ApiModuleManager,
but the public interface remains unchanged.
The $class parameter of addModule, (now called $spec)
also allows passing an array with the spec of the module.
Note that this spec requires the attribute 'class' to be present,
even when 'factory' is specified. This is the same as before,
where $class was always required.

In a perfect DI world ObjectFactory would be injected into
ApiMain::__construct and ApiMain would pass that to its instance
of ApiModuleManager, but that is currently not possible, so for now
it is injected in ApiModuleManager by having ApiMain::__construct
call the service locator.

Bug: T222388
Change-Id: Iee04afc27283547dd68d6db93f44ac2e0ebf1258
2019-09-09 18:50:16 +00:00
Brad Jorsch
6aae213a6b Fix typo in ChangesListSpecialPageTest
Change-Id: I812853ccbb8e0747bf5dbe5650d5b3ebb4dd38b5
2019-09-09 11:38:36 -04:00
Brad Jorsch
c29909e59f Mostly drop old pre-actor user schemas
This removes most of the pre-actor user and user_text columns, and the
$wgActorTableSchemaMigrationStage setting that used to determine
whether the columns were used.

rev_user and rev_user_text remain in the code, as on Wikimedia wikis the
revision table is too large to alter at this time. A future change will
combine that with the removal of rev_comment, rev_content_model, and
rev_content_format (and the addition of rev_comment_id and rev_actor).

ActorMigration's constructor continues to take a $stage parameter, and
continues to have the logic for handling it, for the benefit of
extensions that might need their own migration process. Code using
ActorMigration for accessing the core fields should be updated to use
the new actor fields directly. That will be done for in a followup.

Bug: T188327
Change-Id: Id35544b879af1cd708f3efd303fce8d9a1b9eb02
2019-09-09 11:38:36 -04:00
Aaron Schulz
8d1e7c00c6 filebackend: rename and simplify header sanitizing methods in SwiftFileBackend
In addition:
* Remove restriction that Content-Type was ignored in 'copy' and 'move'.
* Fix failing tests due to copy/move not respecting 'ignoreMissingSource'
  when using doQuickOperations().

Change-Id: Id1befeefeaaf75f0a6bf0e68b1e62271d432f953
2019-09-08 12:42:25 -07:00
mainframe98
b7b490e46d Support the creation of special pages with services injected
Now that the ObjectFactory library supports object creation with
services (T222409), the special page factory can use the object
factory to create special pages based off a spec, allowing the
creation of special pages that need services injected.

The object factory now also handles constructing from class name
and from callable.

This also deprecates providing the special page list with an
instance of SpecialPage, which hasn't been necessary since
r15031.

Bug: T222388
Change-Id: Iabb78ce5c98cfb3b586644be35d984871cb750cb
2019-09-08 12:57:54 +02:00