mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +01:00
Save empty fields as no row, not an empty row
Summary: When a user stores the empty string in an auxiliary field, simply don't store it, and delete it if it already exists. Test Plan: Edited a revision with an empty "Quack" field, got an empty row in the DB. Applied patch, edited empty again, row went away. Edited empty again, still no row. Edited and put something in the field, got a row. Reviewers: jungejason, tuomaspelkonen, aran Reviewed By: jungejason CC: aran, jungejason Differential Revision: 865
This commit is contained in:
parent
99b9ceb6d7
commit
0334a92621
1 changed files with 16 additions and 8 deletions
|
@ -681,15 +681,23 @@ class DifferentialRevisionEditor {
|
|||
|
||||
foreach ($aux_map as $key => $val) {
|
||||
$obj = idx($fields, $key);
|
||||
if (!$obj) {
|
||||
$obj = new DifferentialAuxiliaryField();
|
||||
$obj->setRevisionPHID($revision->getPHID());
|
||||
$obj->setName($key);
|
||||
}
|
||||
if (!strlen($val)) {
|
||||
// If the new value is empty, just delete the old row if one exists and
|
||||
// don't add a new row if it doesn't.
|
||||
if ($obj) {
|
||||
$obj->delete();
|
||||
}
|
||||
} else {
|
||||
if (!$obj) {
|
||||
$obj = new DifferentialAuxiliaryField();
|
||||
$obj->setRevisionPHID($revision->getPHID());
|
||||
$obj->setName($key);
|
||||
}
|
||||
|
||||
if ($obj->getValue() !== $val) {
|
||||
$obj->setValue($val);
|
||||
$obj->save();
|
||||
if ($obj->getValue() !== $val) {
|
||||
$obj->setValue($val);
|
||||
$obj->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue