Commit graph

1129 commits

Author SHA1 Message Date
MatmaRex
ed7979a970 Refactor watchlist token handling
Do not allow the user to change it directly; instead create a form
where they can reset it. (The token can still be changed via the API.)
The token is autogenerated whenever it is shown or otherwise used.

This really should have never used the preferences; however, trying to
change that now would be lots of work for very little gain, so this
keeps using that mechanism, adding a little abstraction over it.

It's not unconceivable that similar tokens could be used for other
pieces of data, like Echo's notifications; this enables that with one
new hook.

----

Things done here:

* Add getTokenFromOption() and resetTokenFromOption() methods to User,
  abstracting out the get-and-generate-if-empty process of handling
  tokens. Respect $wgHiddenPrefs (Watchlist didn't do that
  previously).

* Create Special:ResetTokens, inspired by Special:Preferences and
  Special:ChangeEmail, presenting the token resetting interface
  (HTMLForm-based with CSRF protection).

* Create a new hook, SpecialResetTokensTokens, allowing extensions to
  register tokens to be shown in the resetting form. Each token needs
  information about the preference it corresponds to and a short
  description (used for checkbox label).

* Hide the preference on Special:Preferences (use type=api to achieve
  this), display a link to aforementioned special page instead. Move
  info blurb to its own section at the bottom.

Bug: 21912
Change-Id: I0bdd2469972c4af81bfb480e9dde58cdd14c67a8
2013-07-24 22:06:15 +02:00
Timo Tijhof
f61ef8760a User#getOption: Check ignoreHidden before $wgHiddenPrefs
Change-Id: Icb1aab8cd8dc15387d199bb51ca2cd72de6dba88
2013-07-22 13:43:59 +00:00
Juliusz Gonera
1b6c4bc3c7 Make User::getEditCount() always return an integer
The docs comment says it returns an int but it often returned a string.
This led to casting this value into an integer in other parts of the
codebase and in extensions (grep MobileFrontend or Echo for EditCount).

Bug: 51633
Change-Id: I6fe5b26c24e674e8148c1fd278774b3fabe844c5
2013-07-18 15:46:15 -07:00
Marius Hoch
d50479979b Don't cache in User::isEveryoneAllowed during unit tests
Extension unit tests depend on being able to change these
mid-request (that would never happen during normal usage).

Change-Id: Ic32da022cf774341631686e6345969acc1aa5055
2013-07-12 22:43:29 +02:00
Brad Jorsch
76623e75da Add User::isEveryoneAllowed function
User::groupHasPermission is used for various purposes, from checking
whether it makes sense to show a "hide logged-in users" on
Special:NewPages to showing different error messages in some places when
'user' or 'autoconfirmed' is allowed the action to avoiding unstubbing
$wgUser to check $wgUser->isAllowed( 'read' ) in the common case where
'read' permission is granted to everyone.

For the OAuth work, we need to be able to catch that last type of use
without interfering with the others. This change introduces
User::isEveryoneAllowed() to be used for that type of check, which both
makes sure the right granted to '*' isn't revoked from any group and
calls a hook to allow extensions to indicate that they might remove the
right.

Change-Id: Idfee1b4d0613aaf52e143164acd6022459415c49
2013-07-12 11:18:15 -04:00
jenkins-bot
f34c397ca2 Merge "add and use updateExternalDBGroups function, fixes #49641" 2013-07-11 16:46:41 +00:00
Brad Jorsch
618bc84b62 Don't skip UserGetRights hook in addGroup/removeGroup
The addGroup and removeGroup functions in User were reloading the cached
mRights, but not calling the UserGetRights hook that is supposed to
allow for extensions to modify the rights list. Instead, let's just null
the cache so it will be reloaded next time something calls
$user->getRights().

Note we still call $this->getEffectiveGroups( true ), though, to trigger
that to recache.

Change-Id: I81784917303b639bc7c22c726e9cbdb0d191e674
2013-07-10 10:31:11 -04:00
Mathias Ertl
b8b91a0092 add and use updateExternalDBGroups function, fixes #49641
This enables plugins to add/remove groups in an external authentication
service when a group is added via the MediaWiki interface without relying
on the related Hooks. Relying on the Hook would mean that a plugin cannot
use User::addGroup or User::delGroup to add/remove groups comming FROM
the authentication service, as these functions would call the hook and
then redundantly add these groups to the auth-service again.

Change-Id: Ia04d5bb30831a89dfc66128e3c335bbe07f724b6
2013-07-08 19:46:31 +02:00
jenkins-bot
e7f4f3a2f0 Merge "Use a UNIX timestamp in the LoggedOut cookie" 2013-07-04 06:00:18 +00:00
Tim Starling
afe2cb12d0 Use a UNIX timestamp in the LoggedOut cookie
Since it is easier to interpret in VCL. The read side code strangely
does not need to be updated, and MW will continue to work with
cookies sent before this change, because wfTimestamp() automatically
detects the timestamp format.

Change-Id: I8c661b735b1de8e295d5d713a5ca959ee99e274e
2013-07-04 15:55:10 +10:00
Brad Jorsch
d24779328e Fix protection rights usage
It has long been recognized that using the 'protect' right to control
the ability to edit sysop-protected pages is troublesome. r31247 fixed
this by adding an 'editprotected' right, but for some reason in r32164
this was changed to bypass protection completely instead of fixing the
bug identified in r31462.

This patch goes back to do it the right way: editprotected no longer
bypasses all protection, and it is used instead of 'protect' for
controlling access to sysop-protected pages. For good measure, the same
is done with autoconfirmed protection (semiprotection): a new
editsemiprotected right is created instead of overloading the
existing autoconfirmed right.

This also fixes bug 27152 by making editprotected no longer special.

Bug: 13137
Bug: 27152
Change-Id: I6bf650a3fbdab8589ae6945c8c916eafd949e41c
2013-07-04 15:38:36 +10:00
Brad Jorsch
08adf46b26 Add 'viewmyprivateinfo', 'editmyprivateinfo', and 'editmyoptions' rights
These are needed for OAuth grants.

Note that we don't bother with a 'viewmyoptions' right, since the
majority will be determinable from just observing the interface.

Note that the fact of having a confirmed email address cannot be
reliably hidden, and if the user has 'sendemail' they may be able to
determine the real name and email address by sending an email to another
account that they control.

Change-Id: I3f03dd010020e8d43cc2d3bca7b3ef7196d1c548
2013-07-03 13:40:04 -04:00
Brad Jorsch
18062eb3b0 Add user rights 'viewmywatchlist', 'editmywatchlist'
These are needed for OAuth grants.

Note that, even if 'editmywatchlist' is not granted, various actions
will still allow for adding but not removing of pages.

Change-Id: Ie33446a228dd6ed0114730935c1bf65667f5ce01
2013-06-26 10:20:40 -04:00
Aaron Schulz
6d89076e3a Avoid the "key conflict attempting to insert a user row" exception in some cases
bug: 41609
Change-Id: Iebfcf50e648a43f2970e6d0e4073cb6d84d260df
2013-06-25 15:23:42 -07:00
Brad Jorsch
fc989b468d Add user rights 'editmyuserjs' and 'editmyusercss'
These are needed for OAuth grants.

Change-Id: I52f8e4a5cb48573cb2dbc26fc508e61a95d748c3
2013-06-10 15:44:22 -04:00
Daniel Friesen
db44d7308e Shorten our in-comment urls to the whatwg HTML spec.
whatwg.org has a redirect to /specs/web-apps/current-work/multipage/ from /html/.

Change-Id: If21705c214ca8f14db5a0c6dda3c43c22f9ca811
2013-06-05 14:21:06 +00:00
Timo Tijhof
1ec0f9cd93 User: Clean up coding style and documentation
* Parameter type hint should be a variable type or a class
  name. Types Null, Bool, Boolean, Int, Integer, String do
  not exist and are invalid values. Changed to their PHP
  type names (basically just lowercase).
* Made inline comments consistently use "//" instead of "#".
* Removed various odd spurious spaces sequences in @param
  lines. They are sometimes used to pretty-align multi-line
  descriptions. Though I think that is silly, I've left those
  alone. I've only removed the spaces where it seems arbitrary
  and not aligning with anything. Last I checked the common
  convention for multi-line descriptions is to simply continue
  on the next line with one extra space as indention.
