Skip to content

Fix wrong url id harvest #225

Merged
merged 1 commit into from Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 15 additions & 14 deletions app/src/Lib/Util/TableUtilities.php
Expand Up @@ -145,20 +145,21 @@ public static function treeTraversalFromId(string $modelName, int $id, array &$r
// Get the Record from the database
$resp = $ModelTable->find()
->where(['id' => $id])
->first()
->toArray();

// Find all the foreign keys and fetch the rest of the tree
foreach($resp as $col => $val) {
if (
$val !== null
&& $col !== $modelName
&& str_ends_with($col, '_id')
) {
$fkModel = StringUtilities::foreignKeyToClassName(($col));
$fk_table = Inflector::underscore($fkModel);
if (\in_array($fk_table, $listOfTables, true)) {
self::treeTraversalFromPrimaryLink($col, $val, $results);
->first()?->toArray();

if ($resp !== null) {
// Find all the foreign keys and fetch the rest of the tree
foreach($resp as $col => $val) {
if (
$val !== null
&& $col !== $modelName
&& str_ends_with($col, '_id')
) {
$fkModel = StringUtilities::foreignKeyToClassName(($col));
$fk_table = Inflector::underscore($fkModel);
if (\in_array($fk_table, $listOfTables, true)) {
self::treeTraversalFromPrimaryLink($col, $val, $results);
}
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions app/src/View/Helper/TabHelper.php
Expand Up @@ -186,20 +186,16 @@ public function tabBelongsToModelPath(string $tab, string $modelFullName, int &$
*/
public function getCurrentId(string $tabName = null, bool $isNested = false): int
{
$vv_person_id = $this->getView()->get('vv_person_id');
$vv_obj = $this->getView()->get('vv_obj');
$vv_primary_link = $this->getView()->get('vv_primary_link');
$vv_bc_title_links = $this->getView()->get('vv_bc_title_links');
$request = $this->getView()->getRequest();
$curController = $request->getParam('controller');
$curAction = $request->getParam('action');
$plugin = $this->getView()->getPlugin();
$vv_sub_nav_attributes = $this->getView()->get('vv_sub_nav_attributes');
$tab_actions = !$isNested ? $vv_sub_nav_attributes['action'] : $vv_sub_nav_attributes['nested']['action'];
$tabs = !$isNested ? $vv_sub_nav_attributes['tabs'] : $vv_sub_nav_attributes['nested']['tabs'];

$tid = $vv_person_id
?? $request->getQuery($vv_primary_link)
$tid = $request->getQuery($vv_primary_link)
?? $vv_obj->id
?? end($vv_bc_title_links[0]['target']);

Expand Down