From c176a3038a4b3ac5ab244ae41591700785526428 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 27 Apr 2020 13:12:05 -0700 Subject: [PATCH] (stable) Make omitting "value" from a transaction description an explicit error Summary: See PHI1710. Until D21044, some transactions could omit "value" and apply correctly. This now throws an exception when accessing `$xaction['value']`. All transactions are expected to have a "value" key, so require it explicitly rather than implicitly. Test Plan: Submitted a transaction with a "type" but no "value". After D21044, got a language-level exception. After this change, got an explicit exception. Differential Revision: https://secure.phabricator.com/D21176 --- .../transactions/editengine/PhabricatorEditEngine.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php index 89f23845b7..1bafb92449 100644 --- a/src/applications/transactions/editengine/PhabricatorEditEngine.php +++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php @@ -2204,6 +2204,16 @@ abstract class PhabricatorEditEngine $transactions_key, $key)); } + + if (!array_key_exists('value', $xaction)) { + throw new Exception( + pht( + 'Parameter "%s" must contain a list of transaction descriptions, '. + 'but item with key "%s" is missing a "value" field. Each '. + 'transaction must have a value field.', + $transactions_key, + $key)); + } } return $xactions;