* Swapped "$var Type" in cases where the surrounding @param's
  already use "Type $var".

Change-Id: I6b315e308271194815879c509d3ac6aeb409851b
2013-06-04 13:52:40 +00:00
jenkins-bot
703206f38c Merge "Make 'subnet' feature of $wgRateLimits work with IPv6" 2013-05-29 16:55:30 +00:00
Matthew Flaschen
a1c444f7bd Add autocreate to addNewUserLogEntry docs.
Change-Id: I40bdd510dbbc32d32ceee39b54bb4c66ace0ccfc
2013-05-27 16:43:06 -04:00
Antoine Musso
95712b4a5c User::getDefaultOptions duplicate call
The User::getDefaultOptions() has to set up the 'language' and 'variant'
language. That was done using two calls of $wgContLang->getCode().

This patch reduce it to one call.

Change-Id: I0a30f2541e35c115d1cda72ce40d5e3dcd405c5b
2013-05-23 16:17:33 +02:00
Peter Gehres
0448eed73e Changing "private" to "protected" on a few functions in User.php
This is required for auth plugins to be able to send customized
email confirmation and migration emails.  For example, we need to
send emails from CentralAuth that will both confirm the email
address and then run through Special:MergeAccount attempting to
attach as many local accounts as possible.

Change-Id: If281aa6219e5a0b80252b0deac7ee0c4f74c3d58
2013-05-16 22:19:59 +00:00
Alexandre Emsenhuber
6352be71c6 Make 'subnet' feature of $wgRateLimits work with IPv6
- 'subnet' will aggregate limits for a /64 subnet on IPv6
- Updated DefaultSettings.php to mention this
- Only call WebRequest::getIP() when it will really be used

