HomePhabricator

Fix edit counters for good

Authored by ashley on Mar 10 2020, 10:00 PM.

Description

Fix edit counters for good

Originally there was a seemingly simple bug here: edit counter code in EditCount.php was attempting
to use revision.rev_actor (but that doesn't exist yet) instead of revision_actor_temp.revactor_actor.
Fixing that...did nothing. Edit counts weren't increasing *or* decreasing as desired.
Why?

Because UserStatsTrack's constructor can be called with various things, either a User object, an actor ID or user ID + user name combo (legacy b/c) or even user ID + empty string (weird legacy special case).
When it was called with an actor ID, the call to User#loadFromDatabase would end up
returning outright nonsense since actor IDs are not user IDs and User#loadFromDatabase apparently
needs to have mId set so that it will work properly.

Changed all such dodgy calls to User#loadFromDatabase to User#load.
The one remaining call in RandomUsersWithAvatars is fine because 1) only registered users can have
avatars (d'oh) and 2) the UID is hard-coded into avatar image file names anyway, so getting it from
such a file name, passing it onto User#newFromId and calling User#loadFromDatabase on the object is
totally fine as User::$mId will be populated by then.

Also fixed a bug (undefined variable) in UserRelationship#sendRelationshipRemoveEmail and adjusted
the doc comment for UserRelationship#sendRelationshipRequestEmail as well.

Change-Id: Ib612b4ce5fdcebcd47836d58ea10c28110e70405
Follow-up: cd2dbcf8171bb7e81f22845b60b62b4320a9251c
Bug: T247184