@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow PhabricatorUserLog to store non-user PHIDs

Summary:
Ref T4310. This is a small step toward separating out the session code so we can establish sessions for `ExternalAccount` and not just `User`.

Also fix an issue with strict MySQL and un-admin / un-disable from web UI.

Test Plan: Logged in, logged out, admined/de-admin'd user, added email address, checked user log for all those events.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T4310

Differential Revision: https://secure.phabricator.com/D7953

+38 -45
+2 -2
src/applications/auth/controller/PhabricatorLogoutController.php
··· 23 23 24 24 if ($request->isFormPost()) { 25 25 26 - $log = PhabricatorUserLog::newLog( 27 - $user, 26 + $log = PhabricatorUserLog::initializeNewLog( 28 27 $user, 28 + $user->getPHID(), 29 29 PhabricatorUserLog::ACTION_LOGOUT); 30 30 $log->save(); 31 31
+2 -2
src/applications/auth/provider/PhabricatorAuthProviderPassword.php
··· 185 185 } 186 186 187 187 if (!$account) { 188 - $log = PhabricatorUserLog::newLog( 188 + $log = PhabricatorUserLog::initializeNewLog( 189 189 null, 190 - $log_user, 190 + $log_user ? $log_user->getPHID() : null, 191 191 PhabricatorUserLog::ACTION_LOGIN_FAILURE); 192 192 $log->save(); 193 193
+2 -2
src/applications/people/controller/PhabricatorPeopleEditController.php
··· 356 356 357 357 if ($request->isFormPost()) { 358 358 359 - $log_template = PhabricatorUserLog::newLog( 359 + $log_template = PhabricatorUserLog::initializeNewLog( 360 360 $admin, 361 - $user, 361 + $user->getPHID(), 362 362 null); 363 363 364 364 $logs = array();
+26 -26
src/applications/people/editor/PhabricatorUserEditor.php
··· 64 64 throw $ex; 65 65 } 66 66 67 - $log = PhabricatorUserLog::newLog( 67 + $log = PhabricatorUserLog::initializeNewLog( 68 68 $this->requireActor(), 69 - $user, 69 + $user->getPHID(), 70 70 PhabricatorUserLog::ACTION_CREATE); 71 71 $log->setNewValue($email->getAddress()); 72 72 $log->save(); ··· 93 93 $email->save(); 94 94 } 95 95 96 - $log = PhabricatorUserLog::newLog( 96 + $log = PhabricatorUserLog::initializeNewLog( 97 97 $this->requireActor(), 98 - $user, 98 + $user->getPHID(), 99 99 PhabricatorUserLog::ACTION_EDIT); 100 100 $log->save(); 101 101 ··· 122 122 $user->setPassword($envelope); 123 123 $user->save(); 124 124 125 - $log = PhabricatorUserLog::newLog( 125 + $log = PhabricatorUserLog::initializeNewLog( 126 126 $this->requireActor(), 127 - $user, 127 + $user->getPHID(), 128 128 PhabricatorUserLog::ACTION_CHANGE_PASSWORD); 129 129 $log->save(); 130 130 ··· 161 161 throw $ex; 162 162 } 163 163 164 - $log = PhabricatorUserLog::newLog( 164 + $log = PhabricatorUserLog::initializeNewLog( 165 165 $actor, 166 - $user, 166 + $user->getPHID(), 167 167 PhabricatorUserLog::ACTION_CHANGE_USERNAME); 168 168 $log->setOldValue($old_username); 169 169 $log->setNewValue($username); ··· 198 198 return $this; 199 199 } 200 200 201 - $log = PhabricatorUserLog::newLog( 201 + $log = PhabricatorUserLog::initializeNewLog( 202 202 $actor, 203 - $user, 203 + $user->getPHID(), 204 204 PhabricatorUserLog::ACTION_ADMIN); 205 205 $log->setOldValue($user->getIsAdmin()); 206 206 $log->setNewValue($admin); 207 207 208 - $user->setIsAdmin($admin); 208 + $user->setIsAdmin((int)$admin); 209 209 $user->save(); 210 210 211 211 $log->save(); ··· 236 236 return $this; 237 237 } 238 238 239 - $log = PhabricatorUserLog::newLog( 239 + $log = PhabricatorUserLog::initializeNewLog( 240 240 $actor, 241 - $user, 241 + $user->getPHID(), 242 242 PhabricatorUserLog::ACTION_SYSTEM_AGENT); 243 243 $log->setOldValue($user->getIsSystemAgent()); 244 244 $log->setNewValue($system_agent); ··· 275 275 return $this; 276 276 } 277 277 278 - $log = PhabricatorUserLog::newLog( 278 + $log = PhabricatorUserLog::initializeNewLog( 279 279 $actor, 280 - $user, 280 + $user->getPHID(), 281 281 PhabricatorUserLog::ACTION_DISABLE); 282 282 $log->setOldValue($user->getIsDisabled()); 283 283 $log->setNewValue($disable); 284 284 285 - $user->setIsDisabled($disable); 285 + $user->setIsDisabled((int)$disable); 286 286 $user->save(); 287 287 288 288 $log->save(); ··· 314 314 return $this; 315 315 } 316 316 317 - $log = PhabricatorUserLog::newLog( 317 + $log = PhabricatorUserLog::initializeNewLog( 318 318 $actor, 319 - $user, 319 + $user->getPHID(), 320 320 PhabricatorUserLog::ACTION_APPROVE); 321 321 $log->setOldValue($user->getIsApproved()); 322 322 $log->setNewValue($approve); ··· 382 382 $email->delete(); 383 383 } 384 384 385 - $log = PhabricatorUserLog::newLog( 385 + $log = PhabricatorUserLog::initializeNewLog( 386 386 $actor, 387 - $user, 387 + $user->getPHID(), 388 388 PhabricatorUserLog::ACTION_DELETE); 389 389 $log->save(); 390 390 ··· 435 435 throw $ex; 436 436 } 437 437 438 - $log = PhabricatorUserLog::newLog( 438 + $log = PhabricatorUserLog::initializeNewLog( 439 439 $actor, 440 - $user, 440 + $user->getPHID(), 441 441 PhabricatorUserLog::ACTION_EMAIL_ADD); 442 442 $log->setNewValue($email->getAddress()); 443 443 $log->save(); ··· 480 480 481 481 $email->delete(); 482 482 483 - $log = PhabricatorUserLog::newLog( 483 + $log = PhabricatorUserLog::initializeNewLog( 484 484 $actor, 485 - $user, 485 + $user->getPHID(), 486 486 PhabricatorUserLog::ACTION_EMAIL_REMOVE); 487 487 $log->setOldValue($email->getAddress()); 488 488 $log->save(); ··· 536 536 $email->setIsPrimary(1); 537 537 $email->save(); 538 538 539 - $log = PhabricatorUserLog::newLog( 539 + $log = PhabricatorUserLog::initialieNewLog( 540 540 $actor, 541 - $user, 541 + $user->getPHID(), 542 542 PhabricatorUserLog::ACTION_EMAIL_PRIMARY); 543 543 $log->setOldValue($old_primary ? $old_primary->getAddress() : null); 544 544 $log->setNewValue($email->getAddress());
+2 -2
src/applications/people/storage/PhabricatorUser.php
··· 431 431 } 432 432 } 433 433 434 - $log = PhabricatorUserLog::newLog( 435 - $this, 434 + $log = PhabricatorUserLog::initializeNewLog( 436 435 $this, 436 + $this->getPHID(), 437 437 PhabricatorUserLog::ACTION_LOGIN); 438 438 $log->setDetails( 439 439 array(
+4 -11
src/applications/people/storage/PhabricatorUserLog.php
··· 35 35 protected $remoteAddr; 36 36 protected $session; 37 37 38 - public static function newLog( 38 + public static function initializeNewLog( 39 39 PhabricatorUser $actor = null, 40 - PhabricatorUser $user = null, 40 + $object_phid, 41 41 $action) { 42 42 43 43 $log = new PhabricatorUserLog(); ··· 46 46 $log->setActorPHID($actor->getPHID()); 47 47 } 48 48 49 - if ($user) { 50 - $log->setUserPHID($user->getPHID()); 51 - } else { 52 - $log->setUserPHID(''); 53 - } 54 - 55 - if ($action) { 56 - $log->setAction($action); 57 - } 49 + $log->setUserPHID((string)$object_phid); 50 + $log->setAction($action); 58 51 59 52 return $log; 60 53 }