Commit graph

6409 commits

Author SHA1 Message Date
jenkins-bot
57609f4ded Merge "Consolidate duplicated unseen change logic and fix inconsistent code" 2019-05-06 19:59:46 +00:00
Aryeh Gregor
24949e738d MovePage methods need to run safety checks
A move method that doesn't check for things like moving a page on top of
itself or moving to a namespace with a different content model does not
seem like it's what callers would expect, and not what Title::moveTo
ever did. If there's a caller that really wants this behavior, we can
make moveUnsafe public.

I also made the $reason and $createRedirect parameters to move()
optional to match Title::moveTo() behavior. However, I made $reason
default to null instead of '', to distinguish between an empty edit
reason provided by the user and no edit reason provided at all (e.g., a
move done internally without specific user request).

Depends-On: I971e619eb76c4474fe037fad258f9c496717bf41
Change-Id: I6ddcc9f34a48f997ae39b79cd2df40dd2cc10197
2019-05-06 10:04:26 +03:00
Aaron Schulz
03d37f283b Consolidate duplicated unseen change logic and fix inconsistent code
Bug: T218511
Change-Id: I42387498dff0b1fc31f006ce3ba71241de9d45d7
2019-05-03 13:23:24 -07:00
Aryeh Gregor
18ec468633 Don't pass Config to service constructors
We don't want to depend on the entire site configuration when we only
need a few specific settings.

This change additionally means that these services no longer see a live
version of the settings, but rather a copy. This means in tests you
really do have to call overrideMwServices() if you want services to pick
up your config changes.

ResourceLoader and SearchEngineConfig will need more work to port,
because they expose their member Config in a getter, and the getter is
actually used.

Parser and NamespaceInfo are also relatively complicated, so I split
them into separate patches.

Tested with 100% code coverage. \o/

Depends-On: If6534b18f6657ec1aba7327463f2661037f995b3
Change-Id: I1a3f358e8659b49de4502dc8216ecb6f35f4e02a
2019-05-02 11:33:56 +03:00
Matěj Suchánek
8aa55aeabf Hide uploads link on IP contributions page
If IPs cannot upload files, hide link to list of files
which they uploaded.

Also simplify the code: User::getID() should always return int,
so $id !== null was always true. And add references to some tasks.

Bug: T220674
Change-Id: Ia9e1516393d6e85858cceb02bb09405148adaf51
2019-05-01 17:25:04 +02:00
jenkins-bot
b8c5ec5999 Merge "ContribsPager: Fix slow queries" 2019-05-01 04:38:54 +00:00
Brad Jorsch
c1db9d7443 ContribsPager: Fix slow queries
When ContribsPager is using an auxiliary table like ip_changes or
revision_actor_temp for the main action of the query, we already had
code in place to let it use the auxiliary table's denormalized timestamp
field for the ordering. What we didn't have was code to let it also use
the auxiliary table's denormalized timestamp field for *continuation*.

With the schema defined in tables.sql, the simplest thing to do would be
to be to add a redundant JOIN condition between rev_timestamp and the
denormalized timestamp field which would be enough to allow
MySQL/MariaDB to propagate the continuation conditional on rev_timestamp
to the denormalized timestamp field.

Unfortunately many Wikimedia wikis have rev_timestamp defined
differently from table.sql (P8433), and that difference is enough to
break that propagation. So we need to take a more difficult route,
restructuring the code tell IndexPager to explicitly use the
denormalized fields for ordering and continuation.

On the plus side, since we're doing that anyway we can get rid of the
code mentioned in the first paragraph.

Bug: T221380
Change-Id: Iad6c0c2f1ac5e1c610de15fe6e85a637c287bcd8
2019-04-30 21:07:32 -04:00
jenkins-bot
b942fc27c9 Merge "Deprecate User::isBlocked()" 2019-04-29 11:44:50 +00:00
Derick Alangi
d0a98441de SpecialUserrights: Improve ::userCanChangeRights() method logic
Bug: T37674
Change-Id: I22aa9ff72aec175b0f86ebcf48cd7716f3328b01
2019-04-28 22:55:35 +01:00
jenkins-bot
4d6828ef78 Merge "Rename BlockRestriction -> BlockRestrictionStore and wire it up as a service" 2019-04-26 11:47:47 +00:00
jenkins-bot
e53ea4b247 Merge "specials: Avoid the use of global variables in Special:Version" 2019-04-25 20:21:53 +00:00
David Barratt
e86a060284
Deprecate User::isBlocked()
The method User::isBlocked() attempts to answer two questions:
(1) Does the user have a block?
(2) Is the user prevented from performing this action?
The method can answer #1, but it cannot answer #2. Since User::getBlock() can
also answer #1, this method is redundant. The method cannot answer #2 because
there is not enough context in order to answer that question.

