Commit graph

1082 commits

Author SHA1 Message Date
Ricordisamoa
12dec5d85d Fix some stuttering in comments and documentation
Change-Id: I9c0088b9aab37335203cad45a1d6fa8ac3f43321
2014-12-17 19:44:10 +00:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
Ori Livneh
1c17347580 Optimize how user options are delivered to the client
We currently embed the full set of user options in a <script> tag in the HTML
output of every page. This is grossly inefficient, because the full set of
options is usually largely made up of site defaults which the user hasn't
customized.

So instead of doing that, let's emit the default options using one
ResourceLoader module and then apply the user's customizations on top.

This has the effect of slightly increasing the total bytes of JavaScript code
(because options that the user has customized will be emitted twice: once with
their default value in the user.defaults module, and then again with the
customized value in user.options). But this is more than offset by the
fact that the bulk of user options code (~4 kB uncompressed on enwiki) becomes
cacheable across requests.

Bonus round:
* Varnish gets to cache 4 kB fewer per page.
* Changes to the default options don't take 30 days to propagate.

Change-Id: I5a7e258d2d69159381bf5cc363227088b8fd6019
2014-12-05 19:36:45 +00:00
Alex Monk
d02a4d3a7a Include anchor in group page wiki link
We effectively did this when outputting an HTML link in the function above, but
not for the wiki text version.

Just use getFullText instead of getPrefixedText, which handles adding anchors
where necessary and nothing else.

Bug: T75959
Change-Id: I1a4aa46d26e738c2a97e41463231da632e4ca8e5
2014-11-28 10:31:37 +00:00
csteipp
fcbcab693f SECURITY: Require new right to change content model
Add the user right 'editcontentmodel', which is required to change the
content model while editing a Page.

Bug: 70901
Change-Id: I54f59539f1045092ec0de76c31cb47ca19c56874
2014-11-26 23:57:06 +01:00
jenkins-bot
c92a5a8129 Merge "Properly mark UserGetImplicitGroups hook as deprecated" 2014-11-21 20:58:59 +00:00
Brad Jorsch
b27e460b26 Make Title::makeTitleSafe() not need user variant
In trying to avoid hitting RequestContext::getLanguage() from a call to
User::idFromName(), I05aacd30 made it no longer safe for user input.

A closer analysis of the call stack involved reveals that
Title::makeTitleSafe() is constructing a prefixed dbkey using the
localized name for NS_USER, and then Language::getNsIndex() is needing
to get the variant in order to handle that localized name. But if we use
the canonical name for NS_USER, Language::getNsIndex() short-circuits
and skips the problematic code path.

And it turns out that it doesn't actually matter which prefix
Title::makeTitleSafe() uses, since the prefix doesn't make it anywhere
into the resulting Title object. So let's revert I05aacd30 and Ibeef0409
and just do that instead.

Change-Id: Ib902573996c69d1e77527cc7b2faf4e7fa5d3daf
2014-11-19 18:22:32 +00:00
Ori Livneh
fc8159e4de Follow-up to I05aacd30b: normalize case in User::idFromName
Change-Id: Ibeef04093338bfef8e65f40b1f9db588c8d5a79d
2014-11-18 20:03:44 -08:00
Ori Livneh
1d44597743 Avoid calling Title::makeTitleSafe in User::idFromName
We don't want to call Title::makeTitleSafe yet, since that call path
ends up needing the user language, which ends up trying to load the
user object, which ends up back in User::idFromName.

Bug: 54193
Change-Id: I05aacd30be66fe505b5c211113ea938fa82e2492
2014-11-17 17:58:50 -08:00
Bartosz Dziewoński
3e85dfb8ad Standardize indentation of multiline 'if'/'elseif' conditions
Always indent the continuation one level deeper, and always place the
closing parenthesis on the next line, per coding conventions.
https://www.mediawiki.org/wiki/Manual:Coding_conventions#Indenting_and_alignment
https://www.mediawiki.org/wiki/Manual:Coding_conventions#Line_continuation

Regexp used: (\t+)(if|while|\} elseif|foreach).+(?<![;}])\n\1\S

Also:
* Change to just one line if line length stays under 100 characters.
* Add "// Do nothing" comment in empty 'if' bodies.
* Change '#' comments to '//' comments near affected code.

Change-Id: I4f62658fddb5a0ed18bbf9b2231cd794683d6402
2014-11-17 15:33:34 +00:00
Kunal Mehta
fb7eec53e9 Properly mark UserGetImplicitGroups hook as deprecated
Change-Id: Idef74f9950d5f8e133cd19f67e8486e94ec95882
2014-11-10 14:21:51 -08:00
jenkins-bot
5309ad3df1 Merge "Allow for time-limited tokens" 2014-10-22 13:13:20 +00:00
Marius Hoch
ee9166a10e Make TestUser way faster
By only updating the user row in the database, if needed
and by making use of md5 for passwords instead of slower
hashing.
This cut down run time of some Wikibase API tests to 20%
of the original value for me!
Also it reduces the run time of MediaWiki's test suite
by about 45s on jenkins.

Change-Id: I7024b287a71fe9b327dbcdc5427cd8edb5047606
2014-10-20 02:03:08 +02:00
Brad Jorsch
b1e4006b44 Allow for time-limited tokens
Tokens returned from User::getEditToken will now include an encoded
timestamp (and therefore will be up to 16 bytes longer).

User::matchEditToken and User::matchEditTokenNoSuffix are gaining a
"maxage" parameter: when specified, only tokens with an encoded timestamp
within $maxage seconds will be accepted.

Change-Id: Ic4cf148cc1fa9d0561aac0bd2d68a09c7851896d
2014-10-17 17:07:38 -07:00
jenkins-bot
ca28853e22 Merge "Fix for Bug 63980 - Comparison of limits in pingLimiter is incorrect" 2014-10-04 20:35:30 +00:00
Brad Jorsch
4dc1f5a175 PasswordFactory::newFromPlaintext( null ) needs to work
Various code passes null around to mean "an invalid password". It
shouldn't all have to test for null and specially handle that.

This also fixes a codepath where User::$mNewpassword could get set to an
empty string rather than a password object, which would cause problems
later when anything else tries to use it.

Bug: 71421
Change-Id: Ib5f94b52c07e7dba89328b98fb43c86db95ee09f
2014-09-29 21:42:33 +00:00
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
Rohan
5a53d94111 Fix for Bug 63980 - Comparison of limits in pingLimiter is incorrect
Change-Id: Ie9da2c5af82d60e974bd258554b9438c1667630a
2014-06-10 20:21:41 +05:30
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