From 16a28a447192a5ca5f4500fef36f96a2494ea156 Mon Sep 17 00:00:00 2001 From: Benn Oshrin Date: Fri, 10 Dec 2021 08:59:37 -0500 Subject: [PATCH] Fix error when no matchgrid (CO-2297) and other errata --- app/src/Controller/StandardController.php | 5 ++++- app/src/Controller/TierApiController.php | 7 +++++++ app/src/View/Helper/BadgeHelper.php | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index e56468b02..21410016f 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -330,7 +330,7 @@ public function index() { $query = $table->find(); } catch(\Cake\Database\Exception $e) { - if($modelsName == 'MatchgridRecords' && $e->getCode() == 500) { + if($modelsName == 'MatchgridRecords') { $this->Flash->error(__('match.er.mg.notfound', [$e->getMessage()])); return $this->redirect([ @@ -338,6 +338,9 @@ public function index() { 'action' => 'manage', $this->cur_mg->id ]); + } else { + // Rethrow the exception + throw new \RuntimeException($e->getMessage()); } } } diff --git a/app/src/Controller/TierApiController.php b/app/src/Controller/TierApiController.php index 87d3cf9ff..e70a5017a 100644 --- a/app/src/Controller/TierApiController.php +++ b/app/src/Controller/TierApiController.php @@ -187,6 +187,13 @@ protected function doMatchRequest(bool $searchOnly=false) { throw new \InvalidArgumentException('No JSON record found or body not successfully parsed'); } + // getParsedBody can apparently return either an array or an object + // according to its mood. We originally assumed an object, so if we get + // an array we'll convert it to an object. + if(is_array($json)) { + $json = (object)$json; + } + $AttributeManager = new \App\Lib\Match\AttributeManager(); $MatchService = new \App\Lib\Match\MatchService(); diff --git a/app/src/View/Helper/BadgeHelper.php b/app/src/View/Helper/BadgeHelper.php index cd91ab296..fe8e83899 100644 --- a/app/src/View/Helper/BadgeHelper.php +++ b/app/src/View/Helper/BadgeHelper.php @@ -58,6 +58,7 @@ public function badgeIt( string $fa_class = null, bool $dis_text_dark = false ) { + $fa_element = ''; $badge_classes = [];