Change-Id: Ia96800df5fb498a79e2c0527baee2392cd4623c7
2013-05-16 08:19:13 +02:00
Daniel Friesen
97caae596d Drop support for XHTML 1.0
* $wgHtml5 = false; is now ignored completely.
* $wgDocType and $wgDTD have been removed.
* $wgXhtmlDefaultNamespace is now ignored.
* XHTML5 will be output if $wgMimeType is set to an XML mime type (according to HTML5's rules).
* For backwards compatibility with extensions $wgHtml5 and $wgXhtmlDefaultNamespace are set
  in Setup.php but depending on them is deprecated.

Change-Id: Iad9634e2ee420b5a3bbffe550421fde4fa1819b0
2013-05-15 23:09:25 -07:00
Peter Gehres
efa4652fcf Unsetting the email address for a user when the email address is invalidated.
Change-Id: I2a8445745f04540e7962695c3116bb247d81fd94
2013-05-14 08:27:24 +02:00
kaldari
334958ee45 Removing exception in case rev is null
Change-Id: I2fe2961876dcdc9bde3bca9584fcbe2294629eba
2013-05-06 17:59:01 -07:00
kaldari
09de4d5c86 Adding check to make sure rev isn't null
Change-Id: I4be3904ed413086d559c21f95fd35e9b1540ce7f
2013-05-06 17:38:42 -07:00
kaldari
bc34b5867a Adding GetNewMessagesAlert hook and wgUserNewMsgRevisionId JS global
This hook allows extensions to disable or modify the new messages
alert ('orange bar of doom') while still allowing the user_newtalk
table to be updated.

The wgUserNewMsgRevisionId JS global allows gadgets and extensions
to create their own new message alerts on the client side.

I also threw in a few comment updates for good measure!

See also Echo change I3f35a56b which utilizes this.

Bug: 47962
Change-Id: I2105bdd2bcd5b27f6f36ec8d8fa7fa99d60a2d82
2013-05-04 20:21:41 -07:00
Aaron Schulz
3e7c222992 Include user name in weird User insertion exception.
Change-Id: I70fea9819e968ae306de5c3c3eee4292d3fa17d3
2013-05-03 16:14:31 -07:00
umherirrender
6f79eef473 Fixed spacing around parenthesis in includes
Change-Id: Ie8adc00f4ee8ecec4554e584c18d5d2073415397
2013-04-28 15:50:07 +00:00
Niklas Laxström
a956fd06c3 User::addGroup could cause duplicate groups
Use array_unique to avoid this case.

Bug: 46844
Change-Id: I14eb6e5a5333d887d71d545e42570493437dd320
2013-04-23 11:52:43 +00:00
Aaron Schulz
c0c5ad0272 Avoid use of __METHOD__ in closure.
Change-Id: Ib25063f41cc25647003442cbd5851c3b777b2a7a
2013-04-22 12:08:28 -07:00
daniel
3487ae0630 Fix debug log line for $userLimit.
$userLimit was used inline in the message, causing an "array to string conversion"
notice and a mangled log entry.

Change-Id: I8c5199f1bf01b56e955d8d15c48061b5301b1745
2013-04-22 09:52:36 +02:00
umherirrender
ef2f507d23 Fixed spacing in files direct in includes folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: Ibb8dd102db045522d12ff939075ba7420d95ab6b
2013-04-21 06:38:49 +00:00
Aaron Schulz
dc0fae6f6a Reduced DB contention in User::saveOptions().
Change-Id: Ic91501cd6476dae54b54b85f2f06c25bd2577c9b
2013-04-17 17:05:55 +00:00
umherirrender
15abcf71ca Added/Removed spaces around string concatenation
And added/removed spaces around some other tokens,
like +, -, *, /, <, >, =, !

Fixed windows newline style

Change-Id: I0b9c8c408f3f6bfc0d685a074d7ec468fb848fc8
2013-04-13 13:36:24 +02:00
Kevin Israel
57bf4cae49 Add @since line for User::groupHasPermission()
Change-Id: Ibcd20a3921058a010334e0e0983e2d9541aea734
Follows-up: I41edb091fa35c8c68b6f95cc5fd208ea99418cdb
2013-04-10 22:18:43 -04:00
Chad Horohoe
36cade5fe8 Remove ExternalUser authentication code
This was an experimental authentication system intoduced a couple
of years ago with a pretty narrow use-case. It's been pretty much
ignored since introduction, and makes login more complicated than
it needs to be.

I didn't drop the external_user table on the off-chance someone
out there actually has data in it, but they should use AuthPlugin
for their external authentication needs.

Change-Id: I794338dbb75961ee033d41fa44bb7aa22e54f447
2013-04-04 10:09:34 -04:00
Aaron Schulz
d3281c2b5c Deferred user_touched update via onTransactionIdle.
* This should reduce deadlocks and lock wait timeouts.

Change-Id: I7d028f9efbe6b2f73240aa653eb9775020f33e8c
2013-04-02 06:07:16 +00:00
Skizzerz
d99bda6ee6 Apply IP blocks to X-Forwarded-For header
Adds a new configuration variable ($wgApplyIpBlocksToXff), which when
enabled will scan the XFF header for IP addresses and check if any of
them have been blocked. $wgApplyIpBlocksToXff is disabled by default.

Bug: 23343
Change-Id: I3faa9c3e8107c6e46cdf21f8c18adda1f42890d7
2013-03-30 05:51:46 -07:00
Aaron Schulz
fb096ec339 Merge "Revert "Apply IP blocks to X-Forwarded-For header"" 2013-03-29 19:57:35 +00:00
Aaron Schulz
4ba66e41b5 Revert "Apply IP blocks to X-Forwarded-For header"
Test are now starting to fail for everything.

This reverts commit a5d70e3ae6

Change-Id: I30c9eb9c00be12ff080e85452e17c2a310f03bd3
2013-03-29 19:13:35 +00:00
jenkins-bot
8b3108fe77 Merge "Apply IP blocks to X-Forwarded-For header" 2013-03-29 18:42:50 +00:00
Skizzerz
a5d70e3ae6 Apply IP blocks to X-Forwarded-For header
Adds a new configuration variable ($wgApplyIpBlocksToXff), which when
enabled will scan the XFF header for IP addresses and check if any of
them have been blocked. $wgApplyIpBlocksToXff is disabled by default.

Bug: 23343
Change-Id: I3e38b94d10600a60d2d4857de54307f34c4662c4
2013-03-29 11:29:17 -07:00
Matthew Flaschen
ec794e12c3 If isConfirmedEmail (already confirmed), skip dbtouch/hook call
Bug: 46655
Change-Id: I5ea64611f68e01b1e82cd9dbe564123e81b17ed9
2013-03-28 18:30:52 -04:00
Alexandre Emsenhuber
df5265e14d Fix case of some Title methods
Change-Id: I37ce7fe392f4941c500fa0a88007664501d7e338
2013-03-27 14:36:05 +01:00
umherirrender
6c278b6d7e fix some spacing
* Removed spaces around array index
* Removed double spaces or added spaces to begin or end of function
  calls, method signature, conditions or foreachs
* Added braces to one-line ifs
* Changed multi line conditions to one line conditions
* Realigned some arrays

Change-Id: Ia04d2a99d663b07101013c2d53b3b2e872fd9cc3
2013-03-25 22:22:46 +00:00
Yuri Astrakhan
9506e3d812 Spellchecked /includes directory
* Ran spell-checker over code comments in /includes/
* A few spellchecking fixes for wfDebug() calls

Found one very strange (NOOP?) line in Linker.php - see "TODO: BUG?"

Change-Id: Ibb86b51073b980eda9ecce2cf0b8dd33f058adbf
2013-03-13 03:42:41 -04:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
jenkins-bot
073a675adf Merge "fix some spacing" 2013-03-07 17:13:27 +00:00
umherirrender
d63121016d fix some spacing
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments

Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
2013-03-07 17:53:21 +01:00
umherirrender
e43dc272bd Fix align of block comments
Change-Id: I88ea33a125a71671886b49e4ebf4c1d0a1cce572
2013-03-07 17:27:38 +01:00
Reedy
7a2bc6d480 Few minor parameter type hints in documentation
Change-Id: Ibcaad4427375b9aa39bb2b333b72a0beb9a3620c
2013-03-06 01:17:31 +00:00
jenkins-bot
636d0de4b8 Merge "Adding new subclass to HTMLForm for constructing a checkbox matrix" 2013-03-05 20:09:21 +00:00
umherirrender
de7380b56e Change intval( User::getOption() ) to User::getIntOption()
Also changed some getOption with int or bool cast

Change-Id: Ia551a50e9de047c62be84065481fdf8c02e2ef96
2013-03-04 14:08:48 +00:00
ASchulz
a6ac08128d Deal with garbage user_token values in the DB.
Change-Id: I92f1645d4a1cfc4151bd34b566ec3ac05eab427f
2013-02-27 21:08:03 +00:00
Kaldari
043b6b32f6 Adding new subclass to HTMLForm for constructing a checkbox matrix
Also adding corresponding support for using them within preferences

Change-Id: Ie6e77dfd8edaff212655d0be1d048a10eeba341f
2013-02-27 11:56:31 -08:00
Kaldari
018686256b Merge "Change new wgUserRegistration format, put in User:" 2013-02-27 19:08:40 +00:00
ASchulz
873970eda9 Init the user token before adding users.
* The DB column has garbage padding as the default value, which
  was intented to just be "". Since the the insert functions cast
  the value to a string, inserting a user without creating a token
  causes garbage to be inserted. The logic to automatically fix
  empty tokens does not trigger. This fixes createNew() to set the
  token and makes sure that addToDatabase() does.

Change-Id: I3529fe8afbc62bac37063217d5aa0179a4a6e169
2013-02-27 17:28:17 +00:00
Matthew Flaschen
910ed234e8 Change new wgUserRegistration format, put in User:
* This is much more useful if it can be passed to new Date.  As a side
effect, this means straight arithmetic comparisons can be done.
* Add a method for this to mediawiki.user (getRegistrationDate).
* Improve docs on server User::getRegistration method by documenting possibility that data is null.

Change-Id: Id7ae0faa930433876939b73d47fc294975e14fb1
2013-02-27 05:55:55 +00:00
jenkins-bot
782d246839 Merge "Mention that User::setInternalPassword() accepts null as password string" 2013-02-20 15:37:47 +00:00
umherirrender
bcea44e64a Add some missing readonly checks:
* Do not allow working on Special:EditWatchlist
* Do not reset all notification markers
* Do not delete expired restrictions

Change-Id: I7a990c0a80b9c7a6340465dd082a110dafea8f14
2013-02-09 18:58:56 +01:00
Alexandre Emsenhuber
7ed06f3b0a Mention that User::setInternalPassword() accepts null as password string
This allows to set an invalid hash preventing the user from logging in.

Change-Id: I8869eda42fd902dd26660c63e5f213b63e7e77ef
2013-02-08 08:21:29 +01:00
MatmaRex
1b71bc5256 (bug 29472) kill $wgUseDynamicDates
Remove $wgUseDynamicDates and everything related to it.

I left DateFormatter::reformat() alone, since it might possibly be
used elsewhere, and to be honest I'm afraid to touch it.

Change-Id: I609db8471c14e5e5946916f085d2ee5b96204d81
2013-02-06 17:38:05 +01:00
umherirrender
1044b0b8df fix some spacing
Change-Id: I8f976013f33c5818e4402604fe8610aa3f43b0c6
2013-02-04 20:18:33 +00:00
umherirrender
6fbbbd17ca fix some spacing
Change-Id: Ie7bb35871cc99237f3a655f7db22ca1f0646df5e
2013-01-27 14:21:50 +01:00
jenkins-bot
36320a7f1e Merge "$wgContLang global unused in addNewUserLogEntry since b65893755" 2013-01-26 00:00:05 +00:00
Platonides
dbc953fab7 $wgContLang global unused in addNewUserLogEntry since b65893755
Change-Id: Ie59aba0b6805484b57bfee917778b7dd97f86754
2013-01-25 22:35:29 +01:00
jenkins-bot
0ba1eec7aa Merge "Added new "byemail" action to the new users log" 2013-01-25 16:57:45 +00:00
Tyler Anthony Romeo
be04062547 (bug 44346) Fixed call signature for PingLimiter hook.
Changed third parameter of PingLimiter hook to a
reference since that's what all the docs say and because
extensions need to be able to override the result of
the ping limiting.

Change-Id: Ia8e9d3c4de9a6f298a00949007cad53021ab782c
2013-01-25 11:06:08 -05:00
Alexandre Emsenhuber
b65893755f Added new "byemail" action to the new users log
This allows to display the "password sent by e-mail." string in the user's language
since it's now in the action text rather than always in content language due to the
fact it was hardcoded in the log's comment.

Insertion of log entries for the new users log is now acomplished using the
ManualLogEntry class rather than the old LogPage one.

Removed 'newuserlog-byemail' message since it's no longer used (also checked
extensions in Wikimedia's Git repo).

IRC notifications will use the same message for 'create2' and 'byemail' for backward
compatibility. The only difference is that 'byemail' entries will no longer have
"password sent by email." in the comment.

Change-Id: Icdf1d714259d054cf8c256faf894c533be0dc73c
2013-01-25 16:15:33 +01:00
Alexandre Emsenhuber
a9775ae572 (bug 44202) Account creation through API no longer leaks IP address of account creator
This happens when an anonymous user wants to create an account for himself through
the API. This is due to the fact that User::addNewUserLogEntry() was always using
$wgUser as performer, but the API does not replace $wgUser by the newly created user
object when the peformer is an anonymous user.

Changed User::addNewUserLogEntry() to directly take the log action as first parameter,
rather than a boolean value saying whether the password was sent by e-mail or not,
and force the performer to be the user itself in the log action is "create". This
avoids such problems in that case, no matter the value of $wgUser, and it makes this
parameter much more readable that the old one. Backward compatibility is maintained.

Creating an user and sending its password by e-mail will still log the performer's
IP address in the log if this is made by an anonymous user.

Finally the second parameter of the AddNewAccount is now correct when creating an
account from the API, it was always false previously.

Change-Id: I188ecf420b85e9d1dab6fb933ed50d5f58532109
2013-01-21 22:00:25 +01:00
Tyler Anthony Romeo
e521f0680e (bug 43959) Add ability to reset certain option kinds in API.
Added the "resetkinds" option to action=options, so that when the
"reset" option is set, the user can control which kinds of options
are reset, rather than having to do all or none.

Also added documentation to the "change" parameter, since passing
it option keys without any "=value" after it will result in resetting
that specific option to its default value.

Change-Id: Id5bc1fffa0d487c0f152b79115205d2722f380d3
2013-01-18 13:41:44 -05:00
jenkins-bot
159dc210f7 Merge "Don't apply IP blocks to users with "ipblock-exempt" rights when creating an account" 2013-01-13 20:31:47 +00:00
MatmaRex
733d19d0d0 (bug 40124) allow arbitrary user preferences prefixed with 'userjs-'
Before change I98df55f2 it was possible to set arbitrary preferences (ie.
with anything as the key) using the action=options API. That change
removed this ability by enforcing full validation of the preferences, also
introducing several regressions which were fixed by follow-ups.

Per the discussion on bug 40124, this changeset aims to restore this
ability, but in a slightly restricted way: arbitrary preferences' names
must start with userjs- prefix, to avoid any possibility of conflicting
with new MediaWiki versions or extensions.

The contents of these preferences is not escaped, sanitized nor validated
in any way; script authors are expected to sanitize them themselves to
prevent XSS attacks and other security vulnerabilities.

This commit also adds the User::getOptionsKinds() method (to determine
whether given preference keys are used by MediaWiki itself or an extension,
intended to be used via the API, or entirely unknown) and enhances the
User::resetOptions() method to allow for resetting only preferences of
chosen kinds.

These changes allow for fixing of Special:Preferences not to clear those
additional fields when saving user settings.

Change-Id: I5f9ba5b0dfe7c2ea5458d836f03429cf6d93969d
2013-01-13 19:08:56 +01:00
Alexandre Emsenhuber
9055e91f22 Don't apply IP blocks to users with "ipblock-exempt" rights when creating an account
So that this check is consistent with the one in User::getBlockedStatus().

Change-Id: Ibcadb15b87794cfe59fc42d862728e5fd46c3413
2013-01-12 19:21:04 +01:00
Platonides
fb0966908b Miscellaneous profiling fixes
Change-Id: I8d8ce0bc0383e4feb4ed38fd96b2dd516dcb742e
2013-01-06 22:35:11 +01:00
Alexandre Emsenhuber
7cbf3b6363 Set $mLoadedItems to true in User::loadFromId()
CentralAuth calls User::loadFromId() directly after calling setId().
This avoid having to load the object two times in this case.

Change-Id: Iade37631a9346dff45e18acfa078af37c1fbbfab
2013-01-01 18:44:10 +01:00
Timo Tijhof
2549c49562 (bug 40340) Fix cache issues with changing user groups
* migrateUserGroup.php: Call User::invalidateCache

* While at it, also fix the issue where User::clearInstanceCache
  did not clear cache for User::getGroups.

  Although it does clear the caches of methods used to calculate
  other group-related lists (such as User::getEffectiveGroups),
  the one for the query from user_groups was still cached in
  $this->mGroups.

  Presumably this was forgotten when this pattern was introduced
  as the instance cache precedes the user_group table.

Change-Id: I22abdba00f8ccf587a3d7696e57970ed4653afc8
2012-12-28 14:35:49 +00:00
Antoine Musso
cb60d72be1 misc style fix
* makes booleans lower case
* add spaces before open braces

Change-Id: Id88884e08bc23d7730361ee91646f54f5e16920b
2012-12-20 16:09:25 +01:00
Reedy
d537d96868 Add numerous missing @throws to method documentation
Change-Id: Iba868e82a75fef7c7d011bc5be192bf059d037c0
2012-12-09 03:09:48 +00:00
jeroendedauw
a91a5c741a Improve type hint
Eclipse and phpstorm where showing 'User' as return type before, which causes me to not check for false somewhere and thus fatals happening :)

