mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20:56 +01:00
Fix an issue with editing pre-space objects using a form with no visibility controls
Summary: WMF ran into this after their update. Here's the setup: - When you enable Spaces, we leave all existing objects set to `null`, which means "these belong to the default space". This is so we don't have to go update a trillion objects. - New objects get set to the default space explicitly (`PHID-SPCE-...`) but older ones stay with `null`. - If you edit an older object (like a task) from the time before Spaces, //and// the form doesn't have a Visbility/Spaces control, we would incorrectly poplate the value with `null` when the effective value should be the default space PHID. - This caused a "You must choose a space." error in the UI. Instead, populate the control with the effective value instead of the literal database value. This makes the edit go through cleanly. Also add a note about this for future-me. Test Plan: - Disabled "Visibility" control in task edit form. - Edited an old task which had `null` as a `spacePHID` in the database. - Before patch: UI error about selecting a Space. - After patch: edit goes through cleanly. Reviewers: chad, 20after4 Reviewed By: chad, 20after4 Subscribers: 20after4, aklapper Differential Revision: https://secure.phabricator.com/D15306
This commit is contained in:
parent
dc7d0b4a56
commit
af1fef242c
2 changed files with 9 additions and 1 deletions
|
@ -101,6 +101,9 @@ final class PhabricatorPolicyEditEngineExtension
|
|||
if ($capability == PhabricatorPolicyCapability::CAN_VIEW) {
|
||||
$type_space = PhabricatorTransactions::TYPE_SPACE;
|
||||
if (isset($types[$type_space])) {
|
||||
$space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID(
|
||||
$object);
|
||||
|
||||
$space_field = id(new PhabricatorSpaceEditField())
|
||||
->setKey('spacePHID')
|
||||
->setLabel(pht('Space'))
|
||||
|
@ -114,7 +117,7 @@ final class PhabricatorPolicyEditEngineExtension
|
|||
->setConduitDescription(
|
||||
pht('Shift the object between spaces.'))
|
||||
->setConduitTypeDescription(pht('New space PHID.'))
|
||||
->setValue($object->getSpacePHID());
|
||||
->setValue($space_phid);
|
||||
$fields[] = $space_field;
|
||||
|
||||
$space_field->setPolicyField($policy_field);
|
||||
|
|
|
@ -527,6 +527,11 @@ abstract class PhabricatorApplicationTransaction
|
|||
// TODO: Remove this eventually, this is handling old changes during
|
||||
// object creation prior to the introduction of "create" and "default"
|
||||
// transaction display flags.
|
||||
|
||||
// NOTE: We can also hit this case with Space transactions that later
|
||||
// update a default space (`null`) to an explicit space, so handling
|
||||
// the Space case may require some finesse.
|
||||
|
||||
if ($this->getOldValue() === null) {
|
||||
return true;
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue