Commit graph

1065 commits

Author SHA1 Message Date
Matthias Mullie
d695ef0cd1 Move code to load User data from cache out of loadFromId
This way, outside code can load data from cache only if present. E.g. when data
for a lot of users is needed, it'd be preferable to batch-load all that is not
yet in cache.

Since there's currently no way to check for data in cache, one would have to
load all User objects separately (which may result in lots of DB queries if
nothing is in cache) or batch-load all of them (which may result in few DB
queries, but ones that may not be needed if all data is already in cache)

Change-Id: Ia22d04744760c3b6f3264786434e218b8aa88d53
2014-09-23 19:38:50 +00:00
Kunal Mehta
eab5a7d6ef Add MailAddress::newFromUser()
And tests!

Change-Id: I5214c50855f6bc756f6d748e435ae2124b2264c1
2014-09-14 19:03:18 +00:00
Kunal Mehta
c7ef6775fe $wgAuth is no longer a stub object
Follows-up Icb36e47a

Change-Id: I92031c905cd61cc31eae34c90f2ce49a8f84ba8b
2014-09-08 01:27:34 -07:00
Aaron Schulz
4b3edb21bd Profile User::checkPassword
Change-Id: I2e7e9574a56725f4e7c34415b241006a933f631d
2014-09-04 11:02:34 -07:00
csteipp
3ab9d9964b Load password information when expiring
Call loadPasswords when expiring the user's password, otherwise the
change is overwritten with the previous value.

This lets you do:
  $u = User::newFromName( 'User' );
  $u->expirePassword();
And the user will have to reset their password on the next login.

Change-Id: I47325dde1ce14280088efdc90ce7887b45e0dc6a
2014-08-28 11:04:57 -07:00
umherirrender
2f491ef504 Remove double @return from User::isAllowedAny
And fix the @param for the varargs

Change-Id: Idb9b3037bb6cbb41e01432a278695d6a29008edd
2014-08-24 11:05:16 +02:00
bsitu
0f079ab390 Followup I4049b666: "Removing prefix exception for HTMLCheckMatrix"
Change I4049b666 changed the way Preferences combines the prefix with
the row and column for HTMLCheckMatrix, but did not adjust the
corresponding code in User::getOptionFromUser().

Bug: 69146
Change-Id: I69ed9c875443ba44d1a5e12e51165ebf8d6d6a06
2014-08-07 22:02:55 +00:00
Tyler Romeo
a223f2541b
Add loadPasswords() calls to User password mutators
In User::setPassword() and User::setNewpassword(), added
calls to loadPasswords() so that the passwords are not
overridden when they are eventually actually loaded.

Bug: 69102
Change-Id: I0b881986323051abed7d1af816eae9eafdbd6782
2014-08-04 11:10:01 -04:00
Kunal Mehta
50bcbe6c89 Add getPassword/getTemporaryPassword accessors to User
In I0a9c972931a, User::load() no longer loaded the
mPassword and mNewpassword member variables, and
User::loadPasswords() is private. So this lets
things that need to access the Password objects directly.

Change-Id: Ib79ce01a47f90af681e376ce918eda559b4b94a6
2014-08-03 18:41:39 -07:00
jenkins-bot
4bbc818c46 Merge "Fix title handling in User::getCanonicalName" 2014-07-30 23:27:56 +00:00
Chad Horohoe
0c76fdada1 Merge "Clean up user version constants" 2014-07-30 14:21:34 +00:00
jenkins-bot
50a12ff5ca Merge "checkTemporaryPassword should call loadPasswords() first" 2014-07-30 01:17:49 +00:00
Chad Horohoe
68bf9d703c Clean up user version constants
- Two global constants unused outside of this class so removed
- Shorten name since MW and USER are redundant since it's in a class
- Use class constant instead of global define consistently

Change-Id: I0e8b05372512de568a230a6e5026751aa37c4c4e
2014-07-29 20:55:24 +00:00
Brian Wolff
514d1bc76d checkTemporaryPassword should call loadPasswords() first
Otherwise mNewpassword could be null.

Mlpearc reports on irc getting fatals about mNewpassword not
being an object. I couldn't reproduce, but loadPasswords() should
definitely be called here.

