From c2565d5e24371e4ece74ffbd7a21f5d55210f796 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 3 Nov 2016 13:38:06 -0700 Subject: [PATCH] Fix a bug with creating Phortune merchant accounts without applying an email address transaction and some null field issues Summary: When Phortune merchant accounts are created via mechanisms other than the web UI (for example, by Phacility unit tests) this validation check may fail. Transactions are validated even if no transactions of the given type are being applied, to allow the editor to raise errors like "Name is required!". If there's no TYPE_INVOICEEMAIL transaction, we'll get called with empty `$xactions` and fail on `strlen($new_email)` because the variable is never defined. As a secondary issue, if contactInfo, invoiceEmail or invoiceFooter are not provided the record will fail to insert (none of these are nullable). Test Plan: Ran Phacility unit tests, got a clean result for new instance creation. Reviewers: chad Reviewed By: chad Differential Revision: https://secure.phabricator.com/D16798 --- src/applications/phortune/editor/PhortuneMerchantEditor.php | 1 + src/applications/phortune/storage/PhortuneMerchant.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/applications/phortune/editor/PhortuneMerchantEditor.php b/src/applications/phortune/editor/PhortuneMerchantEditor.php index e2db3688e7..53fc7c94f2 100644 --- a/src/applications/phortune/editor/PhortuneMerchantEditor.php +++ b/src/applications/phortune/editor/PhortuneMerchantEditor.php @@ -134,6 +134,7 @@ final class PhortuneMerchantEditor } break; case PhortuneMerchantTransaction::TYPE_INVOICEEMAIL: + $new_email = null; foreach ($xactions as $xaction) { switch ($xaction->getTransactionType()) { case PhortuneMerchantTransaction::TYPE_INVOICEEMAIL: diff --git a/src/applications/phortune/storage/PhortuneMerchant.php b/src/applications/phortune/storage/PhortuneMerchant.php index a57e5bd69e..69675c2ebc 100644 --- a/src/applications/phortune/storage/PhortuneMerchant.php +++ b/src/applications/phortune/storage/PhortuneMerchant.php @@ -19,7 +19,10 @@ final class PhortuneMerchant extends PhortuneDAO public static function initializeNewMerchant(PhabricatorUser $actor) { return id(new PhortuneMerchant()) ->setViewPolicy(PhabricatorPolicies::getMostOpenPolicy()) - ->attachMemberPHIDs(array()); + ->attachMemberPHIDs(array()) + ->setContactInfo('') + ->setInvoiceEmail('') + ->setInvoiceFooter(''); } protected function getConfiguration() {