Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Additional fix for CO-2235 (CO-2564)
Benn Oshrin committed Dec 27, 2022
1 parent 9689a6e commit bd348bb
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/src/Command/BulkLoadCommand.php
@@ -126,7 +126,7 @@ public function execute(Arguments $args, ConsoleIo $io) {
try {
$MatchService = new \App\Lib\Match\MatchService();

$MatchService->connect();
$MatchService->connectDatabase();
$MatchService->setConfig($mg->id);

// First see if table is already built. If not, throw an error that the
@@ -261,7 +261,7 @@ public function execute(Arguments $args, ConsoleIo $io) {
$MatchgridBuilder->build($mg, $mg->attributes, true);
}

$MatchService->disconnect();
$MatchService->disconnectDatabase();
}
catch(\Exception $e) {
$io->out($e->getMessage());
10 changes: 8 additions & 2 deletions app/src/Controller/MatchgridRecordsController.php
@@ -107,7 +107,7 @@ public function add() {

$MatchService = new \App\Lib\Match\MatchService();

$MatchService->connect();
$MatchService->connectDatabase();
$MatchService->setConfig($this->cur_mg->id);

// Before we perform the request, see if we already have an entry for this SORID
@@ -231,7 +231,7 @@ public function edit($id) {

$MatchService = new MatchService();

$MatchService->connect();
$MatchService->connectDatabase();
$MatchService->setConfig($this->cur_mg->id);

// Unlike add (which verifies no entries for sor+sorid), we don't sanity
@@ -436,6 +436,8 @@ protected function performMatch(MatchService $MatchService, string $sor, string
// Did any rules run successfully? If not (eg: no attributes provided in the
// request, no rules defined) then throw an error.
if(empty($results->getSuccessfulRules())) {
$MatchService->disconnectDatabase();

throw new \RuntimeException(__('match.er.rules.unsuccessful'));
}

@@ -457,6 +459,8 @@ protected function performMatch(MatchService $MatchService, string $sor, string
// Fuzzy match, we insert the record but do NOT send notification
$matchRequest = $MatchService->insertPending($sor, $sorid, $AttributeManager);

$MatchService->disconnectDatabase();

$this->Flash->information(__('match.rs.refid.pending', [$matchRequest]));

// Redirect to the reconcilation page
@@ -469,6 +473,8 @@ protected function performMatch(MatchService $MatchService, string $sor, string
}

$id = $MatchService->getRequestIdForSorId($sor, $sorid);

$MatchService->disconnectDatabase();

return $this->redirect([
'action' => 'edit',
10 changes: 8 additions & 2 deletions app/src/Controller/MatchgridsController.php
@@ -149,11 +149,13 @@ public function pending(string $id) {
try {
$MatchService = new \App\Lib\Match\MatchService();

$MatchService->connect();
$MatchService->connectDatabase();
$MatchService->setConfig((int)$id);

$results = $MatchService->getRequests('pending');

$MatchService->disconnectDatabase();

// Although we're passing the $id as provided by the user, it has been
// vetted since MatchgridLinkTrait will pull the current Matchgrid from
// the database before we get here and throw an error if $id is invalid.
@@ -182,7 +184,7 @@ public function reconcile(string $id) {
$MatchService = new \App\Lib\Match\MatchService();
$AttributeManager = new \App\Lib\Match\AttributeManager();

$MatchService->connect();
$MatchService->connectDatabase();
$MatchService->setConfig((int)$id);

if($this->request->is('post')) {
@@ -285,6 +287,8 @@ public function reconcile(string $id) {
}
}

$MatchService->disconnectDatabase();

// Redirect back to list of pending requests
return $this->redirect([
'action' => 'pending',
@@ -341,6 +345,8 @@ public function reconcile(string $id) {
// Also set the original request separately to make it easier for the view
$this->set('vv_request', $origReq[$rowId]);
$this->set('vv_title', __('match.op.reconcile.request', [$sor, $sorid]));

$MatchService->disconnectDatabase();
} // is post
}
catch(Exception $e) {

0 comments on commit bd348bb

Please sign in to comment.