From 7b4be0c90afb296ed98511f755e1559f05add6ea Mon Sep 17 00:00:00 2001 From: Benn Oshrin Date: Mon, 19 Apr 2021 19:34:12 -0400 Subject: [PATCH] Miscellaneous patches --- app/src/Controller/StandardController.php | 15 ++++++++++++++- app/src/Locale/en_US/default.po | 6 ++++++ app/src/Model/Table/MatchgridRecordsTable.php | 2 +- app/src/Model/Table/RulesTable.php | 3 ++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/src/Controller/StandardController.php b/app/src/Controller/StandardController.php index 31a0d29dd..364da8f6d 100644 --- a/app/src/Controller/StandardController.php +++ b/app/src/Controller/StandardController.php @@ -241,7 +241,20 @@ public function index() { // where the link attribute is NULL $query = $this->$modelsName->find()->where([$link['linkattr'].' IS' => $this->request->getQuery($link['linkattr'])]); } else { - $query = $this->$modelsName->find(); + try { + $query = $this->$modelsName->find(); + } + catch(\Cake\Database\Exception $e) { + if($modelsName == 'MatchgridRecords' && $e->getCode() == 500) { + $this->Flash->error(__('match.er.mg.notfound', [$e->getMessage()])); + + return $this->redirect([ + 'controller' => 'matchgrids', + 'action' => 'manage', + $this->cur_mg->id + ]); + } + } } $this->set($tableName, $this->Paginator->paginate($query, $this->paginate)); diff --git a/app/src/Locale/en_US/default.po b/app/src/Locale/en_US/default.po index 24393629d..6c675ead2 100644 --- a/app/src/Locale/en_US/default.po +++ b/app/src/Locale/en_US/default.po @@ -68,6 +68,9 @@ msgstr "Loading records to matchgrid table mg_{0}" msgid "match.cmd.bl.summary" msgstr "Finished processing {0} records ({1} errors, {2} unresolved matches, total elapsed time {3} seconds)" +msgid "match.cmd.db.noop" +msgstr "SQL NOT EXECUTED" + msgid "match.cmd.db.ok" msgstr "Database schema update successful" @@ -231,6 +234,9 @@ msgstr "When this value is selected, {0} cannot be empty" msgid "match.er.input.invalid" msgstr "Invalid character found" +msgid "match.er.mg.notfound" +msgstr "Matchgrid table not found, was the Matchgrid built? ({0})" + msgid "match.er.mgid" msgstr "Could not find Matchgrid ID in request" diff --git a/app/src/Model/Table/MatchgridRecordsTable.php b/app/src/Model/Table/MatchgridRecordsTable.php index b3a020284..052f15324 100644 --- a/app/src/Model/Table/MatchgridRecordsTable.php +++ b/app/src/Model/Table/MatchgridRecordsTable.php @@ -49,7 +49,7 @@ public function initialize(array $config) { // We allow unkeyed primary link here because a record ID is not by itself // sufficient to identify a matchgrid, since each matchgrid gets its own // physical table. - $this->setAllowUnkeyedPrimaryLink(['edit']); + $this->setAllowUnkeyedPrimaryLink(['delete', 'edit']); $this->setAutoViewVars([ 'sor' => [ diff --git a/app/src/Model/Table/RulesTable.php b/app/src/Model/Table/RulesTable.php index 20d422191..af212a246 100644 --- a/app/src/Model/Table/RulesTable.php +++ b/app/src/Model/Table/RulesTable.php @@ -68,7 +68,8 @@ public function initialize(array $config) { 'attributes' => [ 'type' => 'auxiliary', 'model' => 'Attributes', - 'find' => 'filterPrimaryLink' + 'find' => 'filterPrimaryLink', + 'order' => ['name' => 'ASC'] ], 'confidenceModes' => [ 'type' => 'enum',