Commit graph

895 commits

Author SHA1 Message Date
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