Skip to content

Commit

Permalink
Additional fix for CFM-482
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Nov 14, 2025
1 parent f5d2e9f commit d97cacd
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions app/src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ protected function primaryLinkOnGet(string $potentialPrimaryLink): Object|bool
$modelsName = $this->getName();

// If this action allows unkeyed, asserted primary link IDs, check the query
// string (e.g.: 'add' or 'index' allow matchgrid_id to be passed in)
// string (e.g.: 'add' or 'index' allow co_id to be passed in)
$actionParam = $this->request->getParam('action');
$allowsUnkeyed = $this->getCurrentTable()->allowUnkeyedPrimaryLink($actionParam);
$allowsLookup = $this->getCurrentTable()->allowLookupPrimaryLink($actionParam);
Expand Down Expand Up @@ -380,13 +380,6 @@ protected function primaryLinkOnPost(string $potentialPrimaryLink): Object|bool

return $this->populatedPrimaryLink($potentialPrimaryLink, (int)$reqData[$potentialPrimaryLink]);
}

// If we didn't find the primary link in the submitted form or API
// request, it might be available via the URL.
// XXX It's not clear what the use case is for this, and the (rewritten) code above
// won't get here anyway, so we'll comment this out for now and eventually remove
// it if nothing comes up.
// return $this->primaryLinkOnPut();
}

/**
Expand Down Expand Up @@ -479,6 +472,21 @@ protected function primaryLinkLookup(): void
}
} // foreach

// If we make it here and we are in a POST, check to see if we allow looking up
// the primary link for this action. We want to exhaustively try to find the
// primary link in the POST body first, so we have to do this after we walk the
// set of available primary links.

if(empty($this->cur_pl->value)
&& $this->request->is('post')
&& $this->request->getParam('action') != 'delete'
&& !empty($this->request->getParam('pass.0'))
&& $table->allowLookupPrimaryLink($this->request->getParam('action'))
) {
$this->cur_pl = $table->findPrimaryLink((int)$this->request->getParam('pass.0'));
$this->set('vv_primary_link', $this->cur_pl->attr);
}

// At the end we need to have a Primary Link
if(empty($this->cur_pl->value)
&& !$table->allowEmptyPrimaryLink($this->request->getParam('action'))
Expand Down

0 comments on commit d97cacd

Please sign in to comment.