Commit graph

165 commits

Author SHA1 Message Date
jenkins-bot
022d6ab817 Merge "Avoid DB_MASTER queries in User::newSystemUser() when possible" 2017-06-03 05:16:08 +00:00
Kunal Mehta
2f1f04dd4f User: Avoid deprecated wfMemcKey()
And ObjectCache::getMainWANInstance() while we're at it.

Change-Id: Id0280aec72202f3b3098c9c3b563541c2c0f2900
2017-05-25 12:17:27 -07:00
Kunal Mehta
2f059883fb User: Avoid deprecated wfMemcKey()
Change-Id: Iffb4d85dfed740b01fcef5a25762dc751b292c41
2017-05-25 11:20:24 -07:00
Aaron Schulz
0f4b3764ce Use test user helper methods in UserGroupMembershipTest/UserTest
This avoids postgres failures when trying to insert users with name
"false" (cast to 0, which fails since integer != text type).

Bug: T75174
Change-Id: I809edd94117811d22492eaba440fad6aaea1195b
2017-05-19 19:07:21 +00:00
Aaron Schulz
e9c7e1d34e Avoid DB_MASTER queries in User::newSystemUser() when possible
Bug: T92357
Change-Id: I1c90fef9b4f3acc658f4911a8db6f985e7cc7c83
2017-05-14 16:56:04 -07:00
Paladox
54c56da85a Fix php code style
Preparation change for updating mediawiki code sniffer to 0.8.0

Change-Id: Ib0b3fe4afea9096ffa3a1347b4f7e07d3398b0b2
2017-05-05 12:03:54 +00:00
jenkins-bot
bfb9b1ce86 Merge "Adding explantation for why to use User::incEditCount()" 2017-05-01 23:49:26 +00:00
Florian Schmidt
c9649314f7 Use IPSet for checking of wgProxyList
Instead of using array_* functions, use the IPSet for checking, if a
specific IP address matches a set of addresses.

This also deprecates a backward-compatibility functionality, that
the wgProxyList array could also be an associative array, where the blocked
IP address is set as a key of the array insted of a value. All IP address
keys will be mved to values on-the-fly, however a deprecation warning will
be emitted. A notice in the Release notes was added, too.

Bug: T161580
Change-Id: I69d9534942c415ab044177969ecd54160079b593
2017-05-01 22:15:03 +00:00
Kaldari
d4863dea27 Adding explantation for why to use User::incEditCount()
... rather than User::incEditCountImmediate() for most cases.

Change-Id: Ia16baabaeaca5c726e1dd1fc2506dc0b85500b6e
2017-04-28 13:45:25 -07:00
This, that and the other
9ee4e74e31 Expire the cache of a User object when a group membership is set to expire
To avoid user permissions persisting for up to 1 hour beyond their expiry
time.

Bug: T163691
Change-Id: I85b578e6b7816639c3d0101d66efb1efedb17af6
2017-04-25 13:55:26 +10:00
Aaron Schulz
dd359741cc Move DB errors to Rdbms namespace
Change-Id: I463bd86123501abc68fdb78b4cda6110f7af2549
2017-04-15 10:47:41 -07:00
jenkins-bot
0697e41485 Merge "Move Database and subclasses to Rdbms namespace" 2017-04-12 18:07:43 +00:00
Aaron Schulz
d735dc562d Move Database and subclasses to Rdbms namespace
Change-Id: I52bef87512f9ddd155d1f4cc0052f6b7a0db5b42
2017-04-12 10:43:57 -07:00
zppix1
0a6f7f5796 Remove "editusercssjs" user right
Deprecated since MediaWiki1.16

Change-Id: Ic9851d53affe0f4ece7a79f541ec5cb39133b109
2017-04-11 14:54:43 +01:00
Brad Jorsch
40f89f230e Decode '0'-valued user options to integer 0
I13d0e402f fixed a MySQL strict-mode bug by having boolean false be
sent to the database as 0 rather than "", since so many of our
logically-boolean fields are typed as tinyints. That happened to also
cause logically-false user preferences to be stored in the
user_properties table as "0" rather than "", which works fine in PHP but
confuses JavaScript since it considers string-0 as truthy rather than
falsey.

To avoid this situation, convert "0" to 0 when loading the user
options. Completely solving T54542 is left for another time, since
identifying which type to normalize each option to seems nontrivial.