Change-Id: Ibd5b5598f05e6b08481ad65060c7cae18762dc4e
2012-11-28 20:37:14 +01:00
Platonides
5e309c21b4 Move around User::getEditCount() code.
It's simpler to do an early return and catch almost everything
in the profiling.

Change-Id: I2306c7b39d9808989f11d7d9d34db06c39d51820
2012-11-26 22:56:42 +01:00
Marius Hoch
76eb53053e Minor fixes to User and ApiQueryUsers
I've fixed several PHP notices and the problem that rights returned
by User::getRights() might have duplicates if altered by a hook
(same for User::getEffectiveGroups).

Change-Id: Id92af387d8c09414076bac40e83052cd6f913f42
2012-11-09 22:23:14 +01:00
Marius Hoch
070d5ca071 (bug 41793) Make contribs. link on Special:ListUsers red for users with 0 edits
The link to the user contributions on Special:ListUsers weren't red
as the needed parameter for this wasn't set in the call to
Linker::userToolLinks and User::getEditCount returned strings while
it was supposed to return integers.

Change-Id: I8d5faaedefec02d309e3e9c2da80f135b44fa5f1
2012-11-07 20:38:32 +01:00
Nikerabbit
31069e3989 Merge "Use LogFormatter to format rights log." 2012-11-01 18:51:09 +00:00
parent5446
edf5632f6a (bug 37963) Fixed loading process for user options.
The bug has actually already been fixed, so this
patch just removes extraneous function calls and code in
User::getOption() and User::setOption(). It also adds
unit tests for user options (including a test for the
case provided in the bug report).

Change-Id: Idd8af9cf1a26a4adbde3ca71dde64539ecd0a207
2012-10-30 20:28:39 +01:00
Marius Hoch
adf6e8fcdd Cache the result of User::getDefaultOptions
Caching the result of User::getDefaultOptions as it always returns
the same data, despite for unit tests, which can't use the cached
values as they do evil things with variables being constant in normal
operation.

Change-Id: I02d557006d2f879e7ce510a5e47fa1543baab8a6
2012-10-29 01:47:17 +01:00
Hoo man
d05ddf6e06 Make action=query&list=users use User::getRights()
Made action=query&list=users use User::getRights() if
usprop rights given. This not only removes redundant
code, but makes it execute the UserGetRights hook, so
that this now includes rights given by Extensions (eg.
CentralAuth does that).

Patch Set 2: Modified the User class to be able to
inject further data into User::newFromRow() and using
that to inject the groups taken out of one SQL query
(for performance reasons). Furthermore I've split up
the query in ApiQueryUsers.php into one for user data
and one for the groups, to only have one row for each
user.
After all the perfomance of this should now be ok, not
extremly good, but bearable (though I couldn't test it
deeply, as I don't have much data in my CentralAuth
environment).

Change-Id: Ie5b2924abb82ac254c77e1d04cc4d5b308962dad
2012-10-24 20:16:06 -07:00
Alexandre Emsenhuber
4c69cd3ad6 Use LogFormatter to format rights log.
* Has to keep actual messages for IRC notification
* Catch really old log entries with no parameters and use an
  appropriate message in that case to not always display erroneous
  "X changed group membership for Y from (none) to (none)".

Change-Id: Ie188bc6fcdf672fe31f0f389a158aab6256031fa
2012-10-22 19:28:32 +02:00
IAlex
4728e61383 Merge "(bug 41171) Refactor User::edits() and User::incEditCount()" 2012-10-20 16:13:42 +00:00
umherirrender
9d19d7342a Remove a bunch of trailing spaces and unneeded newlines
Change-Id: I7db616db8c969567d420c0161fa207b366e292b6
2012-10-19 22:03:05 +02:00
Tim Starling
b7b606b3a2 Clear $this->mOptionsLoaded in User::clearInstanceCache()
(bug 41198) If clearInstanceCache() is to clear cached user data apart
from the data from the user table, as addToDatabase() expects, then
$this->mOptionsLoaded needs to be set to false. Clearing $this->mOptions
may reduce memory usage a bit, but is not sufficient.

Change-Id: I6912415dc154d06f62839a1ee777c2c3747253d6
2012-10-19 14:12:33 +11:00
Marius Hoch
d0520bef02 (bug 41171) Refactor User::edits() and User::incEditCount()
User::edits() lets you fetch a cached number of edits from a slave database.
in case the field is not yet filed, we initialize if by hitting the `revision`
table and saving the result in user_editcount.

User::incEditCount() updates the edit countr and also does a lazy
initialization, if needed.

