Commit graph

1129 commits

Author SHA1 Message Date
Aaron Schulz
76f961097a Remove cache use in setNewtalk, as nothing reads from that
Change-Id: Ia094fa99be49816b48e35aeb695b5d9558fd1d28
2015-04-27 16:45:58 -07:00
jenkins-bot
786a37c577 Merge "Added CAS logic to User::addAutopromoteOnceGroups" 2015-04-21 15:43:54 +00:00
Aaron Schulz
8c5406a437 Added CAS logic to User::addAutopromoteOnceGroups
* This should avoid duplicate logging events on races or when
  the cache fails to update.
* Also added getDBTouched() method to get user_touched itself.

Bug: T48834
Change-Id: Ib2cd0a2c72629fa4e13dcff4d2d6fbac8e690b32
2015-04-16 13:31:40 -07:00
Aaron Schulz
28404fad36 Made saveSettings() CAS check handle caught DB exceptions better
Change-Id: I8e9e75af437e00a76e4184908c579a6702c9023a
2015-04-16 10:54:45 -07:00
Aaron Schulz
9e50d6e999 Try to reduce stale cache updates in User::saveSettings()
Bug: T95839
Change-Id: I4dc87697448b833ea575cbb3e05c92c7160d03f9
2015-04-15 20:34:51 -07:00
Aaron Schulz
eccd9707a8 Tweaked CAS log message for User::saveSettings
Change-Id: I82376561b3c7c15da6fe6374db0245caa5d79ce8
2015-04-15 17:58:48 -07:00
This, that and the other
ae3ab9eef0 Allow users to add, remove and apply change tags using the API
You can add tags at the same time as performing action=edit, as long as you
have the "applychangetags" right. Also, you can add or remove tags after
the fact from revisions and log entries using the API action=tags.

No UI is provided for either of these changes. The target audience is user
scripts, gadgets and similar tools.

Includes a new log parameter format type: "list", for a comma-separated
list of values.

Logging of change tag events is limited to those that do not accompany an
edit (i.e. those done after the fact), and is hidden from Special:Log by
default, similar to the patrol log.

Bug: T20670
Change-Id: I37275e0f73fa3127f55da0c320b892551b61ee80
2015-04-15 18:30:45 +00:00
Aaron Schulz
7eb982b0b4 Avoid deadlocks in User::incEditCount
* This makes concurrent editing less problematic

Change-Id: I930222d5e831bb3729194abbdcb3cab194c70494
2015-04-14 04:59:44 +00:00
Aaron Schulz
5b4bd16327 Made User::invalidateCache() use touch() instead of the DB query
* This method is used for clearing the User cache as well
  as bumping the value of getTouched() for HTTP 304 logic.
  These do not need to do the actual user_touched update.
* This also avoids problems with setting mTouched but
  deferring the update. That confused the CAS update
  logic since it expects mTouched to be in the DB.

Change-Id: I96b30f5c9c8b4714e6663b187f741954a13312cf
2015-04-07 19:59:35 -07:00
Aaron Schulz
eb9a75cff6 Made User::loadPasswords respect "queryFlagsUsed"
* Also cleaned up a few var names

Change-Id: I3a835e3980dfc3205716cf5bb1a4c04aa037f36d
2015-04-07 12:12:23 -07:00
jenkins-bot
7253056a23 Merge "Added CAS-style logic to User::saveSettings as a final sanity check" 2015-04-07 15:43:43 +00:00
jenkins-bot
4b983308cb Merge "Log when User::saveSettings is called in read-only mode" 2015-04-07 09:44:59 +00:00
Aaron Schulz
f6b76d3a9e Added CAS-style logic to User::saveSettings as a final sanity check
* This should prevent lag or race conditions from rolling back data

Change-Id: I5e70975f4e4010fea7af0801bc11dda887df55f4
2015-04-06 12:20:05 -07:00
Aaron Schulz
6af07cbe1f Log when User::saveSettings is called in read-only mode
Change-Id: I56a1760f2e6bbda889590777b553a8dfda587590
2015-04-06 11:26:42 -07:00
Aaron Schulz
b84d573d4b Made User::newTouchedTimestamp handle clock skew a bit better
* This does not handle race conditions, but is a prelude to using CAS
  style logic on save using the timestamp.

Change-Id: I9c31c272fcf77b686764b7c3a6a32ac29576347c
2015-04-06 11:14:48 -07:00
Aaron Schulz
f7fe3c2b46 Added read-only checks around User::saveSettings where they belong
* Ideally saveSettings() would not just silently do nothing in
  read-only mode as not all callers expect that behavior. This
  change is just the first step.

Change-Id: Ieeaf531dac3027ddba89c60159b98f9c04de78d3
2015-04-02 18:12:37 +00:00
Tyler Romeo
63cf33d825 SECURITY: Set maximal password length for DoS
Prevent DoS attacks caused by the amount of time
it takes to hash long passwords by setting a limit
on password length.