If access is being checked against a Title object, all access checks can be
performed with PermissionManager:userCan() which will also check the user's
blocks.

If performing all access checks is not desirable, using
PermissionManager::isBlockedFrom() is also acceptable for only checking if the
user is blocked. This method does *not* determine if the action is allowed,
only that the user's block applies to that Title.

If access is being checked without an existing Title, User::getBlock() can be
used to get the user's block. Then Block::appliesToRight() can be used to
determine if the block applies explicitly to a right (or returns null if
it is unknown or false if explicitly allowed). If the user is creating a new
Title, but the text of the title is not yet known (as in the case of Wikibase),
access should be checked with Block::appliesToNamespace().

Bug: T209004
Change-Id: Ic0ad1b92e957797fee8dcd00bd1092fe69fa58f1
2019-04-25 11:47:44 -04:00
Derick Alangi
2ffeb5238e specials: Avoid the use of global variables in Special:Version
We're moving away from globals to Config this patch attempts to
clean off some globals whose values can be nicely gotten via the
use of Config.

Bug: T72638
Change-Id: I25516873c215b74cdd425d023e877e5cdc3d6149
2019-04-24 17:20:09 +01:00
sbassett
d965b0b465 [SECURITY] [API BREAKING CHANGE] Require logout token.
Special:Userlogout now requires a token

Api action=logout requires a csrf token and the request to be POSTed

Patch author: bawolff

Bug: T25227
Change-Id: Icb674095956bb3f6c847c9553c53e404402ea774
2019-04-24 15:38:40 +00:00
jenkins-bot
9abfbf85b9 Merge "UsersPager: Use CSS-based parentheses" 2019-04-24 08:45:06 +00:00
Roan Kattouw
4d7a8b8779 UsersPager: Use CSS-based parentheses
Tell Linker::userToolLinks() and Linker::userToolLinksRedContribs()
to omit parentheses, and load the CSS that fills them in.

Change-Id: Ie979537abed226e945cf1918b3ee240ae78ee24e
2019-04-23 10:32:22 -07:00
Reedy
9189db0c50 Stop calling FileRepo->streamFile()
Change-Id: Ifdf379dc7f2501e561dfbc06f9afa7a9089306f2
2019-04-20 02:06:50 +01:00
jenkins-bot
86c13ba3ad Merge "Merge last-seen stash data at more points in SpecialWatchlist" 2019-04-19 23:28:35 +00:00
jenkins-bot
ce44cc9d5b Merge "RCFilters: display timestamp of new changes in refresh link" 2019-04-19 23:24:56 +00:00
jenkins-bot
e77e1bcbf7 Merge "Add block type filter to Special:BlockList" 2019-04-18 16:20:31 +00:00
Aryeh Gregor
e6df285854 Remove all $wgParser use from core
Bug: T160811

Change-Id: I0556c04d33386d0339e02e2bf7a1ee74d97c2abd
2019-04-17 15:16:50 +03:00
Dayllan Maza
d872203495 Add block type filter to Special:BlockList
Now that Partial Blocks feature is being enabled on multiple wikis
a new filter (Block Type) is added to Special:BlockList to facilitate
viewing the different blocks in place.

Bug: T191549
Change-Id: I0bc8c6eaff22930c2e3c12ae5e77e03287910db9
2019-04-17 11:40:26 +00:00
Dayllan Maza
de67ee1972 Rename BlockRestriction -> BlockRestrictionStore and wire it up as a service
BlockRestriction was initially created as a static class and there is no reason
why this shouldn't be available in the service container.

Also renaming as BlockRestrictionStore to keep up with the new emerging naming patterns.

Bug: T219684
Change-Id: If0b954f286d4759de2e3e41a0eb788e74bd72996
2019-04-16 21:55:15 -04:00
Stephane Bisson
c27ffdfecf RCFilters: display timestamp of new changes in refresh link
The timestamp displayed in the link is not from the last refresh
but from when new changes are available.
I don't think this distinction is consequential. The fundamental
meaning is that clicking the link will bring changes newer than
the timestamp.