As both methods use the same $dbw->update() statement for this, I've
created a new, protected initEditCount() function which can take care of that.

Change-Id: If111270a84d4278bc4ea14d32ae602069f7c276f
2012-10-18 17:14:24 +02:00
Siebrand
7d4c391e25 Merge "Deprecate static User::edits() in favour of User::getEditCount()" 2012-10-18 00:00:11 +00:00
Marius Hoch
63ed4ac0e4 Deprecate static User::edits() in favour of User::getEditCount()
Moved the logic from the old static User::edits() into
User::getEditCount() and deprecated User::edits() as it's
not following the class hierarchy.

Change-Id: Id2b939ffb903accb8f4dc132a6ac6b6576f81beb
2012-10-18 01:41:00 +02:00
Jakub Vrana
e9ac745555 (bug 40899) Cache resources for anonymous users
Changes mTouched for anonymous users to '1' because '0' is treated as 'now' by wfTimestamp()

Change-Id: If0d77f72dc776c4709a1e5da360fbd6273178b29
2012-10-10 18:38:23 -07:00
Aaron Schulz
20e2e1e835 Merge "(bug 16020) Fix race condition in User::addToDatabase()" 2012-10-10 18:08:53 +00:00
Liangent
e4bae8bca4 Check headers for default variant when initializing default user options.
Currently, if a user with Accept-Language: zh-tw header accesses a zh site,
the page contents are served in zh-tw variant, but the interface language
is zh (falling back to zh-hans) so the user is seeing interface messages
in zh(-hans) unless a &variant= is manually set (originally variant set in
URL is checked by getDefaultVariant).

There were debates that serving different languages based on headers from
the same URL breaks cache, but currently contents are served in different
variants based on headers and it works. So I assume this is not an issue.

PS2-4: HTTP header settings shouldn't affect user preference settings of
logged-in users.

PS5-6: Move code loading variant settings for anonymous requests from
User::getDefaultOptions() to User::loadOptions() to avoid pollution of
defaults. A visual bug of this is that if I have variant set to zh and
load index.php?title=Special:Preferences&variant=zh-cn, the dropdown is
shown as zh-cn because I was using the default value and now it thinks the
default value is zh-cn instead of zh.

PS7-8: Rebase to add dependency and tweak commit summary etc.

PS9: Remove the argument added to getDefaultVariant, which was intended to
keep B/C of getDefaultVariant (not to check headers by default).

Change-Id: Ie600ab24294a1add804875e921c32febe6ed645f
2012-10-10 04:31:59 +00:00
Siebrand Mazeland
d4b046a893 Update docs for return and exception info
* Removed some inline tabs in the process.
* IDE fixed some incorrect leading spaces, too.

Change-Id: Ic9303eff6db4424ac3f1fa2816839692b43e6190
2012-10-09 09:41:58 +00:00
umherirrender
22dd67ea3c Avoid direct access to $wgGroupPermissions
Created a new method User::groupHasPermission and check also
$wgRevokePermissions for the given right

Change-Id: I41edb091fa35c8c68b6f95cc5fd208ea99418cdb
2012-10-09 06:41:23 +00:00
Tim Starling
a9f02d4022 (bug 16020) Fix race condition in User::addToDatabase()
Fix the DB error which comes from User::addToDatabase() if it is called
when the user already exists. This is the most common DB error we log at
WMF in normal operation, perhaps because of double clicks on the "create
account" button, or perhaps due to CentralAuth autocreation when
multiple pages on another wiki are opened in the browser simultaneously,
as the bug reporter suggests.

See the doc comment for the interface rationale. Patched
Special:Userlogin to be aware of the new return value. Most extension
callers will continue to work, I will patch a couple that need it in
subsequent commits.

Change-Id: I1f6ef5e6319bfe692fb82a3fa50dc66c9fde8f15
2012-10-09 10:20:45 +11:00
Marius Hoch
6ec9df30cd Clear the cached edit count within User::clearInstanceCache
(After a question in r26457): Let User::clearInstanceCache
clear out the cached edit count as well, as a user session
can be open for a long time.

Change-Id: I4444f352e3b5df7b24f37668a5f1fbf9d64d6978
2012-10-05 18:52:57 +02:00
Catrope
ab8f2c37d5 Merge "(bug 40541) Fixed $wgSecureLogin functionality." 2012-09-28 20:30:15 +00:00
Catrope
a274321310 Merge "(bug 29898) Set cookie to force HTTPS from HTTP" 2012-09-28 17:34:26 +00:00
Tyler Anthony Romeo
60c596812b (bug 39674) Fixed loading User from session when hook aborts.
Rather than have separate calls to User::loadDefaults()
every time User::loadFromSession() fails, there is now just
one call in User::load() if loadFromSession() returns false.
This fixes the case where a UserLoadFromSession hook aborts
loading from session, leaving the User object uninitialized.

Change-Id: I8d1a114d7ec361b27b260791f742c473a1497f26
Signed-off-by: Tyler Anthony Romeo <tylerromeo@gmail.com>
2012-09-28 06:12:31 +00:00
Tyler Anthony Romeo
565014a8cb (bug 40541) Fixed $wgSecureLogin functionality.
* Added parameter to login link so that wpStickHTTPS
  is set to true by default when the user is coming
  from HTTPS.
* Added redirect in Special:Userlogin so that when
  $wgSecureLogin is enabled it automatically redirects
  to HTTPS.
* Adjusted User::setCookies() to add a parameter for
  forcing secure/insecure cookies, and then added the
  appropriate argument to Special:Userlogin so that
  cookies are set appropriately.

Change-Id: I17ac68014840daa47bfd4768e978e9ff2edb00db
2012-09-27 14:34:11 -04:00
csteipp
5801da5f86 (bug 29898) Set cookie to force HTTPS from HTTP
Sets a cookie on user login (removed on logout) if wpStickHTTPS
was checked, which causes the browser to get a redirect if they
visit the HTTP version of the site.

Change-Id: I60f44a1062a93d15198edae6674bb3310a148b2d
2012-09-21 15:47:59 -07:00
csteipp
ed5b575667 (bug 39184) LDAP password leakage
Allow AuthPlugin to determine if user passwords should be stored
locally.

* Released as part of 1.20wmf10, 1.19.2, 1.18.5

Change-Id: Ie41bed7ecf5390f8815128c227bae371880a6058
2012-08-31 14:39:31 -07:00
Siebrand Mazeland
01788cddd3 Replace deprecated wfMsg* calls with Message class calls.
Last round of easy replacements. About 30 uses in core remain (outside of HISTORY
and GlobalFunctions::wfMsg*). I'll work with IAlex and Nikerabbit to work towards
getting rid of those, too.

Updated method documentation in a few places.

Change-Id: I2491c006b62a9cc183230e31a0bd96c91e5b6142
2012-08-27 20:44:47 +02:00
Demon
f3b2af3911 Merge "(bug 36776) Changing User::getNewtalk to use $wgDisableAnonTalk." 2012-08-14 23:14:20 +00:00
Aaron Schulz
1b7045e341 Added UserCache class for doing name/title batch lookups.
* Made Special:ListFiles be the first user of this class.

Change-Id: I2ea068d4765fe6ae12445786c38217119e79f823
2012-08-14 14:59:03 -07:00
Aaron Schulz
0994f2584c Merge "add 'editprotected' right to list of available rights" 2012-08-13 20:52:11 +00:00
Aaron Schulz
8394be7e15 Merge "add 'reupload-own' right to list of available rights" 2012-08-13 20:04:39 +00:00
Aaron Schulz
948f80ba5d Merge "add 'passwortreset' right to list of available rights" 2012-08-13 20:04:30 +00:00
umherirrender
6fb938c3ac add 'patrolmarks' right to list of available rights
now it is shown and selectable on api (list=allusers&aurights=) and
Special:GlobalGroupPermissions (from CentralAuth)

Change-Id: I9464109c2d1648e5668e545b9c7109ced656f4d7
2012-08-13 09:51:02 +02:00
umherirrender
66502a6dd9 add 'reupload-own' right to list of available rights
Follow up bug 5057, now it is shown and selectable on api
(list=allusers&aurights=) and Special:GlobalGroupPermissions
(from CentralAuth)

