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
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
- UserEditCountUpdate: accept UserIdentity instead of User
- Move User::incEditCount() to UserEditTracker
Change-Id: Ibf1482bcbcbf4d56fc06531bb3e17e2a6e3e2e6f
* 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
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
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