I considered using a relative timestamp (2h ago) like is
proposed in the task but I didn't think it was worth it
for the following reasons:
1. Client-side formatting with momentjs is hacky
   at best and I couldn't find a way to have it
   respect user's preferences.
2. I don't think it makes the meaning of the timestamp
   in the message any clearer. I'll admit the meaning
   of the current timestamp is not explicit but I think
   it works when you don't think too much about it.
3. A relative timestamp requires a setInterval with
   decreasing interval to keep it up to date.
   ("A few seconds ago" -> "2 minutes ago", "1h ago", etc)

Bug: T200353
Change-Id: I9058d47645914783227d1520adb78e75399b5504
2019-04-16 17:51:25 -07:00
jenkins-bot
168f15ba9e Merge "Rename un-prefixed rcfilters selectors" 2019-04-15 21:38:35 +00:00
jenkins-bot
5b8357a195 Merge "Fix calls to Title::getUserPermissionsErrors on SpecialImport" 2019-04-15 19:13:58 +00:00
Brad Jorsch
c4a9fb65bd ContibsPager: Fix slow query with actor migration read-new mode
The change in I1678f7ec broke the workaround in I992aa50f by adding
the rev_id column to the ORDER BY clause. We need to extend the aliasing
to rev_id => revactor_rev to re-fix it.

Bug: T220991
Change-Id: I62dc3803621da982e526d7402ab8e7b08f8336bc
2019-04-15 13:02:19 -04:00
Ed Sanders
3266b126f1 Rename un-prefixed rcfilters selectors
Only -head and -container have on-wiki usage, so
keep deprecated aliases for those.

Bug: T220852
Change-Id: I67b120d67fbbdf108da98ddfc7eae24e668bfe11
2019-04-15 08:33:34 -07:00
Amir Sarabadani
5593f9dac4 Fix calls to Title::getUserPermissionsErrors on SpecialImport
Right now, it uses a deprecated way to set rigor causing it to read from
master on GET, giving out errors

Change-Id: I89bbe20080998bde2156680c631700b52f4e4712
2019-04-15 16:42:21 +02:00
Reedy
c28707d371 Fix casing of Special Pages to match class name
Change-Id: Ifc9e827202493e8f055a21875c54ff827a38d1f7
2019-04-14 13:55:04 +01:00
Reedy
d8f480bad3 Remove PreferencesFormLegacy.php
Now unused, deprecated in 1.32

Change-Id: I4fc4bdf36b3832786c0266786cff57d512140d8e
2019-04-14 02:08:32 +00:00
Reedy
571a44a4be Replace PreferencesFormLegacy usages with PreferencesFormOOUI
Change-Id: I4fc2a609ebb0f93b0767dddc343c3ff93ca8a39c
2019-04-14 00:51:05 +00:00
Aryeh Gregor
7b4489e019 Get rid of unnecessary func_get_args() and friends
HHVM does not support variadic arguments with type hints.  This is
mostly not a big problem, because we can just drop the type hint, but
for some reason PHPUnit adds a type hint of "array" when it creates
mocks, so a class with a variadic method can't be mocked (at least in
some cases).  As such, I left alone all the classes that seem like
someone might like to mock them, like Title and User.  If anyone wants
to mock them in the future, they'll have to switch back to
func_get_args().  Some of the changes are definitely safe, like
functions and test classes.

In most cases, func_get_args() (and/or func_get_arg(), func_num_args() )
were only present because the code was written before we required PHP
5.6, and writing them as variadic functions is strictly superior. In
some cases I left them alone, aside from HHVM compatibility:

* Forwarding all arguments to another function. It's useful to keep
  func_get_args() here where we want to keep the list of expected
  arguments and their meanings in the function signature line for
  documentation purposes, but don't want to copy-paste a long line of
  argument names.
* Handling deprecated calling conventions.
* One or two miscellaneous cases where we're basically using the
  arguments individually but want to use them as an array as well for
  some reason.

Change-Id: I066ec95a7beb7c0665146195a08e7cce1222c788
2019-04-12 20:17:01 +00:00
Fomafix
9cbb8f104d Use https://www.php.net/ instead of https://secure.php.net/
Change-Id: I0acca592c6909e91b28b904da49dcbd6a43cd2a5
2019-04-12 06:44:48 +02:00
jenkins-bot
7ecbff2360 Merge "Simplify checking for widgets on special block page" 2019-04-11 09:29:16 +00:00
Aaron Schulz
1ef64b2f26 Merge last-seen stash data at more points in SpecialWatchlist
Follow-up to 7c12727fff

