mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Flatten "RemarkupValue" objects when setting field defaults for custom forms
Summary: Ref T13685. "RemarkupEditField" uses a "RemarkupValue" internally, and it currently attempts to serialize into the database unsuccessfully. Instead, flatten the value before returning it for storage. Test Plan: - Edited the default description of a task in a custom form. Maniphest Tasks: T13685 Differential Revision: https://secure.phabricator.com/D21854
This commit is contained in:
parent
1fc04e238f
commit
9426765a2c
2 changed files with 27 additions and 1 deletions
|
@ -29,6 +29,32 @@ final class PhabricatorRemarkupEditField
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getValueForDefaults() {
|
||||||
|
$value = parent::getValueForDefaults();
|
||||||
|
|
||||||
|
if ($value instanceof RemarkupValue) {
|
||||||
|
$value = $value->getCorpus();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getDefaultValueFromConfiguration($value) {
|
||||||
|
|
||||||
|
// See T13685. After changes to file attachment handling, the database
|
||||||
|
// was briefly poisoned with "array()" values as defaults.
|
||||||
|
|
||||||
|
try {
|
||||||
|
$value = phutil_string_cast($value);
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
$value = '';
|
||||||
|
} catch (Throwable $ex) {
|
||||||
|
$value = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
public function getMetadata() {
|
public function getMetadata() {
|
||||||
$defaults = array();
|
$defaults = array();
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ class AphrontFormTextAreaControl extends AphrontFormControl {
|
||||||
|
|
||||||
// NOTE: This needs to be string cast, because if we pass `null` the
|
// NOTE: This needs to be string cast, because if we pass `null` the
|
||||||
// tag will be self-closed and some browsers aren't thrilled about that.
|
// tag will be self-closed and some browsers aren't thrilled about that.
|
||||||
$value = (string)$this->getValue();
|
$value = phutil_string_cast($this->getValue());
|
||||||
|
|
||||||
// NOTE: We also need to prefix the string with a newline, because browsers
|
// NOTE: We also need to prefix the string with a newline, because browsers
|
||||||
// ignore a newline immediately after a <textarea> tag, so they'll eat
|
// ignore a newline immediately after a <textarea> tag, so they'll eat
|
||||||
|
|
Loading…
Reference in a new issue