Commit graph

13 commits

Author SHA1 Message Date
jenkins-bot
dd8ff26758 Merge "Start clean up of revision_actor_temp table" 2022-05-23 16:54:28 +00:00
Amir Sarabadani
24115a8f4c Start clean up of revision_actor_temp table
It is being dropped in production

Bug: T215466
Change-Id: I66b2cb8653252e720c897351065978119f040ba7
2022-05-23 15:37:42 +00:00
Umherirrender
49ad716948 Use User::isRegistered for readability instead of ::getId falsy check
Change-Id: I42aab149559e3e899cde6c77af76c66936ed0ef0
2022-04-29 21:15:57 +02:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
Tim Starling
d3d8dc9965 Schema migration for revison_actor_temp table removal
Introduce a new schema migration stage in which rev_actor is used
directly and the revision_actor_temp table is no longer needed. This
becomes the new "new" stage whereas the previous situation is now
termed SCHEMA_COMPAT_TEMP.

Introduce migrateRevisionActorTemp which copies data from
revision_actor_temp to rev_actor. The code is similar to
migrateImageCommentTemp.php except that it doesn't delete from the old
table.

Partial revert of c29909e59f. That change removed direct
references to $wgActorTableSchemaMigrationStage and made queries
involving revision_actor_temp be unconditional. Such changes need to be
reverted to make the use of revision_actor_temp be conditional again.

In ActorMigrationTest, I compacted provideGetJoin() and
provideGetWhere(), removing most of the duplication between expected
values. I gave all the stages a short name, and mostly used the name in
providers.

Bug: T275246
Change-Id: I7498107dd6433ab7de5bf2e7b3fe2aa5e10e345d
2021-07-14 08:29:04 +10:00
jenkins-bot
f2877a80ba Merge "Add and fix various type hints in PHPDocs" 2021-06-18 21:14:30 +00:00
Thiemo Kreuz
51777ee8c1 Add and fix various type hints in PHPDocs
Random fixes I collected the past weeks in my local dev
environment.

Change-Id: Ic8a6262fd28e05cb57335f2faf390a47ff97dbaa
2021-06-18 08:19:23 +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
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
Timo Tijhof
45dff9dfff UserEditTracker: Minor code clean up and follow-ups
* Remove ILoadBalancer from UserEditCountInitJob constructor,
  since it is not a parameter and not a Job property.
  It is not needed during Job construction.

* Use ConvertibleTimestamp instead of MWTimestamp since no
  MW-specific methods or behaviours are needed here.

* I don't know if UserEditCountInitJob is always safe to de-duplicate,
  but this should be decided in the Job class, and is not the
  responsibility of calling code that creates/queues a job.
  I don't know for sure why this is publicly part of JobSpecification,
  but I guess it is there for internal use when serialising jobs,
  not for external use in the way it was used here.

  I'm assuming for now that its use means it is safe and I moved it to the
  UserEditCountInitJob class. If this is not the case and de-dupability is
  actually dependent on the parameters, then that logic should reside
  in the UserEditCountInitJob constructor.

* Document for which internal use clearUserEditCache() is public.
  This way during refactoring the method can be easily found and
  made private if that caller is no longer needed.

* Remove needless Job::factory() indirection in the
  UserEditCountInitJob test suite. This added overhead that is not
  part of the test's purpose, and also risks making the test break
  because Job::factory() allows types to be mapped to different
  implementations. But, this test suite is meant to cover the
  UserEditCountInitJob class implementation specifically.

Change-Id: I6fef4d297b1c0169f95906822e30b4addab7eaf4
2020-09-18 02:21:11 +00:00
Máté Szabó
90c2840cca UserEditTracker: Do not try to initialize edit count in read-only mode
The method UserEditTracker::getUserEditCount (as well as the old User class
logic it replaced) calculates the user's edit count and writes it to the
database if it was not computed yet. However, it attempts this write even if
MediaWiki is in read-only mode, causing errors as this method is frequently
called on read requests as well.

As a fix, move the edit count initialization to the job queue, which will avoid
trying to open a source DB connection (and thus cause a read-only error) on
installs that do not use the DB-based job queue. This change requires a
workaround in UserGroupManagerTest.

Bug: T259719
Change-Id: I6d1c8e9038ae1f98f47bdb2495aecc21654b24c0
2020-08-06 00:50:41 +02:00
Umherirrender
bc5cb7ae64 phan: Enable redundant_condition_detection
Remove duplicate casts
Suppress false positives

Bug: T248438
Change-Id: I2f89664a4bcd3b39b15e7cf850adda2f0c90ae6f
2020-07-01 20:13:07 +00:00
DannyS712
1ccf066380 Add a new UserEditTracker service for user edit counts and timing
Moved to the new service are the following User:: methods:
* ::getEditCount
* ::getFirstEditTimestamp
* ::getLatestEditTimestamp
* ::getEditTimestamp
* ::initEditCountInternal

A subsequent patch will replace existing uses in core and deprecate the
User methods.

The new service has 100% test coverage with pure Unit tests.

Bug: T253431
Change-Id: If96f9d41026aa358c0fe269a3e078af5f6f058f2
2020-06-02 03:00:05 +00:00