Change-Id: Ia3280b7ce923641eac077141b47cba10d3fb88db
2017-03-23 11:26:42 -04:00
jenkins-bot
7360156ec7 Merge "User::getRights phpdoc from return array to string[]" 2017-03-21 02:16:29 +00:00
addshore
1f5dd321ac User::getRights phpdoc from return array to string[]
Change-Id: I188ed3d427f53ff773235d35ef277de0a3221777
2017-03-20 17:38:39 +00:00
Sam Wilson
6e7c7f9d76 Remove the localStorage replication of the block cookie
The block cookie was being replicated to localStorage in an attempt
to make it harder for users to get around the block by deleting the
cookie (and changing IP addresses).

This whole setup was hard to test, had a few bugs (e.g. the localStorage
value would never expire), and given that it is a minor improvement
over just a plain cookie, it is now being removed. The cookie is only
intended to stop casual block-evaders (other users will get around it
by deleting the cookie or using incognito mode) and so it is not felt
worth having the extra complexity that will only guard against people
who know to remove cookies, not use incognito mode, and yet don't know
to remove localStorage.

Bug: T152952
Change-Id: Ifb06dc2390f4d648d7fcb39e30267de5eddc6941
2017-03-17 11:58:48 -07:00
jenkins-bot
aa3319c4c0 Merge "Miscellaneous indentation tweaks" 2017-02-28 18:38:36 +00:00
jenkins-bot
17eda64357 Merge "includes: Replace implicit Bugzilla bug numbers with Phab ones" 2017-02-28 00:51:57 +00:00
Bartosz Dziewoński
ecdef925bb Miscellaneous indentation tweaks
I was bored. What? Don't look at me that way.

I mostly targetted mixed tabs and spaces, but others were not spared.
Note that some of the whitespace changes are inside HTML output,
extended regexps or SQL snippets.

Change-Id: Ie206cc946459f6befcfc2d520e35ad3ea3c0f1e0
2017-02-27 19:23:54 +01:00
Stephane Bisson
09e441003b RCFilters UI: Highlight behavior
Let there be highlight! and there were highlights
And RCFilters separated the highlight from the darkness
And it defined highlights as five colors
The lights are called yellow and green, and the darks red and blue
And there were colors and there were circles; one highlight.

This is the commit that adds highlight support for filters both in the backend
and the UI. The backend tags results based on which filter they fit and the
front end paints those results according to the color chosen by the user.
Highlights can be toggled off and on.

Also added circle indicators to the capsule items and each line of results
to indicate whether the line has more than one color affecting it.

Bug: T149467
Bug: T156164
Change-Id: I341c3f7c224271a18d455b9e5f5457ec43de802d
2017-02-23 10:58:56 -08:00
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
2017-02-21 18:13:24 +00:00
Gergő Tisza
c2f357f1bf User::isPingLimitable(): handle CIDR notation in $wgRateLimitsExcludedIPs
Bug: T156983
Change-Id: I727c19214cb3f9fad558d433bb38fbcf25d8497a
2017-02-17 07:25:11 +00:00
Sam Wilson
5fd5b3276f Validate BlockID cookie before use
This change adds a HMAC to the block-cookie to prevent someone
spoofing a cookie and so discovering revdeleted users' names.
The HMAC is only added if $wgSecretKey is set; if it isn't, the
existing plain-ID format is used. A note about this has been
added to DefaultSettings.php.

Tests are updated and new tests added to demonstrate an
inauthentic HMAC, and for when $wgSecretKey is not definied.

Bug: T152951
Change-Id: I6a3ef9e91091408c25eaa2d36d58b365d681e8c6
2017-02-10 11:35:57 +08:00
addshore
8236e856e7 Remove User::crypt() & User::comparePasswords()
These have both been deprecated since 1.24
Hard deprecation happened back in 2014

Both methods are still used by the SecurePasswords
extension, but this extension is documented on mw.org
as not working with MW1.24+.

I can find no other uses.
Lets finally get rid of these!

Change-Id: I94a7b65d2216bbc505e190af3182de2317976ed1
2017-01-28 18:15:16 +01:00
This, that and the other
73224f4f8b User group memberships that expire
This patch adds an ug_expiry column to the user_groups table, a timestamp
giving a date when the user group expires. A new UserGroupMembership class,
based on the Block class, manages entries in this table.

When the expiry date passes, the row in user_groups is ignored, and will
eventually be purged from the DB when UserGroupMembership::insert is next
called. Old, expired user group memberships are not kept; instead, the log
entries are available to find the history of these memberships, similar
to the way it has always worked for blocks and protections.

Anyone getting user group info through the User object will get correct
information. However, code that reads the user_groups table directly will
now need to skip over rows with ug_expiry < wfTimestampNow(). See
UsersPager for an example of how to do this.