Change-Id: Ic7c57c8b29a385ad9c1ad8328ee08af758e3a4f7
2012-08-13 09:43:51 +02:00
umherirrender
216af4534d add 'passwortreset' right to list of available rights
Follow up bug 30636, now it should be shown and selectable on api
(list=allusers&aurights=) and Special:GlobalGroupPermissions (from
CentralAuth)

Change-Id: Id09d144f523c1ed687bd766945dbf9281e1d38c6
2012-08-13 09:29:44 +02:00
umherirrender
bacbb0c4cf add 'editprotected' right to list of available rights
Follow up bug 13137, now it should be shown and selectable on
Special:GlobalGroupPermissions (of CentralAuth)

Change-Id: Iebdf0454ff3636585983b07eab3d2387f404498f
2012-08-13 08:46:00 +02:00
Aaron Schulz
1690388847 Merge "(bug 12701) Use diff of all unseen revisions in the "new messages" bar." 2012-08-09 16:59:57 +00:00
Reedy
7cf98e5f37 Merge "debug log group for DNS blacklist lookup results" 2012-08-02 16:13:27 +00:00
Antoine Musso
14f426ce96 debug log group for DNS blacklist lookup results
The 'beta' project uses DNS blacklist lookup to automatically block open
proxy and active spammers. This patch simply creates the new
'dnsblacklist' debug group so we can easily log the lookup result.

Change-Id: Idfc9fb2d3db4a0bb5387c76fdef07bf9e74eeff4
2012-08-02 10:23:55 +02:00
Demon
78d1812fc5 Merge "Follow-up Ifa9c55b7 (58852d8): Change one more item to getWatchedItem()" 2012-07-30 01:52:37 +00:00
parent5446
9283e7395e (bug 36776) Changing User::getNewtalk to use $wgDisableAnonTalk.
Previously, $wgDisableAnonTalk was only used as a visual
hack in includes/Linker.php. Now, if the variable is set,
no queries will be made to user_newtalk at all.

Change-Id: Id5521abbec7f05f2de7230f9f0316176abc7f215
Signed-off-by: parent5446 <tylerromeo@gmail.com>
2012-07-27 16:46:55 -04:00
Aaron Schulz
9effaea71a Merge "Use User::getDefaultOption() instead of $wgDefaultUserOptions" 2012-07-22 09:45:18 +00:00
Alex Monk
747e89ed57 (bug 37926) Split 'deleterevision' right for log entries
This change adds a new permission ('deletelogentry') which is required to be able
to delete log entries.

It does not affect who can see deleted content.

Change-Id: I6b69919a1bdc502becc1ae4ac9169b8b0e85bfdc
2012-07-21 20:34:23 +01:00
umherirrender
a36ddc9661 Use User::getDefaultOption() instead of $wgDefaultUserOptions
Using User::getDefaultOption() in User::setOption() sets preferences like
'language' to the right default value, whereas using $wgDefaultOptions
sets the language to null because language is not part of $wgDefaultUserOptions,
but it is part of return value of User::getDefaultOption().

This only makes problems when reusing the same user object, because when
a new user object is created, the value of 'language' is correct.

Change-Id: I43a32c66fc3997a4f842c63af374e84d234602b2
2012-07-21 03:00:04 -07:00
Alexandre Emsenhuber
75211ce18e Follow-up Ifa9c55b7 (58852d8): Change one more item to getWatchedItem()
Change-Id: Id723f94e0dff68953fb7ea4e260cba58ab24d49d
2012-07-14 19:03:07 +02:00
Antoine Musso
aab43dd495 escape tags and entity in doxygen comments
When inserting XML elements inline <such as this one>, doxygen chokes
about it not being known. Simply enclosing the tag in double quotes
prevents doxygen from emitting a warning.

Also enclosed a few invalid functions calls such as \. and double quoted
the HTML entities such as &foobar;

Change-Id: I4019637145e683c2bec3d17b2fd98b0c50a932f1
2012-07-10 17:08:32 +02:00
Alexandre Emsenhuber
58852d8827 Deprecated Title::userIsWatching(); use User::isWatched() instead.
* The problem is that Title::userIsWatching() relies on $wgUser,
  which is not suitable on every case. Instead User::isWatched()
  requires both an User and a Title object.
* Replaced all core calls from the former to the latter
* Added a cache in User for the WatchedItem instances so we do not
  need to do a database request every time something want to know
  whether a page is watched or not, which can happen several times
  per request.

Change-Id: Ifa9c55b7ffb487ce6893c74df233eedc7654dc5e
2012-06-29 23:22:35 +02:00
lupo
b082e920b1 (bug 12701) Use diff of all unseen revisions in the "new messages" bar.
Also pluralize properly.

"You have a new message from another user (last change)"
if only one unseen revision, or
"You have new messages [from another user|from N users|]
(last changes)" if there are several unseen revisions.

Contains a fix in Title::countAuthorsBetween() adding options to include
(one or both of) the delimiting revisions in the count.

Change-Id: I8870111802085d0bd188cb508c4f4b852985634d
2012-06-18 08:43:47 +02:00
awjrichards
c29fd59775 Big oops - merged to wrong branch.
Revert "Revert to arbitrarily old point before initial remote branch creation to help clean up"

This reverts commit ee0d3d330f
2012-06-05 22:58:54 +00:00
awjrichards
ee0d3d330f Revert to arbitrarily old point before initial remote branch creation to help clean up
Change-Id: I41a3d1e55d3ea9dffa42451237fe065f9334361d
2012-06-02 08:43:04 -07:00
umherirrender
bf7a4bc7fc clean up User::getOptions a bit
* use local vars for often used objects
* move some lines near the code, which depends on it

Change-Id: I7a4d4ba1350cca69a8f1c6d355002ee8fdd8f2bc
2012-06-02 10:46:37 +02:00
umherirrender
2f190c4792 user table: replace some '*' with explicit fields in selects
It is good practice to select only fields, which are used later

Change-Id: Iaaa252d594112894334a8ee9916007352d5bc4e7
2012-05-25 17:53:29 +02:00
Aaron
8ffaa46662 Reduced contention slam potential in User::invalidateCache().
Change-Id: If40f368072d97e244295522003fbaa9c082f8f7c
2012-05-11 15:18:14 -07:00
Liangent
47f3110a7e Use CamelCase in both ConfirmEmail and InvalidateEmail page names.
Change-Id: I2685023eff58479f0eecd3d6ff416cbe22ee425a
2012-05-08 17:29:21 +08:00
Demon
b095e93a1a Merge "Use the same object when checking if the user is blocked instead of creating a new one." 2012-05-04 14:09:05 +00:00
Werdna
a97f5a1134 Merge "(bug 18195) Allow changing preferences via API" 2012-05-04 05:53:06 +00:00
Szymon Świerkosz
a6cd69d83a (bug 18195) Allow changing preferences via API
I have created an API module for changing the preferences.
It allows resetting preferences (reset argument) and bulk changes
of preferences (change argument) in a format:
name1=value1|name2=value2

The change argument has a limitation imposed by the current API
implementation as it cannot accept | in values. There is
available a pair of arguments optionname and optionvalue, the
latter accepts values with |.

I have created optionstoken parameter in meta=userinfo to provide
a token. There is already preferencestoken there, but I would
like to have a consistent naming.

Change-Id: I0d6c654a7354ba77e65e338423952a6a78c1150f
2012-04-20 16:56:27 +10:00
Platonides
bc7840f7d4 (bug 35961) Hash comparison should always be strict.
If your salted password end up being completely numeric when
represented in hexadecimal (less than 1 password per 10 millions),
it is also possible to login by providing another password that only
matches the first 9 bytes (instead of the full 16 ones) if it turns out
to also be completely numeric with your assigned salt (which is completely unknown).
The odds of finding an equivalent password with such characteristics, over a double md5
with an unknown salt, are really low. Even if the attacker broke into the servers and
robbed the salts, making use of this property would require a preimage attack of a partial
md5 (2^18) with the output of another md5 hash, for which a full preimage would still be
needed. Breaking the hashes using conventional attacks would be easier, so this is not
a critical update.

