@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+21 -2
+21 -2
src/applications/transactions/xaction/PhabricatorEditEngineSubtypeTransaction.php
··· 25 25 } 26 26 27 27 public function validateTransactions($object, array $xactions) { 28 - $map = $object->getEngine() 28 + $errors = array(); 29 + 30 + if (!$xactions) { 31 + return $errors; 32 + } 33 + 34 + $engine = $object->getEngine(); 35 + 36 + if (!$engine->supportsSubtypes()) { 37 + foreach ($xactions as $xaction) { 38 + $errors[] = $this->newInvalidError( 39 + pht( 40 + 'Edit engine (of class "%s") does not support subtypes, so '. 41 + 'subtype transactions can not be applied to it.', 42 + get_class($engine)), 43 + $xaction); 44 + } 45 + return $errors; 46 + } 47 + 48 + $map = $engine 29 49 ->setViewer($this->getActor()) 30 50 ->newSubtypeMap(); 31 51 32 - $errors = array(); 33 52 foreach ($xactions as $xaction) { 34 53 $new = $xaction->getNewValue(); 35 54