diff --git a/src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php b/src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php --- a/src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php +++ b/src/applications/oauthserver/storage/PhabricatorOAuthServerClient.php @@ -2,7 +2,9 @@ final class PhabricatorOAuthServerClient extends PhabricatorOAuthServerDAO - implements PhabricatorPolicyInterface { + implements + PhabricatorPolicyInterface, + PhabricatorDestructibleInterface { protected $secret; protected $name; @@ -89,4 +91,33 @@ return null; } +/* -( PhabricatorDestructibleInterface )----------------------------------- */ + + public function destroyObjectPermanently( + PhabricatorDestructionEngine $engine) { + + $this->openTransaction(); + $this->delete(); + + $authorizations = id(new PhabricatorOAuthClientAuthorization()) + ->loadAllWhere('clientPHID = %s', $this->getPHID()); + foreach ($authorizations as $authorization) { + $authorization->delete(); + } + + $tokens = id(new PhabricatorOAuthServerAccessToken()) + ->loadAllWhere('clientPHID = %s', $this->getPHID()); + foreach ($tokens as $token) { + $token->delete(); + } + + $codes = id(new PhabricatorOAuthServerAuthorizationCode()) + ->loadAllWhere('clientPHID = %s', $this->getPHID()); + foreach ($codes as $code) { + $code->delete(); + } + + $this->saveTransaction(); + + } }