NULL is used to represent infinite (no) expiry, rather than a string
'infinity' or similar (except in the API). This allows existing user group
assignments and log entries, which are all infinite in duration, to be
treated the same as new, infinite-length memberships, without special
casing everything.

The whole thing is behind the temporary feature flag
$wgDisableUserGroupExpiry, in accordance with the WMF schema change policy.

The opportunity has been taken to refactor some static user-group-related
functions out of User into UserGroupMembership, and also to add a primary
key (ug_user, ug_group) to the user_groups table.

There are a few breaking changes:
- UserRightsProxy-like objects are now required to have a
  getGroupMemberships() function.
- $user->mGroups (on a User object) is no longer present.
- Some protected functions in UsersPager are altered or removed.
- The UsersPagerDoBatchLookups hook (unused in any Wikimedia Git-hosted
  extension) has a change of parameter.

Bug: T12493
Depends-On: Ia9616e1e35184fed9058d2d39afbe1038f56d7fa
Depends-On: I86eb1d5619347ce54a5f33a591417742ebe5d6f8
Change-Id: I93c955dc7a970f78e32aa503c01c67da30971d1a
2017-01-27 09:24:20 +00:00
Aaron Schulz
2e5eb693de objectcache: add WANObjectCacheReaper for assuring purges
* This fixes keys based on some sort of change log.
  Updates are wrapped in a mutex and keep track of the
  last known good position.
* Make WANObjectReapUpdate class that cleans up title
  related keys using the recentchanges table. This triggers
  as a deferred updates on RC view.

Change-Id: I7f14b9ca2533032147e62b1a3cc004a23da86579
2017-01-27 02:21:06 +00:00
Brad Jorsch
337c0fb3e1 Add $wgSoftBlockRanges
This variable allows for blocking anonymous contributions from certain
IP addresses. Account creation from these addresses will be allowed.

The idea here is that, for example, Wikimedia could add 10.0.0.0/8 to
prevent logged-out bots on labs from making confusing edits. See
I74f5f4a3.

The default for the new variable is empty to avoid causing issues on
upgrade for wikis on private networks.

Change-Id: I6c11a6b9e1a740de074e7ccd753418f94c4b6288
2017-01-06 15:59:19 -05:00
Subin Siby
2792221354 Remove &$this usage
Replaced &$this to avoid PHP 7.1 warning of passing $this by reference

Bug: T153505
Change-Id: I3e9bc59dc8cefac0108482afeb9cc9a274e2e54b
2016-12-23 15:54:03 +05:30
Timo Tijhof
57290f6926 user: Minor clean up of User::isLocallyBlockedProxy()
Change-Id: If8bcb2f26f14ce04ee23fb9500be95c8cdf1a967
2016-12-16 22:11:49 -08:00
Max Semenik
866884763f Remove deprecated function User::isPasswordReminderThrottled()
Deprecated and stubbed in 1.27, only throws exceptions these days.
The only user in core or extensions is AjaxLogin which is completely
broken anyway (T153385).

Change-Id: I298fbc3e65d98b3af2f3cfef3d9884e277e6717c
2016-12-16 12:55:30 -08:00
Max Semenik
12d13acde4 Remove 2 deprecated functions from class User
They've been deprecated in 1.27 and only throw exceptions
no callers in core or extensions.

Change-Id: I1ccfa39c287b640b435a075449e4674daf8d24e7
2016-12-16 12:54:04 -08:00
Brad Jorsch
01a3b2b0bf Add the concept of "system blocks"
Blocks made for configured proxies, dnsbls, or the configured range
soft-blocks being added in I6c11a6b9 aren't real blocks stored in the
database. Let's actually flag these blocks as such and use a more
appropriate message when displaying them to the user.

Change-Id: I697e3eec2520792e98c193200c2b1c28c35bf382
2016-12-16 12:30:03 -05:00
Thiemo Mättig
00c3f09566 Remove empty lines from PHP and JavaScript comment blocks
This is a pure documentation change. It mostly removes empty lines from
comments (and entirely empty comments), as well as adds a few missing
documentation blocks and fixes a minor mistake. I hope it's ok to have
this in one patch. I can split it, please tell me.

Change-Id: I9668338602ac77b903ab6b02ff56bd52743c37c4
2016-12-09 09:01:06 +00:00
Brad Jorsch
901d575b54 Set token properly when creating in User::newSystemUser()
Otherwise callers that don't use 'steal' is going to break because it'll
think it needs to steal the user.

If such a user exists on a wiki, it can be fixed by setting the token to
the invalid token. The easiest way is probably to just call
User::newSystemUser( $name, [ 'steal' => true ] ) with eval.php.

Note there's no way for anyone to use these users unless they steal the
token from the DB, since they still don't have a password, email, or any
other method of authentication or account recovery set up.