Bug: T218511
Change-Id: I7357853f33717d6d34ca69381b0e59f67625d972
2019-04-10 14:58:52 -07:00
Amir Sarabadani
6655ab0828 Add legoktm, James Forrester, bawolff, and addshore to main contributors
Each one of these people has more than 500 commits (Kunal with more than 1000)

Change-Id: I8174f7e8af378dad7c2773b90e2b657ff948162d
2019-04-10 00:41:16 +02:00
Gilles Dubuc
6ed0de046e Remove unnecessary slash in scalerThumbUrl
The thumb proxy URL already contains a trailing slash

Bug: T220265
Change-Id: I9176ac893250f857c04df5a6878278784cf785f6
2019-04-09 18:57:38 +02:00
Gilles Dubuc
1a1f01571e Add support for X-Swift-Secret to upload stash
This will allow us to treat the request to the temp
container as securely as those on a private wiki.

Bug: T220265
Change-Id: I43a7212481665e05ae23c44ab1788d8988b80a4b
2019-04-09 17:21:51 +02:00
Brian Wolff
1aba1d864c Make Special:Version escape extension names that aren't links
This is to make phan-taint-check happy. Technically this is
a breaking change, but I am unaware of any extensions actually
having their names be arbitrary html, and support for this
is not documented anywhere.

Bug: T216348
Change-Id: I065d7e57f36e079e0b02180379e2df1f8535f3a8
2019-04-07 17:06:19 +00:00
Kunal Mehta
02b18ba4cd Fix/suppress phan errors related to arrays (#11)
Change-Id: Ie5c05fbc88c51d493bc1462005d2f8dde5f72101
2019-04-07 16:27:02 +00:00
jenkins-bot
8b9143e121 Merge "Fix/suppress misc phan errors (#5)" 2019-04-05 23:44:43 +00:00
Kunal Mehta
7bd9073c4b Fix/suppress misc phan errors (#2)
* Title: phan false positive
* McrUndoAction: fixed improper use of @param
* UploadSourceAdapter: fixed wrong type
* XmlTypeCheck: Use null so phan doesn't think we're trying to call the
function ''
* Database: phan false positive
* SpecialBlock: Use phan's advanced type documentation so phan knows
specifically what's being returned
* ChangesListSpecialPage: phan false positive
* BatchRowUpdate: Have default callback take a parameter so phan doesn't
think too many arguments are being passed
* MimeAnalyzer: left FIXME for relying on PHP 7.1 unpack() signature
* LanguageConverter: Specify types for $mTables since phan couldn't
determine it automatically
* preprocessorFuzzTest: Implement User::load() method signature

Change-Id: I08080ab636c5fe67ea6a4e14b2212d7523606e21
2019-04-05 16:12:18 -07:00
Kunal Mehta
4ef179e335 Fix/suppress misc phan errors (#5)
Add lots of missing return statements, or remove incorrect doc blocks.

Change-Id: I0881e98fbb9d0d4cf79ecc824064d24538055d3f
2019-04-05 15:53:37 -07:00
Thalia
dc941617b2 Simplify checking for widgets on special block page
Certain groups of widgets always exist if the form is loaded, or always exist
if partial blocks is enabled. Others depend on certain user rights or config
variables. Check these widgets in groups rather than checking for the
existence of each one individually.

Change-Id: I6950ebc22f4564aadaf6d6acd5ca36534d8b9962
2019-04-05 15:37:54 +01:00
jenkins-bot
75f937543b Merge "Collapse some nested if statements" 2019-04-04 19:29:31 +00:00
Reedy
c13fee87d4 Collapse some nested if statements
Change-Id: I9a97325d738d09370d29d35d5254bc0dadc57ff4
2019-04-04 19:02:22 +00:00
jenkins-bot
3222ddcea8 Merge "Fix wpCreateAccount bug when set on Special:Block url params" 2019-04-04 12:58:04 +00:00
Dayllan Maza
dd9fa238cf Fix wpCreateAccount bug when set on Special:Block url params
wpCreateAccount default is dynamically changed if the user
has not posted the form or interacted with the field in any way

Bug: T218554
Change-Id: Ied68dc60d57ed35ed3285c5cf89b772c8c4e41d1
2019-04-03 14:40:01 -04:00
jenkins-bot
1715b41651 Merge "Sunsetting viewPrevNext" 2019-04-02 17:35:09 +00:00