Slightly restructures the behavior of User::checkPasswordValidity
in order to accommodate for the difference between
passwords the user should be able to log in with and
passwords they should not.

Bug: T64685
Change-Id: I24f33474c6f934fb8d94bb054dc23093abfebd5e
2015-04-01 09:55:42 -07:00
jenkins-bot
eca8322266 Merge "Removed unused parameter from User::checkNewtalk" 2015-03-30 18:31:55 +00:00
Aaron Schulz
4f8dc27b90 Removed unused parameter from User::checkNewtalk
Change-Id: I112fc32d9985664ab5edea842f52f62554c082ea
2015-03-30 11:15:01 -07:00
Aaron Schulz
ab24e5d417 Made User::getFormerGroups load properly
Change-Id: I5c752f9446ef78f08c457e9758ebf9e0b79a0c37
2015-03-30 11:13:46 -07:00
Aaron Schulz
cdc572c767 Made User::validateCache account for mQuickTouched
Change-Id: I3b733a0221462350f3a24d54ffe814357f379512
2015-03-30 09:36:49 -07:00
jenkins-bot
f9a5c17799 Merge "Made user preferences load from the master by default" 2015-03-30 15:30:49 +00:00
Aaron Schulz
f68da5b863 Made User actually use the mQuickTouched process cache
Change-Id: I158eae2dac16b5fdacd095fff7fb031b42804a1e
2015-03-26 22:51:13 -07:00
Aaron Schulz
7e27652a76 Made user preferences load from the master by default
* Warn when saving slave-loaded data in saveSettings()
* Respect the loading $flags for preferences/groups
* Fixed use of flags in addToDatabase()
* Made loadFromCache() protected to make this mess easier
  to reason about (no callers found)
* Added some doc comments

Bug: T92232
Change-Id: Ic1dd66063cc2f98fc03861df1c523981f846a0be
2015-03-26 19:18:44 -07:00
jenkins-bot
ddfcbf86cc Merge "Made addAutopromoteOnceGroups check wfReadOnly" 2015-03-26 22:37:59 +00:00
jenkins-bot
1be2b846dd Merge "Introduced User::touch() method to bump the getTouched() value using memcached" 2015-03-26 22:25:19 +00:00
Aaron Schulz
04424ff049 Made addAutopromoteOnceGroups check wfReadOnly
Change-Id: I2fecf6616dd00cd34647f67298583ea8ec2977c0
2015-03-26 15:20:14 -07:00
Aaron Schulz
87d2eba431 Introduced User::touch() method to bump the getTouched() value using memcached
* This lets some callers avoid the heavyweight invalidateCache() method

Bug: T91279
Bug: T92357
Change-Id: I8c1c7ff9c5574f0eca23e7effde199ab13a19231
2015-03-26 15:05:56 -07:00
Aaron Schulz
70919c8a32 Made User::loadFromRow protected for sanity
* The loading logic is complex enough without more possible
  entry points to cover
* No outside callers found

Change-Id: I7e9bace35afb0a540993423cf1da98381a516ac5
2015-03-26 05:41:42 +00:00
Aaron Schulz
14f63add18 Allow callers to load user objects from slaves if desired
Bug: T92357
Change-Id: Ib9d21b8ee988c84e7b3d1676ad6cbbbf07f795a4
2015-03-24 10:38:05 -07:00
jenkins-bot
b15cd2ee45 Merge "Re-introduce AvailableRightsTest for User::getAllRights completeness" 2015-03-16 18:00:02 +00:00
Aaron Schulz
58c8e2b969 Made getNewtalk use slaves instead of cache/master
* This was causing floods of master connections on page views

Bug: T92357
Change-Id: I02fd1505f589112b8f6217047e6713845142a1c3
2015-03-13 21:46:28 +00:00
Amir E. Aharoni
16c2aec980 Shorten long lines in User.php to make phpcs pass
Change-Id: Id0938687439d046b98d7b3a4b7666ff7ae41760a
2015-03-04 04:26:32 +00:00
Kunal Mehta
c899d19888 Populate User::$idCacheByName in User::loadFromRow() if possible
Change-Id: I4c7dab517ca6b7adcdec0c945e21d6be0b7b7d66
2015-03-02 14:52:25 -08:00
Hoo man
cd5790efff Re-introduce AvailableRightsTest for User::getAllRights completeness
Because extensions often don't add their rights to $wgAvailableRights
or via the 'UserGetAllRights' hook, thus User::getAllRights is incomplete.

As announced on https://lists.wikimedia.org/pipermail/wikitech-l/2015-February/080953.html

This reverts commit 9a16d3a37e.