Change-Id: I8d1153fb91ca6507bd1df91e9953561f74f12ef6
2012-04-19 18:25:45 +02:00
Alexandre Emsenhuber
89df167b20 Use the same object when checking if the user is blocked instead of creating a new one.
* Block::parseTarget() first called trim() on its parameter which was converting objects into string, thus making the checks for object and null useless; now trim() is called after these checks.
* User::getBlockedStatus() was passing $this->getName() to Block::newFromTargert() which in turn was passed to Block::parseTarget() where a new User object was created.
  Instead of this, the User object is directly passed to Block::newFromTargert(), which avoids creating a new object for the same user.

Change-Id: Iffea21d4f53e8692072749264f7486c22b6be5fd
2012-04-17 09:48:58 +02:00
Alexandre Emsenhuber
1f61fb0d65 Fix error from I55939bb5295e73594c3fdf7287dddbc16a233ce4 (r4099) pointed out by Nikerabbit
The error is "PHP Strict Standards:  Creating default object from empty value in includes/User.php on line 2142"; the problem was that I forgot to renamed an instance of that variable while refactoring the code.

Change-Id: I4e32311693708ec5a0227d60f7818b374fccd4cc
2012-04-05 20:02:59 +02:00
Alexandre Emsenhuber
5fc4d3739c Per Siebrand, follow-up I55939bb5295e73594c3fdf7287dddbc16a233ce4 (r4099):
* Add message documentation
* Changed 'emaildisabled' wording for better understandability
* Added @since comment in User::setEmailWithConfirmation() and @deprecated in Preferences::trySetUserEmail()

Change-Id: I73c4b82ff2493a26ffbab426f30cd9af5680e503
2012-04-03 18:44:06 +02:00
Alexandre Emsenhuber
eb6df43f2e Moved Preferences::trySetUserEmail() to User::setEmailWithConfirmation()
* Much more easier to find it in the User class than in Preferences and it's general enough to be in that class.
* Rewrote the function for better readbility
* It now always return a Status object so that it's easier to interpret its result.
* Update the only caller in core (in Special:ChangeEmail) and moved the PrefsEmailAdit hook there

Change-Id: I55939bb5295e73594c3fdf7287dddbc16a233ce4
2012-04-03 10:50:34 +02:00
Platonides
cd76555106 Unneeded globals after e2ee009e5 (aka. r114233)
Change-Id: I2ee0f3946e2b584db9952926900d425b8af1dd3b
2012-03-30 00:09:14 +02:00
Daniel Friesen
73d5d7a226 Fix broken email confirmation expiration caused by MWCryptRand changes.
Change-Id: I7ef0913074f372b5ace3d14993e0e3a914b9f22c
2012-03-25 20:48:20 -07:00
bsitu
28283a0de3 fix and comparison in pingLimiter
Change-Id: Ib8aa8ecf169acdf69c55f8c1dbce0d709fb9e852
2012-03-23 16:57:53 -07:00
Tim Starling
4b8e45d604 * Removed the $method parameters from MWCryptRand. Apparently Dantman didn't know about our awesome debug traceback functions like wfGetAllCallers(). The weird optional-middle-parameter calling convention thankfully disappears as a consequence.
* Reduced the amount of debug log noise slightly, removing a few redundant messages.
2012-03-21 10:27:34 +00:00
Tim Starling
34db0956e1 (bug 35316) On autocreate, use $this as the "doer" in the newuser log entry, since unlike User::addNewUserLogEntry(), there is no way the action could have been triggered by a different user. Usually $wgUser is set correctly, but there's no need to rely on it here. 2012-03-20 06:19:02 +00:00
Daniel Friesen
e2ee009e5c Commit the cryptrand project worked on in git:
- MWCryptRand: A new api for generating cryptographic randomness for security tokens. Uses whatever cryptographic source is available and if not falls back to using random state and clock drift.
- wfRandomString - A simple non-cryptographic pesudo-random string generation function to replace wfGenerateToken which was written pretending to be secure when it's really not.
- Core updates to use MWCryptRand in various places:
-- user_token generation (to do this we stop generating user_token implicitly and only generate it when needed to avoid depleting the system's entropy pool by reading random data we'll never use)
-- email confirmation token generation
-- password salt generation
-- temporary password generation
-- Generation of the automatic watchlist token
-- login and create user tokens
-- session ids when php's entropy sources are not set
-- the installer when generating wgSecretKey and the upgrade key
2012-03-20 05:17:40 +00:00
Alexandre Emsenhuber
eb5e031f31 * (bug 35303) Make proxy and DNS blacklist blocking work again 2012-03-18 22:19:00 +00:00
Aaron Schulz
0abb52ae76 Reverted r113177 per CR 2012-03-13 20:09:49 +00:00
Alexandre Emsenhuber
a7e20dd87f Move delcaration of User::$mAllowUsertalk out of the "cache variables" block since it's not part of it; also reorder the cache variables for consistency. 2012-03-13 19:03:59 +00:00
Alexandre Emsenhuber
8263743db1 Revert r113650 and reapply r113619 and r113649 with one modification: User::createNew() was missing a DatabaseBase::timestamp() call 2012-03-12 21:17:23 +00:00
Marcin Cieślak
f65f4456b2 Revert r113619, r113649: Breaks unit tests
https://integration.mediawiki.org/ci/job/MediaWiki-postgres-phpunit/3210/console

Maybe a new property with unpredictable
value breaks some tests. Need to investigate.
2012-03-12 19:58:27 +00:00
Marcin Cieślak
7a5ec916b4 Fix r113619: Convert timestamp to the backend database value 2012-03-12 19:35:38 +00:00
Alexandre Emsenhuber
91f9e6b721 Removed the remaining parts of "cookie password" stuff, does nothing and no longer used since ages 2012-03-12 14:04:20 +00:00
Alexandre Emsenhuber
b51076f9f7 Set the user_touched field directly when adding a new user to the database so that the field is correct when someone does not call saveSettings() after addToDatabase() 2012-03-12 13:07:50 +00:00
Alexandre Emsenhuber
21ac31f144 No need to do a database query when passing an IP address to User::idFromName() 2012-03-06 20:52:42 +00:00
Alexandre Emsenhuber
e6441b8f6c * Don't issue a write query to the database if the wl_notificationtimestamp is already null, so we don't to do at COMMIT et al. on every view request on an user watching the page
* Made WatchedItem select wl_notificationtimestamp instead of "1"
* Added loading mechanism, accessor to wl_notificationtimestamp and method to reset that timestamp
2012-02-10 19:35:14 +00:00
Sam Reed
c052fc3b7b Documentation followups from lastnight 2012-02-10 15:37:33 +00:00
Max Semenik
586503f33c (bug 28936, bug 5280) Broken or invalid titles can't be removed from watchlist. Now titles are fixed or deleted, if unfixable, upon loading Special:EditWatchlist. 2012-02-09 20:39:16 +00:00
Sam Reed
85bbb0b080 Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 18:01:10 +00:00
Sam Reed
f3cc77aaee Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 17:41:50 +00:00
Tim Starling
40469f56bd Fixed a bug in User::loadOptions(), probably introduced in r49925, causing the User::loadOptions() query to be done after a cache load if the user had no option overrides at the time of cache save. Store an empty array to the cache's mOptionOverrides instead of null. 2012-02-08 05:25:19 +00:00
Daniel Friesen
877ef150d3 (bug 34237) Regenerate an empty user_token and save to the database when we try to set the user's cookies for login.
This allows the entire user_token column to be regenerated after a leak by running `UPDATE user SET user_token = NULL;` and letting the user_tokens be regenerated as users try to log back in.
2012-02-07 08:07:28 +00:00
Chad Horohoe
f3a6fc1576 Revert r102624, r104262 (user display name stuff). Per CR there isn't consensus on this yet. 2012-01-11 00:53:08 +00:00
Niklas Laxström
b61f0adad9 r98539 - make a note of change in comments 2011-12-16 09:22:07 +00:00
Jeroen De Dauw
43f00eb80c follow up to r106393 - re-add these notices, since now they wont show for people that change the depr limit to see them 2011-12-16 00:24:00 +00:00
Antoine Musso
28cec38f86 Comment out wfDeprecated() call in User::getSkin(), there's over 300 uses in /trunk
reverts r106174
2011-12-14 13:00:30 +00:00
Antoine Musso
f731b9cb92 revert r106183 : type / not setting followup 2011-12-14 12:59:05 +00:00
Sam Reed
649d7f84d7 Comment out wfDeprecated() call in User::getSkin(), there's over 300 uses in /trunk
Follows up some (cba to find) rev
2011-12-14 12:54:35 +00:00
Raimond Spekking
409703b854 Self revert r106076 which was a revert of r106070. 2011-12-14 11:50:50 +00:00
Jeroen De Dauw
04b9a5d834 comment out another to soon placed warning 2011-12-13 21:37:19 +00:00
Raimond Spekking
dbd39d7b1e Partly revert r106070 for now: Flooding of translatewiki.net log/channel:
PHP Notice: Use of User::getSkin was deprecated in MediaWiki 1.18. [Called from TalkpageView::show in /www/w/extensions/LiquidThreads/pages/TalkpageView.php at line 251] in /www/w/includes/GlobalFunctions.php on line 3520
PHP Notice: Use of User::getSkin was deprecated in MediaWiki 1.18. [Called from MessageTable::contents in /www/w/extensions/Translate/utils/MessageTable.php at line 98] in /www/w/includes/GlobalFunctions.php on line 3520
PHP Notice: Use of User::getSkin was deprecated in MediaWiki 1.18. [Called from TranslationHelpers::ajaxEditLink in /www/w/extensions/Translate/utils/TranslationHelpers.php at line 1186] in /www/w/includes/GlobalFunctions.php on line 3520
PHP Notice: Use of User::getSkin was deprecated in MediaWiki 1.18. [Called from ThreadPermalinkView::getSubtitle in /www/w/extensions/LiquidThreads/pages/ThreadPermalinkView.php at line 153] in /www/w/includes/GlobalFunctions.php on line 3520
and maybe more
2011-12-13 20:10:30 +00:00
Jeroen De Dauw
0b105ebf1d added missing deprecation notices 2011-12-13 19:51:03 +00:00
Tim Starling
3da36a9103 Reverted r92364 (per-namespace permissions).
This is the wrong configuration format for such a feature, and the wrong interface. We already have certain per-namespace permissions in the Title class, and we didn't need to add extra formal parameters to a whole lot of User methods in order to get them. The feature should be implemented wholly in Title, and the concept of user rights should remain relatively simple and easy to understand, and independent of its many applications, i.e. a user either has a right or doesn't. Rights are just a tool for developing access policies; the complexity should be in the caller.

