mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Fix incorrect construction of subtype map when validating "subtype" transactions against non-subtypable objects
Summary: Fixes T13389. Currently, we try to "newSubtypeMap()" unconditionally, even if the underlying object does not support subtypes. - Only try to build a subtype map if subtype transactions are actually being applied. - When subtype transactions are applied to a non-subtypable object, fail more explicitly. Test Plan: Clicked "Make Editable" in a fresh Calendar transaction form, got an editable form instead of a fatal from "newSubtypeMap()". (Calendar events are not currently subtypable.) Maniphest Tasks: T13389 Differential Revision: https://secure.phabricator.com/D20741
This commit is contained in:
parent
7198bd7db7
commit
0943561dcb
1 changed files with 21 additions and 2 deletions
|
@ -25,11 +25,30 @@ final class PhabricatorEditEngineSubtypeTransaction
|
|||
}
|
||||
|
||||
public function validateTransactions($object, array $xactions) {
|
||||
$map = $object->getEngine()
|
||||
$errors = array();
|
||||
|
||||
if (!$xactions) {
|
||||
return $errors;
|
||||
}
|
||||
|
||||
$engine = $object->getEngine();
|
||||
|
||||
if (!$engine->supportsSubtypes()) {
|
||||
foreach ($xactions as $xaction) {
|
||||
$errors[] = $this->newInvalidError(
|
||||
pht(
|
||||
'Edit engine (of class "%s") does not support subtypes, so '.
|
||||
'subtype transactions can not be applied to it.',
|
||||
get_class($engine)),
|
||||
$xaction);
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
$map = $engine
|
||||
->setViewer($this->getActor())
|
||||
->newSubtypeMap();
|
||||
|
||||
$errors = array();
|
||||
foreach ($xactions as $xaction) {
|
||||
$new = $xaction->getNewValue();
|
||||
|
||||
|
|
Loading…
Reference in a new issue