Change-Id: Ic394145d123cd74bdd5b912559f56c393f1d5919
2015-03-01 17:38:15 +00:00
jenkins-bot
a756c3b753 Merge "Use the request object provided in User::setCookies" 2015-02-20 22:19:10 +00:00
Brad Jorsch
4b8b0358eb API: Add authz features for RESTBase
The RESTBase team has requested the ability to check the validity of a
CSRF token and to interface with Title::userCan().

The former is accomplished by the new action=checktoken module. The
latter by a new parameter ('testactions') to the existing prop=info.

Bug: T88010
Change-Id: I2530f1315ec93f5be9fb437137992150fdc305f2
2015-02-19 16:45:03 -05:00
Hashar
9a16d3a37e Revert "Add AvailableRightsTest for User::getAllRights completeness"
This change has not been advertised and cause random extensions
to start failing giving little clue to users.

Please have this change discussed on wikitech-l and announced
ahead of time to minimize disruptions. It brokes MathSearch at least:

https://gerrit.wikimedia.org/r/#/c/189442/

This reverts commit d333cd8f7b.

Change-Id: If9a28b1386fca946d8ba351c16134cdf7da8a148
2015-02-11 15:03:35 +00:00
Marius Hoch
d333cd8f7b Add AvailableRightsTest for User::getAllRights completeness
Because extensions often don't add their rights to $wgAvailableRights
or via the 'UserGetAllRights' hook, thus User::getAllRights is incomplete.

Change-Id: Id9ae9eff71e822ec5c038c1c1f990ac36f05cea8
2015-02-10 13:12:11 +01:00
This, that and the other
878523f622 Creation, deletion and improved management of change tags
This allows users with the `managechangetags` right to create tags for
use by wiki users. (Currently there is no way for editors to apply tags
to their edits; that's to come in a later patch.)

Extensions can reserve tag names for their own use, even if they do not
define them or mark them as active.

Tag managers can also delete tags with <= 5000 uses. Currently, if a tag is
misspelt ("vandlaism") or no longer wanted (testing of OAuth, etc), the
wiki is stuck with it forever. This change allows users with the
"managechangetags" right to delete change tags from the database,
including removing them from all revisions to which they are applied.

Obviously this is a powerful thing to be able to do, but I view change
tags as a "light" kind of interface, useful for revision patrolling and
spam/vandalism fighting but not something that necessarily needs to hang
around forever. It's not a big deal for this kind of data to be thrown
away without being archived anywhere.

Tags defined by an extension can only be deleted if the extension allows
it.

Changes to tags are logged in the new "tag management" log. There's even
a nice API module, just for fun.

Bug: T20670
Change-Id: I77f476c8d0f32c80f720aa2c5e66869c81faa282
2015-02-04 14:14:18 -05:00
Alexia E. Smith
e0094618b5 Use: addGroup() and removeGroup() should return boolean
Have User::addGroup() and User::removeGroup() methoids return a
boolean when their respective hooks return the respective boolean.

Fix SpecialUserrights to respect this return vale and update the
add/remove arrays accordingly.

This resolves an issue where a hook that prevents a group from
being added or removed still shows that group being changed in
the Userrights log.

Change-Id: I7621cc22b04ff41cf67bd434a1f89d31bdc2cffd
2015-01-22 16:45:16 -08:00
Niklas Laxström
80ca508ed1 Add User::equals
Seems stupid omission. Title has one. Why do I need to think how
to determine how to users objects point to the same user. Allows
more expressive code.

Also fixes a bug in multiple places where users "0" and "00" were
considered equal.

Change-Id: I682392e564b332b77ab489f2ad394fa2d28098a5
2015-01-13 15:04:45 +01:00
Ricordisamoa
2ae155da52 Fix phpcs errors in includes/
Mostly Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines

Change-Id: I678b2f0902f11cd1dfa1611b9da24e7237df9122
2015-01-08 20:15:07 +01:00
Aaron Schulz
4ff8136807 Removed remaining profile calls
Change-Id: I31c81c78715048004fc8fca0f27d09c1fa71c118
2015-01-08 02:49:33 -08:00
Chad Horohoe
aa21e125a3 Remove obvious function-level profiling
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.

Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.

Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
2015-01-07 11:14:24 -08:00
Niklas Laxström
8d71f214fb Remove over/underescaping detected in Special:UserRights
Bug: T31340
Change-Id: I99823cd56e0a6f501101cb85be832d2925ce9779
2014-12-29 16:05:40 +00:00
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
Erik Bernhardson
7cf1c2fea6 Use the request object provided in User::setCookies
When calling User::setCookies with a $request object that was not
passed on to the User::setCookie method, which went ahead and
updated the request from RequestContext::getMain rather than
the provided request.

This patch adds another parameter to User::setCookie to accept
a request object, and User::setCookies to pass the request along.

Change-Id: Ie46fd8c90753e8bf54ce58842c08e0519a269582
2014-12-03 14:47:44 -08:00