Change-Id: I6d1b74b79c87d1a1870971aafd1349255170123d
2014-07-29 17:21:10 -03:00
jenkins-bot
1a8daf2c07 Merge "Unsetting the email address for a user when the email address is invalidated." 2014-07-29 19:50:55 +00:00
jenkins-bot
878b970ccd Merge "Documentation fixes for Password API-related changes" 2014-07-29 15:25:12 +00:00
withoutaname
72462041c0 Move PasswordError under includes/password/ file
Change-Id: I7256325492b2f6451223714efb8b3e07fca9ee3e
2014-07-29 02:07:50 -07:00
Kunal Mehta
2a904107c5 Documentation fixes for Password API-related changes
A few @since 1.23 --> 1.24

Change-Id: I55d00ab9c3f9dae96ed804a22f19d713879663fa
Follows-Up: I0a9c972931a0eff0cfb2619cef3ddffd03710285
2014-07-29 05:17:26 +00:00
Tyler Anthony Romeo
95a8974c6b
Added password hashing API
Deprecated the old User::crypt, et. al password hashing
system and implemented an extensible password hashing
API.

The new Password class allows registering of child classes
and provides factory functions for creating new Password
objects. The built-in hash types are the old MediaWiki MD5
types, which are for backwards-compatibility only, and bcrypt.

Also included is support for wrapping existing hashes as well
as encrypting passwords with a configured encryption key.

Bug: 54948
Bug: 28419
Change-Id: I0a9c972931a0eff0cfb2619cef3ddffd03710285
2014-07-27 15:51:18 -04:00
umherirrender
1ef57be80a Fix title handling in User::getCanonicalName
With r41328 the title validation was changed to allow rename of invalid
user names, by always creating a title object.

That removes the title validation for validation of 'usable' and
'creatable', but in that case it is also a good idea to apply title
rules to normalize spaces and reject user names which can not have a
valid title. At the moment that is done in User::isValidUserName.