The revert was mostly done by hand, since there were a lot of conflicts. I tried to preserve the gist of conflicting changes in r102187 and r102873. The test changes are not simple reverts, rather I just edited out the per-namespace tests. I reverted the followups r92589 and r104310.
2011-12-12 06:03:01 +00:00
Sam Reed
b5f11fa813 * (bug 32960) remove EmailAuthenticationTimestamp from database when a
email address is removed

In Preferences::trySetUserEmail no point trying to reset the users email if it's the same

Same for User::setEmail

After setting the email though, invalidate email auth tokens
2011-12-11 15:31:17 +00:00
Sam Reed
361deca215 Fix whitespace 2011-12-06 15:38:51 +00:00
Sam Reed
ffbd299b04 Another artefact of the disable account merge
Remove disableaccount userright from core
2011-12-01 00:24:22 +00:00
Chad Horohoe
7914b2ee68 (bug 29475) Remove "trackback" feature entirely from core. This has been disabled-by-default since its inception and nobody uses it.
If someone really really wants this, they can write an extension.

Language files need rebuilding, but I took care of En and messages.inc.
2011-11-23 17:14:03 +00:00
Antoine Musso
61ef7cb305 User: document 2 returns 2011-11-23 15:53:03 +00:00
John Du Hart
aa6a4828af Followup r103294, remove a space that got added on the end of the method 2011-11-16 04:39:21 +00:00
John Du Hart
93e50f7eed Following r100264, update usages in core 2011-11-16 04:37:17 +00:00
Aaron Schulz
54e44e573a Removed transaction in saveOptions(). No reason was given for it and it could break any callers that have transactions. 2011-11-13 12:35:28 +00:00
Daniel Friesen
44ab4a9448 Add a new User::getDisplayName() to return the name that should be displayed in the interface.
Add a UserDisplayName hook to allow extensions to give custom display names for users.
Add a $wgRealNameInInterface to use the real name of a user as the display name.
To start of the first use of the display name functionality tweak SkinTemplate to declare the userdisplayname and use it inside of personal_urls.
2011-11-10 06:55:21 +00:00
Chad Horohoe
db97d8d85e Drop "selenium" user right. As far as I can tell, this isn't actually used anywhere (core or exts) and is leftover from the special page for selenium that was removed. 2011-11-09 17:01:09 +00:00
Roan Kattouw
698f9e9c00 Revert r101488, breaks parser test. Add a comment explaining why there is no caching currently being done, and document the fact that the hook is called a zillion times in hooks.txt 2011-11-01 16:25:26 +00:00
Roan Kattouw
42a360b069 Cache the result of User::getDefaultOptions(), so the UserGetDefaultOptions hook (introduced in r97365) is run only once rather than on every call. Discovered this issue after seeing an insane number of memcached fetches in my RL2 code, caused by a UserGetDefaultOptions hook accessing the Gadgets storage backend (which has a memc layer) and being called a zillion times due to this bug. 2011-11-01 15:55:57 +00:00
Aaron Schulz
5dfe3d6444 Revision objects now always use the current name of users, loading it on demand if necessary (e.g. when given a $row with no user_name but rev_user is not 0) 2011-10-21 23:20:52 +00:00
Jeroen De Dauw
da250a635c we want to get the edit token, not edit the token... 2011-10-19 19:38:17 +00:00
Max Semenik
0c097b01eb (bug 31674) Can't edit watchlist if it contains special pages 2011-10-15 21:06:34 +00:00
Aaron Schulz
c0bb3a6e2b * Only spread blocks on page edit/move attempts via spreadAnyEditBlock(). We don't want to spread everytime the user's block status is checked as the user may just be viewing something rather than attempting to do anything. For example, if the 'edit' tab were changed to reflect block status, the autoblocks would trigger by a user just *looking* at the page. An example "in the wild" would be the UI checks in r93246.
* Made spreadBlock() protected, no outside callers.
2011-10-08 20:22:53 +00:00
Niklas Laxström
c04ace5435 Part of bug 31503 - Allow gender distinction also for user groups 2011-10-08 14:13:17 +00:00
Aaron Schulz
71c25a126d Made addNewUserLogEntry() return the ID of the new log entry to be more useful 2011-09-30 17:31:36 +00:00
Sam Reed
eda06e8593 * (bug 31204) Remove old user.user_options
Added run of ConvertUserOptions maintenance script into update.php before dropping the column

Removed usages of user_options in code

Marked User::decodeOptions() deprecated as of 1.19.

Made ConvertUserOptions drop out early if the user_options field doesn't exist

Made ConvertUserOptions update user_options to '' after migration of user options to mOptions
2011-09-28 18:08:48 +00:00
Tim Starling
59623dc0d1 Fixed User::getGroups(), apparently broken since r33333. User::load() doesn't load groups anymore, so calling $this->getGroups() was the same as just accessing $this->mGroups. Usually it doesn't matter, since most factory functions are funnelled into loadFromId() which calls loadGroups() or loads the groups from the cache, but loadFromRow() was potentially broken.
It's necessary for User::loadFromRow() to set $this->mGroups to null, same as the calling code in User::loadFromDatabase(), so that they will be loaded dynamically when User::newFromRow() is called.

No bugs found that are caused by this but it couldn't hurt to have working accessors. Tested from eval.php.
2011-09-22 06:17:26 +00:00
Aaron Schulz
b93198d111 Added array type hinting too getGroupPermissions() 2011-09-22 03:21:43 +00:00
Krinkle
ba37da2b0b (bug 30940) Add a hook in User:getDefaultOptions.
Needs back porting to 1.18 in order to fix Gadgets in REL1_18
2011-09-17 02:42:34 +00:00
Niklas Laxström
c90c07a587 Load edit count separately. The logging system batch queries it for the user tool links, which uses it for coloring. 2011-09-07 15:39:01 +00:00