Change-Id: I9efd2d2f5fffb4e4411a894f9514cdf2c66663a9
2016-12-02 17:12:33 +00:00
Reedy
2f1d7d2759 User::edits() was removed
Change-Id: I3ebe2cceb94a0d61a9e0ab5bb0599e8a03146046
2016-12-02 00:31:13 -08:00
Brad Jorsch
5840c440ce Remove $purpose parameter from password validity check
This was added in I56b6600 in an attempt to work around a bug in
CentralAuth, but the bug has since been fixed in a better way. No hook
functions in Gerrit use the parameter (or ever have, as far as I can
tell), and anything that was passing a value other than the default
'login' has since been removed. So let's just get rid of it instead of
keeping it around doing nothing.

Change-Id: Ie604e03d268706221161ac93eb866f477e466fb4
2016-12-01 18:41:01 -05:00
jenkins-bot
bfcbf215f7 Merge "Use isDisabled() instead of isBlank() in getGrantName in User.php" 2016-11-29 23:03:55 +00:00
Justin Du
fcd5b14c92 Use isDisabled() instead of isBlank() in getGrantName in User.php
Bug: T151956
Change-Id: Ic23c75b784c725f8f73eb1cf98d2bdb3763ab09d
2016-11-29 16:36:21 -06:00
MtDu
9e2ce38a03 List grant codenames next to grants on Special:ListGrants
Bug: T145351
Change-Id: Ia07de6269fa6192071aaea5d750362685389001c
2016-11-29 16:24:42 -06:00
Kaldari
9ba7296687 Prevent fatal error if $wgCookieSetOnAutoblock is changed to false
... and user still has a block cookie set.

Bug: T151097
Change-Id: I5a2fdc53250f629579428efbed39f6fb1f1531f3
2016-11-28 11:44:36 -08:00
Brian Wolff
f12a3edff7 Remove passwordreset capture feature
If anyone wants such a thing, they can make their own extension.

I asked stewards, and they said they don't use this.

See also T32636 / 9de2bfd1fe

Bug: T150930
Change-Id: I3ab5962dba668e5d628e55ad0c0feae471d82b5e
2016-11-23 00:02:33 +00:00
niharika29
7665985070 Add var to User class to store block type for eventlogging purposes
Bug: T146230
Change-Id: I70b54243a3018191a4e0cc311e90f66d240e1813
2016-11-16 19:43:27 +00:00
Tyler Anthony Romeo
1cc3a57296 Send a cookie with autoblocks to prevent vandalism.
Send a cookie with blocks that have autoblock turned on so that
the user will be identified to MediaWiki and any IP they try
to edit anonymously from will be blocked, even without logging
in to the originally blocked account. Additionally, the block
info is stored in local storage as well as an even stronger
deterrence.

Note: this is meant to deter normal vandals, i.e., not attackers
who know what cookies and local storage are and will be actively
removing the cookie.

This feature is disabled by default, and can be enabled with the
new $wgCookieSetOnAutoblock configuration variable (by setting
it to true);

The cookie will expire at the same time as the block or after
$wgCookieExpiration (whichever is sooner).

Bug: T5233
Bug: T147610
Change-Id: Ic3383af56c555c1592d272490ff4da683b9d7b1b
2016-11-16 10:29:46 -08:00
jenkins-bot
69ae945e8d Merge "Update weblinks in comments from HTTP to HTTPS" 2016-11-08 21:32:00 +00:00
Fomafix
202f695f67 Update weblinks in comments from HTTP to HTTPS
Use HTTPS instead of HTTP where the HTTP link is a redirect to the HTTPS link.

Also update some defect links.

Change-Id: Ic3a5eac910d098ed5c2a21e9f47c9b6ee06b2643
2016-11-07 15:24:46 +01:00
umherirrender
34fe90ac52 Remove empty lines at end of functions
It looks like there is something missing after the last statement
Also remove some other empty lines at begin of functions, ifs or loops
while at these files

Change-Id: Ib00b5cfd31ca4dcd0c32ce33754d3c80bae70641
2016-11-05 11:55:10 +01:00
Gergő Tisza
c21f49aec7 Force User::__toString() return value to be string
Bug: T148486
Change-Id: I19f483b16c99d05f4d1626ee89ba1cfb7a78d52b
2016-10-18 23:50:47 +00:00
Kunal Mehta
61adc1e146 Use namespaced ScopedCallback
The un-namespaced \ScopedCallback is deprecated.

Change-Id: Ie014d5a775ead66335a24acac9d339915884d1a4
2016-10-17 15:46:05 -07:00