When destroying an object, also remove all associated flags and tokens.
Details
- Reviewers
epriestley - Group Reviewers
Blessed Reviewers - Commits
- Restricted Diffusion Commit
rP0b87e462cd70: Remove flags and tokens upon object destruction
Awarded a Maniphest task with a token and flagged it as well. Destroyed it with ./bin/remove destroy and saw flag and token removed from the database.
Diff Detail
- Repository
- rP Phabricator
- Branch
- master
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 6449 Build 6471: [Placeholder Plan] Wait for 30 Seconds
Event Timeline
One thing I think we don't handle is if a user is being deleted, we won't nuke the flags/tokens of that user.
src/applications/system/engine/PhabricatorDestructionEngine.php | ||
---|---|---|
82 | Is there any reason to use PhabricatorTokenGivenQuery here? |
src/applications/system/engine/PhabricatorDestructionEngine.php | ||
---|---|---|
82 | There's an argument against using it: some types of Queries require related objects to exist, even if querying with the Omnipotent viewer. For example, TransactionQuery classes refuse to load transactions if the objects aren't loadable, even if the rows exist. The general idea is that the overwhelming majority of application code is way simpler if it doesn't need to check that every object is complete/valid, and we normally can't policy check these objects anyway. In this case we need to load those "broken/invalid" rows, so destroyTransactions() queries the database directly instead of using an appropriate Query class. It looks like TokenGivenQuery has similar logic, and refuses to load tokens if the objects don't load, so I would expect it to never "see" any tokens (since we just destroyed their objects). There are at least two reasons why this might be bad:
|
src/applications/system/engine/PhabricatorDestructionEngine.php | ||
---|---|---|
82 | In the case of a large result set, probably it would be better to just use queryfx to DELETE FROM %T WHERE objectPHID = %s? |
src/applications/system/engine/PhabricatorDestructionEngine.php | ||
---|---|---|
82 | Yeah, but only if we're certain delete() has no other logic and that we'll definitely remember to fix this if it ever does. In the general case, some delete() methods do something. |