From ec552bb6e9007f58dda98cbd23dc86edd931efb6 Mon Sep 17 00:00:00 2001 From: Benn Oshrin Date: Wed, 27 Feb 2019 11:27:17 -0500 Subject: [PATCH] Fix handling of Update Match Attributes Request (CO-1714) --- app/src/Lib/Match/MatchService.php | 13 ++++++++++--- app/src/Model/Table/AttributesTable.php | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/src/Lib/Match/MatchService.php b/app/src/Lib/Match/MatchService.php index 286b4f735..3df78e176 100644 --- a/app/src/Lib/Match/MatchService.php +++ b/app/src/Lib/Match/MatchService.php @@ -630,8 +630,15 @@ protected function update(int $rowid, AttributeManager $attributes, string $refe // We don't update request time $resolutionTime = ($referenceId ? gmdate('Y-m-d H:i:s') : null); - $attrs = ['referenceid', 'resolution_time']; - $vals = [$referenceId, $resolutionTime]; + $attrs = []; + $vals = []; + + if($referenceId) { + // If we don't have a referenceId, we're probably updating an existing record + // (Update Match Attributes). + $attrs = ['referenceid', 'resolution_time']; + $vals = [$referenceId, $resolutionTime]; + } // Walk the list of configured attributes and build a list, but only if attributes // were provided in the request. (eg: Reassign Reference Identifier does not require @@ -738,7 +745,7 @@ protected function upsert(string $sor, string $sorid, AttributeManager $attribut $this->dbc->completeTrans(); } catch(\Exception $e) { - $dbh->failTrans(); + $this->dbc->failTrans(); Log::write('error', $sor . "/" . $sorid . " Upsert error: " . $e->getMessage()); throw new \RuntimeException($e->getMessage()); } diff --git a/app/src/Model/Table/AttributesTable.php b/app/src/Model/Table/AttributesTable.php index ceb727485..3c704e110 100644 --- a/app/src/Model/Table/AttributesTable.php +++ b/app/src/Model/Table/AttributesTable.php @@ -81,7 +81,7 @@ public function validationDefault(Validator $validator) { 'length', [ 'rule' => [ 'maxLength', 128 ] ] ); - $validator->notEmpty('username'); + $validator->notEmpty('name'); $validator->add( 'matchgrid_id',