diff --git a/app/src/Controller/AppController.php b/app/src/Controller/AppController.php index c741a08a1..5f09f2c7e 100644 --- a/app/src/Controller/AppController.php +++ b/app/src/Controller/AppController.php @@ -192,6 +192,12 @@ protected function getPrimaryLink(bool $lookup=false) { $this->cur_pl['linkvalue'] = $this->request->getData($this->cur_pl['linkattr']); } elseif(!empty($this->request->getData($modelName . "." . $this->cur_pl['linkattr']))) { $this->cur_pl['linkvalue'] = $this->request->getData($modelName . "." . $this->cur_pl['linkattr']); + } elseif($this->$modelsName->allowUnkeyedPrimaryLink($this->request->getParam('action')) + && $this->request->getQuery($this->cur_pl['linkattr'])) { + // If this action allows unkeyed, asserted primary link IDs, check the query + // string (eg: 'add' or 'index' allow matchgrid_id to be passed in). Note we + // do this even though we're in post/put. + $this->cur_pl['linkvalue'] = $this->request->getQuery($this->cur_pl['linkattr']); } elseif($this->$modelsName->allowLookupPrimaryLink($this->request->getParam('action'))) { // Try to map the requested object ID (this is probably a delete, so no attribute in post body) $param = (int)$this->request->getParam('pass.0'); @@ -265,6 +271,12 @@ protected function setMatchgrid() { $mgid = $this->request->getData('matchgrid_id'); } elseif(!empty($this->request->getData($modelName . ".matchgrid_id"))) { $mgid = $this->request->getData($modelName . ".matchgrid_id"); + } elseif($this->name == 'MatchgridRecords' + && !empty($this->request->getQuery('matchgrid_id'))) { + // As a special case for MatchgridRecords, we accept the matchgrid_id + // as a get parameter even though the action is post/put, since this + // is how it is provided for a delete action. + $mgid = $this->request->getQuery('matchgrid_id'); } } } else {