Commit graph

27 commits

Author SHA1 Message Date
Umherirrender
9a107e6b03 Use expression builder instead of raw sql
Bug: T361023
Change-Id: Ibf1c93ddbf8f680e8fb9442816f6fed94a069c0a
2024-07-23 23:30:45 +02:00
Umherirrender
a9adc61d35 Use RawSQLValue for some SET clauses in update/upsert
Change-Id: I03c068c4bf098ab073989a0ea32a0f87fe878727
2024-05-29 19:48:09 +00:00
Amir Sarabadani
8e183495e1 Stop using LoadBalancer::getConnectionRef() so it can be hard-deprecated
Bug: T326274
Change-Id: I90493d7cd4c21fdc022bcc19765fc04d986a9c8f
2024-04-30 13:31:08 +01:00
James D. Forrester
8e940c4f21 Standardise all our class alias deprecation comments for ease of grepping
Change-Id: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
2024-03-19 20:11:29 +00:00
James D. Forrester
67217d08df Namespace remaining files under includes/deferred
Bug: T166010
Change-Id: Ibd40734b96fd2900e3ce12239d09becfb4150059
2023-11-22 10:08:53 -05:00
Amir Sarabadani
e33818cd08 Fix space after comma in single-line array declaration
We are introducing a new phpcs sniff to make sure this doesn't happen

That sniff found this so far.

Bug: T342297
Change-Id: Ibce3f3d28e7d2cb5b0ff7230f584e76446965ddc
2023-07-24 19:04:59 +02:00
Timo Tijhof
b4782b6672 UserEditTracker: Prefer getId() over isRegistered()
Regardless of how isTemp/isAnon/isRegistered unfold in relation
to IP Masking and Temp Users, the requirements of this particular
feature are solely about whether we have a row in the user table
to store the count, which depends on having a user ID.

It is up to higher-level business logic to decide whether and how
to access the information, but we don't need to repeat that 10x
at every turn internally.

Change-Id: I3eb6013cfd2e5eaa13b12146d97bd276fe517a04
2023-07-23 23:43:57 +00:00
Amir Sarabadani
b55c501fe0 Migrate Database::update() to UpdateQueryBuilder
I did this using a script written on top of antlr4 parser so it doesn't
have some clean ups a human would do but it's pretty nice already.

Bug: T330640
Change-Id: I608566700c6d737ee986bf47dda87effc69614d6
2023-06-08 12:34:20 +02:00
Umherirrender
49ad716948 Use User::isRegistered for readability instead of ::getId falsy check
Change-Id: I42aab149559e3e899cde6c77af76c66936ed0ef0
2022-04-29 21:15:57 +02:00
Tim Starling
960a7925ae Add hook UserEditCountUpdate
Add a hook which runs at the end of UserEditCountUpdate. The idea is to
allow CentralAuth to keep its own similar edit count. There's no
other hook appropriate for this purpose since
UserEditTracker::incrementUserEditCount() has multiple callers.

Convert the private associative array in UserEditCountUpdate to a class.
Instances of the class are passed to the new hook. A class is better
suited to a public interface.

Bug: T300075
Change-Id: I16a92e6a6e9faf1be4c7fbe25354a08559df163d
2022-01-31 17:00:49 +11:00
James D. Forrester
8426aacd96 ILoadBalancer: Rename waitForMasterPos to waitForPrimaryPos
Hard-deprecating immediately as no known users in git outside of this repo.

Bug: T282894
Change-Id: I5fa312ae89660a9c6de3c24e13d48de92893e5b0
2021-09-03 20:11:05 +00:00
DannyS712
5ca02c77b2 UserEditCountUpdate: only store a single UserIdentity object
No longer need to save more than one, which was previously
needed to be able to call User::setEditCountInternal(), but
that method has been removed.

It turns out we can't just rely on the user id alone, because
UserEditTracker requires a UserIdentity object and the name
of the user matters.

Follow-up:  Ie3fb4887d9f2d96b32598865030351bf3bf20ce5
Change-Id: I4ba1300837cf2cf624c563d4445a2a7dc6b88d86
2021-06-24 11:28:52 +00:00
DannyS712
b82cf00983 Remove User::$mEditCount and internal caching
UserEditTracker now returns null for anonymous users
instead of throwing an exception.

Added new UserEditTracker::setCachedUserEditCount()
method (internal) to handle the user_editcount field
in User::loadFromRow()'s row. This now means that
the creation of one User object can set the cached
value for any other object for the same underlying user
- the alternative (just ignoring the value) would mean
that an extra database read might be needed. This is
only used for users created with a row that includes
the user id - we silently discard the value if
the row doesn't have a user id (or the user id is 0)
to avoid issues with UserEditTracker trying to fetch
the user id and potentially triggering another load.

