mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Make AuthProvider, ExternalAccount, and ExternalAccountIdentifier all Destructible
Summary: Depends on D21014. Ref T13493. Make these objects all use destructible interfaces and destroy sub-objects appropriately. Test Plan: - Used `bin/remove destroy --trace ...` to destroy a provider, a user, and an external account. - Observed destruction of sub-objects, including external account identifiers. Maniphest Tasks: T13493 Differential Revision: https://secure.phabricator.com/D21015
This commit is contained in:
parent
05eb16d6de
commit
0872051bfa
6 changed files with 82 additions and 9 deletions
|
@ -8758,6 +8758,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorAuthDAO',
|
||||
'PhabricatorApplicationTransactionInterface',
|
||||
'PhabricatorPolicyInterface',
|
||||
'PhabricatorDestructibleInterface',
|
||||
),
|
||||
'PhabricatorAuthProviderConfigController' => 'PhabricatorAuthProviderController',
|
||||
'PhabricatorAuthProviderConfigEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
|
@ -9765,10 +9766,12 @@ phutil_register_library_map(array(
|
|||
'PhabricatorExternalAccount' => array(
|
||||
'PhabricatorUserDAO',
|
||||
'PhabricatorPolicyInterface',
|
||||
'PhabricatorDestructibleInterface',
|
||||
),
|
||||
'PhabricatorExternalAccountIdentifier' => array(
|
||||
'PhabricatorUserDAO',
|
||||
'PhabricatorPolicyInterface',
|
||||
'PhabricatorDestructibleInterface',
|
||||
),
|
||||
'PhabricatorExternalAccountIdentifierQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhabricatorExternalAccountQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
|
|
|
@ -4,7 +4,8 @@ final class PhabricatorAuthProviderConfig
|
|||
extends PhabricatorAuthDAO
|
||||
implements
|
||||
PhabricatorApplicationTransactionInterface,
|
||||
PhabricatorPolicyInterface {
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorDestructibleInterface {
|
||||
|
||||
protected $providerClass;
|
||||
protected $providerType;
|
||||
|
@ -140,4 +141,33 @@ final class PhabricatorAuthProviderConfig
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorDestructibleInterface )----------------------------------- */
|
||||
|
||||
|
||||
public function destroyObjectPermanently(
|
||||
PhabricatorDestructionEngine $engine) {
|
||||
|
||||
$viewer = $engine->getViewer();
|
||||
$config_phid = $this->getPHID();
|
||||
|
||||
$accounts = id(new PhabricatorExternalAccountQuery())
|
||||
->setViewer($viewer)
|
||||
->withProviderConfigPHIDs(array($config_phid))
|
||||
->newIterator();
|
||||
foreach ($accounts as $account) {
|
||||
$engine->destroyObject($account);
|
||||
}
|
||||
|
||||
$identifiers = id(new PhabricatorExternalAccountIdentifierQuery())
|
||||
->setViewer($viewer)
|
||||
->withProviderConfigPHIDs(array($config_phid))
|
||||
->newIterator();
|
||||
foreach ($identifiers as $identifier) {
|
||||
$engine->destroyObject($identifier);
|
||||
}
|
||||
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorExternalAccount extends PhabricatorUserDAO
|
||||
implements PhabricatorPolicyInterface {
|
||||
final class PhabricatorExternalAccount
|
||||
extends PhabricatorUserDAO
|
||||
implements
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorDestructibleInterface {
|
||||
|
||||
protected $userPHID;
|
||||
protected $accountType;
|
||||
|
@ -162,4 +165,24 @@ final class PhabricatorExternalAccount extends PhabricatorUserDAO
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorDestructibleInterface )----------------------------------- */
|
||||
|
||||
|
||||
public function destroyObjectPermanently(
|
||||
PhabricatorDestructionEngine $engine) {
|
||||
|
||||
$viewer = $engine->getViewer();
|
||||
|
||||
$identifiers = id(new PhabricatorExternalAccountIdentifierQuery())
|
||||
->setViewer($viewer)
|
||||
->withExternalAccountPHIDs(array($this->getPHID()))
|
||||
->newIterator();
|
||||
foreach ($identifiers as $identifier) {
|
||||
$engine->destroyObject($identifier);
|
||||
}
|
||||
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
final class PhabricatorExternalAccountIdentifier
|
||||
extends PhabricatorUserDAO
|
||||
implements PhabricatorPolicyInterface {
|
||||
implements
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorDestructibleInterface {
|
||||
|
||||
protected $externalAccountPHID;
|
||||
protected $providerConfigPHID;
|
||||
|
@ -64,4 +66,13 @@ final class PhabricatorExternalAccountIdentifier
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorDestructibleInterface )----------------------------------- */
|
||||
|
||||
|
||||
public function destroyObjectPermanently(
|
||||
PhabricatorDestructionEngine $engine) {
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1110,19 +1110,21 @@ final class PhabricatorUser
|
|||
public function destroyObjectPermanently(
|
||||
PhabricatorDestructionEngine $engine) {
|
||||
|
||||
$viewer = $engine->getViewer();
|
||||
|
||||
$this->openTransaction();
|
||||
$this->delete();
|
||||
|
||||
$externals = id(new PhabricatorExternalAccountQuery())
|
||||
->setViewer($engine->getViewer())
|
||||
->setViewer($viewer)
|
||||
->withUserPHIDs(array($this->getPHID()))
|
||||
->execute();
|
||||
->newIterator();
|
||||
foreach ($externals as $external) {
|
||||
$external->delete();
|
||||
$engine->destroyObject($external);
|
||||
}
|
||||
|
||||
$prefs = id(new PhabricatorUserPreferencesQuery())
|
||||
->setViewer($engine->getViewer())
|
||||
->setViewer($viewer)
|
||||
->withUsers(array($this))
|
||||
->execute();
|
||||
foreach ($prefs as $pref) {
|
||||
|
@ -1137,7 +1139,7 @@ final class PhabricatorUser
|
|||
}
|
||||
|
||||
$keys = id(new PhabricatorAuthSSHKeyQuery())
|
||||
->setViewer($engine->getViewer())
|
||||
->setViewer($viewer)
|
||||
->withObjectPHIDs(array($this->getPHID()))
|
||||
->execute();
|
||||
foreach ($keys as $key) {
|
||||
|
|
|
@ -359,6 +359,10 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
|
|||
return $results;
|
||||
}
|
||||
|
||||
final public function newIterator() {
|
||||
return new PhabricatorQueryIterator($this);
|
||||
}
|
||||
|
||||
final public function executeWithCursorPager(AphrontCursorPagerView $pager) {
|
||||
$limit = $pager->getPageSize();
|
||||
|
||||
|
|
Loading…
Reference in a new issue