Change-Id: I27c488e4008a924117ff6bac2216f148cd5e7abd
2014-07-25 07:27:15 +00:00
umherirrender
1c68a1ee86 Cleanup some docs (includes/*.php)
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: I783e4dbfe5f6f98b32b9a03ccf6439e13e132bcc
2014-07-24 19:42:24 +02:00
Aaron Schulz
9db0dde27d Reject cache with future MW_USER_VERSION versions
* On rollback, using newer cache versions can cause issues if fields were
  modified or removed.

Change-Id: I7be290d6f776f9234c352dd3164b8e73dad4d49e
2014-07-23 17:19:47 -07:00
Bartosz Dziewoński
6cf0e51880 User: Normalize skin key from $wgDefaultSkin for default options
$wgDefaultSkin is allowed not to actually be a valid key (although
doing that is obviously very unwise), which in turn can cause
exceptions from Preferences::loadPreferenceValues()
(MWException "Global default…"), which in turn causes failure of
SpecialPreferencesTest::testBug41337() test.

Change-Id: I8f8ae9ba301337b2e6facd3dcfadbf2ab12ac605
2014-07-23 21:57:40 +02:00
umherirrender
53c420e278 Fixed spacing
- use tab as indent instead of spaces
- Added space after closures "function"
- Added spaces around string_concat
- Added newline inside empty blocks
- Removed four spaces after comma

Change-Id: I4425b0c6a69b36f40acfea6511b8950cf09ce2b2
2014-07-20 21:41:41 +02:00
eikes
2f002458d5 Split "suppressrevision" into two user rights
In this change, a new passive user right named "viewsuppressed"
which can be used in order to view suppressed page content was added
to MediaWiki core.
Furthermore, this right was also added to the list of available rights,
to qqq.json and to en.json where also the description of the
"suppressrevision" right was adjusted in order to reflect reality.

Bug: 20476
Change-Id: Id1baacb9c782763db5e05ef8b5c1b761997efcc9
2014-07-19 18:11:15 +02:00
withoutaname
1163efdea9 Remove $wgEnableSorbs and $wgSorbsUrl
They were deprecated in version 1.17.

Change-Id: I8489c0cb4a041d081283fa3551377ef81ef36549
2014-07-13 00:51:26 +00:00
jenkins-bot
d7dd7fbf98 Merge "New 'UserResetAllOptions' hook from the wikiHow codebase." 2014-07-10 21:51:41 +00:00
Jack Phoenix
6cddec7213 New 'UserResetAllOptions' hook from the wikiHow codebase.
Location is a tad bit different now than on the wikiHow codebase and some
arguments have been added, as per code review.

Because sometimes you have things that are stored in the user_properties
database table that should *not* be reset even when the user has requested
to reset all prefs back to the site defaults.

Live example of a thing using this hook (well, its previous iteration) is
wikiHow's WikihowPreferences extension.

Change-Id: I1da936c786adb21e2c1802ef405bb904c9cf4918
2014-07-11 00:39:16 +03:00
umherirrender
d321aeee51 Remove User::isValidEmailAddr() (deprecated since 1.18)
Change-Id: I3440e32768d03e9160e23b038b6f4dc830f78647
2014-07-10 18:52:34 +02:00
Alexandre Emsenhuber
a7de863d3a Don't use isset to check for null
Change isset() checks for variables that are always defined.

Change-Id: Ic96b9661d94742909c0d6b62a8eb2f6a038a774f
2014-07-04 21:20:22 +02:00
Kunal Grover
50144cd02a First version of Page Language selector
Special page PageLanguage to set the page language of a page.
To enable the feature, set $wgPageLanguageUseDB to true
and assign the 'pagelang' user right to a user group.

Bug: 35489
Change-Id: I0f82b146fbe948f917c1c5d29f7469644d797e80
2014-06-27 23:27:07 +00:00
Aaron Schulz
8006aa946a Avoid key conflict errors in User::addToDatabase
* Also cleaned up the IDBAccessObject constants to cover more cases.

Bug: 66185
Change-Id: Ide28af552b3c59428923b373c0f5764414d50a1f
2014-06-24 10:59:27 +00:00
Aaron Schulz
b66bb911b5 More optimizations to User::saveOptions()
* Avoid doing the DELETE for unchanged rows. This method is often
  called when one new preference (e.g. watchlist token) is set.
  These cases will now simple result in an INSERT, even if the
  user already has some preferences set.

bug: 36116
Change-Id: Ib7c558e7c06927875086b86ea719ac1323a7b4a8
2014-06-06 18:58:43 +00:00
jenkins-bot
f853b14c46 Merge "Make convertUserOptions.php more self-contained" 2014-06-02 22:50:44 +00:00
Kevin Israel
3385d6d157 Make convertUserOptions.php more self-contained
* Moved the code from User::decodeOptions() to the maintenance script,
  the only place it is (indirectly) used.
* Changed the script to insert new rows itself rather than calling
  User::saveSettings(), avoiding bug 63677.
* Removed FOR UPDATE and COMMIT lacking a matching BEGIN.
* Made ORDER BY explicit.
* Removed pointless "Do each user sequentially [...]" comment dating
  back to r48732, in which the script would increment a user's ID
  to get the next one.

Bug: 63677
Change-Id: I86365a7363af3376cc4f55fa528b050b44378656
2014-05-31 23:10:47 -04:00
Nemo bis
5dc4dc099d Save advanced search namespace prefs on Special:Search itself
* Checkbox on own row below power search checkboxes per MatmaRex;
  avoiding a mw-search-ns* id leaves it untouched by All/None JS.
* The option searcheverything is removed: a "shortcut" which is no
  longer necessary now that options can be (un)selected at once
  with All/None buttons on search page itself.
* Require a token for saving: no accidental preferences changes.
* Keep the searchoptions/advancedsearchoptions prefs section in case
  something is using it (no known extension does though); options
  are converted to "api" type so it's empty and hidden by default.
* Add minimal documentation for saveSettings() and friends
  (@todo since 155ddf6de, 2009!).

Bug: 52817
Change-Id: I514cee835988600cc013658049e88a10b670e64a
2014-05-30 14:33:47 -07:00
Kevin Israel
b9e1d5f5c0 Add hash_equals() fallback and use it
Two classes (User and SpecialRunJobs) currently contain string
equality checks that purport to be timing-attack resistant.

Reduce code duplication by adding and using a fallback for the
hash_equals() function from PHP 5.6 (currently in beta), in a way
addressing the comment "@todo: make a common method for this".

Change-Id: Iece006ec0216edb3fc5fbef7cc6ec00a6d182775
2014-05-28 20:52:08 -04:00
Antoine Musso
1b0603ce0f User::pingLimiter() profiles per action as well
We had an outage beginning of may that involved rate limiting of the
'renderfile-nonstandard' action.  This makes User::pingLimiter() to
record a per action profiling point in addition to the generic one, that
would let us finely graph actions being throttled.

Ref:
https://wikitech.wikimedia.org/wiki/Incident_documentation/20140503-Thumbnails#What_can_be_improved

Bug: 65477
Change-Id: Iac7930e85f7d9101663656ccb2bccdbebf908693
2014-05-19 12:45:11 +02:00
jenkins-bot
02b1c42009 Merge "Improved rate limit log to mention IP" 2014-05-13 19:33:19 +00:00
Siebrand Mazeland
2daa1fab7a Make phpcs-strict pass on includes/ (3/~10)
Change-Id: Ibf86d03b5479c47ee72c0dafea6777ef8178fe68
2014-05-11 19:28:07 +00:00
Jackmcbarn
f14e48f4f9 Allow moving category pages
Allow category pages to be moved. This is to preserve attribution of the
page only and does not cause pages in the category to recategorize to the
new one. A warning explains this when such a move is attempted. The new
right move-categorypages is required to do this, which is assigned to user
and sysop by default (the same as other move-related rights). The message
category-move-redirect-override can be used to cause custom text to be
placed on the "old" category page in lieu of a redirect.

Bug: 28569
Bug: 5451
Change-Id: Ic93616a54c8e98e3dc71daee3c92c466d64daffc
2014-05-09 18:12:25 +01:00
Aaron Schulz
825334191e Improved rate limit log to mention IP
* This could be useful for logged in users and subnet limits

Change-Id: I4ddfb08c4730ec5cc3aec82f20792bbc09a49338
2014-05-06 12:34:28 -07:00
umherirrender
5a93df2fba Fix some @params documentation in includes/{GlobalFunctions,User.php}
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in capital.

Change-Id: If8c0cf4627fc62ff288d33658e327ae80548f5c5
2014-04-23 09:53:38 +00:00
jenkins-bot
d16f223edf Merge "Removed 'Remember my login' preference" 2014-04-17 17:02:43 +00:00
tonythomas01
74756a2409 Removed 'Remember my login' preference
Removed 'Remember my login' from Preferences, as it was unwanted. It adds
to the complexity of the user preferences

Bug: 52342
Co-Author: Tyler Romeo <tylerromeo@gmail.com>
Change-Id: I7c957e1e1aaecf47f7c47bc063b5d3b364644afc
2014-04-16 12:49:44 +05:30
Bartosz Dziewoński
59002d8935 Consistently use '@deprecated since <version>'
Variants included 'in <version>', 'as of <version>' and just the
version number.

Some @deprecated annotations do not have the version number at all,
I want to hunt them down separately.

Change-Id: I8208c6097098f4735d4f51bc42254675f1f27f6d
2014-04-15 22:18:19 +02:00
umherirrender
2000672ac3 Fixed spacing
- Added spaces after if/foreach/catch
- Added new line before end of file
- Added or removed spaces before/after parenthesis, comma
- Added spaces around string concat

Change-Id: I0590070f1b3542108e242730e8d9a3ba9831e94f
2014-03-20 20:37:30 +00:00
umherirrender
e165035081 Use square brackets instead of curly braces for char of a string
The use of curly braces is deprecated in php 4.0, so changing it to
square brackets

Change-Id: Ia820cea34d2bd92fe1c3bc8fd773942a425ec90a
2014-03-19 20:13:19 +01:00
csteipp
9d7af803a1 Allow login with passwords not meeting complexity requirements
As part of https://www.mediawiki.org/wiki/Requests_for_comment/Passwords

This patch:
* Allows users to login with a password that does not meet the
  requirements of User::isValidPassword(), including the minimum password
  length.
* Adds a configuration flag that specifies if users should be sent to
  the change password form when they login with a password that doesn't
  meet the requirements of User::isValidPassword().

To test the UX as it will be on WMF wikis, set
$wgMinimalPasswordLength=6 in your LocalSettings.php.

Change-Id: Ib7b72005fea1c69073c0a33a68c0a0df0d6528d2
2014-03-18 20:46:44 +00:00
csteipp
ea7687a7fd Refactor password validity checking
Refactor the password checks to return a status object, so the function
can handle the entire error message, or return multiple error messages.

This patchset aims to keep the functionality identical. A followup
patchset can further improve the functionality. E.g., although
getPasswordValidity stated it could return an array of messages, it
never did so except from the hook, so most callers expect and handle a
single string.

Change-Id: I87644486f5572dc067ebdbacd01fb39c67e5612a
2014-03-15 06:30:25 +00:00