A follow-up will simplify the UserEditCountUpdate class
to remove storing full UserIdentity objects now that
only the id is needed.

Follow-up: Ibf1482bcbcbf4d56fc06531bb3e17e2a6e3e2e6f
Change-Id: Ie3fb4887d9f2d96b32598865030351bf3bf20ce5
2021-06-18 00:25:47 +00:00
Matěj Suchánek
ae7fa75b6a Fix documentation of UserEditCountUpdate::doUpdate
The original documentation was probably copied from somewhere else.
It never corresponded to what the method actually does.

Change-Id: I21491ec97cc24a36450466a090079f63402c8c1c
2021-06-16 22:48:56 +00:00
DannyS712
5a229f691f Accept UserIdentity in code to manage edit counts
- UserEditCountUpdate: accept UserIdentity instead of User
- Move User::incEditCount() to UserEditTracker

Change-Id: Ibf1482bcbcbf4d56fc06531bb3e17e2a6e3e2e6f
2021-06-08 05:41:03 +00:00
James D. Forrester
f2f9345e39 Replace uses of DB_MASTER with DB_PRIMARY in documentation and local variables
This is just a start.

Bug: T254646
Change-Id: I9213aad4660e27afe7ff9e5d2e730cbf03911068
2021-05-14 12:40:34 -07:00
James D. Forrester
df5eb22f83 Replace uses of DB_MASTER with DB_PRIMARY
Just an auto-replace from codesniffer for now.

Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
2021-04-29 09:24:31 -07:00
James D. Forrester
4f2d1efdda Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse
Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
2020-01-10 09:32:25 -08:00
Daimona Eaytoy
e7ee0bc0f5 Better docs to make phan happy
Change-Id: I8a9a6330cf1f889cbb77dfc28c93774204767323
2019-09-07 16:47:18 +00:00
Aaron Schulz
f72ae0f6e6 Switch various LoadBalancer::getConnection() callers to getConnectionRef()
This is the preferred method as it enforces read-only mode for DB_REPLICA
and handles LoadBalancer::reuseConnection() calls automatically.

Change-Id: Iab9439ba8e0810fa14c302661ed7a3534f6bfc0d
2019-07-12 10:56:30 -07:00
jenkins-bot
87193d29e9 Merge "Make UserEditCountUpdate::doUpdate avoid comparing IDatabase instances" 2019-07-02 21:57:10 +00:00
Aaron Schulz
08b0462fdc Make UserEditCountUpdate::doUpdate avoid comparing IDatabase instances
Also make User::initEditCountInternal take the specific DB handle that
was waited on for replication. This shouldn't make a difference but makes
things more explicit.

Change-Id: Ibb8e083406eb4f4453afce94a2b33450239fce94
2019-07-02 21:43:00 +00:00
Umherirrender
7016d1bb31 Pass column as string to IDatabase::selectField
To match documentation

Change-Id: I7ee69fcd90ba1cba947ca2ef205f350dc456a2c7
2019-06-30 00:01:21 +02:00
Aaron Schulz
6718d18339 rdbms: rename safeWaitForMasterPos() to waitForMasterPos() in ILoadBalancer
Change-Id: I2ad0c6f369ba992895a5306a57f1af16a772844c
2019-06-22 14:56:35 +00:00
Umherirrender
efe5761c93 build: Updating mediawiki/mediawiki-codesniffer to 23.0.0
Avoid use of __METHOD__ magic constant in closure

Change-Id: I28d519530ca2fcde026a6cbb419848098d4617ca
2018-12-01 23:11:16 +01:00
Aaron Schulz
e2088f1170 Make UserEditCountUpdate faster by using auto-commit mode
Bug: T202715
Change-Id: I92c08694cb5e1c367809439cff42e33a56ff9878
2018-10-27 13:52:45 -07:00
Aaron Schulz
390fce6db1 Move user_editcount updates to a mergeable deferred update
This should reduce excess contention and lock timeouts.
Previously, it used a pre-commit hook which ran just before the
end of the DB transaction round.

Also removed unused User::incEditCountImmediate() method.

Bug: T202715
Depends-on: I6d239a5ea286afb10d9e317b2ee1436de60f7e4f
Depends-on: I0ad3d17107efc7b0e59f1dd54d5733cd1572a2b7
Change-Id: I0d6d7ddd91bbb21995142808248d162e05696d47
2018-10-25 15:32:18 -07:00