Skip to content

Conversation

@Ioannis
Copy link
Contributor

@Ioannis Ioannis commented Apr 6, 2026

No description provided.

@Ioannis Ioannis requested a review from arlen April 6, 2026 15:28
@Ioannis Ioannis force-pushed the CFM-511_Tab_navigation_resolves_wrong_ID_for_plugin_model_index_links branch from c962f40 to 6c7ac5a Compare April 7, 2026 07:12
Copy link
Contributor

@arlen arlen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Ioannis Ioannis changed the title CFM-511_Tab_navigation_resolves_wrong_ID_for_plugin_model_index_links CFM-511/CMF-274 Tab navigation resolves wrong ID for plugin model index links/Breadcrumb fixes Apr 8, 2026
@Ioannis Ioannis requested a review from arlen April 9, 2026 09:51
@Ioannis Ioannis force-pushed the CFM-511_Tab_navigation_resolves_wrong_ID_for_plugin_model_index_links branch from 892ed7c to de934df Compare April 15, 2026 07:15
@Ioannis Ioannis requested a review from benno April 19, 2026 04:21
@Ioannis Ioannis force-pushed the CFM-511_Tab_navigation_resolves_wrong_ID_for_plugin_model_index_links branch from de934df to 7182820 Compare April 19, 2026 04:24
Comment on lines 501 to 511
* Convert a foreign key into the full qualified (plugin) model name (eg: Reports.Report).
*
* @param string $foreignKey Foreign key name (eg: report_id)
* @return string Pluralized plugin model name.
* @since COmanage Registry v5.2.0
*/
public static function foreignKeyToQualifiedModelName(string $foreignKey): string {
$primaryLinkModelName = StringUtilities::foreignKeyToClassName($foreignKey);

return self::modelNameToQualifiedModelName($primaryLinkModelName);
}
Copy link
Contributor

@benno benno Apr 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to reconcile the comment to what the code actually does. There is no a priori way to extrapolate from a foreign key (eg: report_id) to a fully qualified plugin name. Reports.Report would not be a valid name, it would be something like CoreReporter.Report, though this is a bad example because (the unfinished) Report model is a Pluggable Model, and therefore part of the core code.

It seems like modelNameToQualifiedModelName is trying to find any plugin that implements a model that inflects from this primary key. ie, if I have the key ssh_key_id, then the first plugin that implements SshKeysTable is returned. This will probably work most of the time, but it's not guaranteed. (What if two plugins happen to implement the same foreign key?)

Since this is in the context of Breadcrumbs, I assume what you're trying to do here is map from (eg) MatchServerAttributes (primary key match_server_id) to MatchServers. In this example, if you have access to MatchServerAttributesTable you can examine the primary link on the table, which is CoreServer.match_server_id, which will canonically tell you the correct parent model. But maybe I'm misunderstanding what you're trying to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to reconcile the comment to what the code actually does. There is no a priori way to extrapolate from a foreign key (eg: report_id) to a fully qualified plugin name. Reports.Report would not be a valid name, it would be something like CoreReporter.Report, though this is a bad example because (the unfinished) Report model is a Pluggable Model, and therefore part of the core code.

It seems like modelNameToQualifiedModelName is trying to find any plugin that implements a model that inflects from this primary key. ie, if I have the key ssh_key_id, then the first plugin that implements SshKeysTable is returned. This will probably work most of the time, but it's not guaranteed. (What if two plugins happen to implement the same foreign key?)

Since this is in the context of Breadcrumbs, I assume what you're trying to do here is map from (eg) MatchServerAttributes (primary key match_server_id) to MatchServers. In this example, if you have access to MatchServerAttributesTable you can examine the primary link on the table, which is CoreServer.match_server_id, which will canonically tell you the correct parent model. But maybe I'm misunderstanding what you're trying to do.

@benno
The original code assumed a model name would always map to a single table, but different plugins can define the same model name and map to different tables.
The updated modelNameToQualifiedModelName() removes the ambiguity by looking at the requester model’s associations to determine the correct (possibly plugin-qualified) table name. If the requester has exactly one primary link, it uses that as the canonical parent and returns it immediately.
This fixes issues surfaced by tabs and nested tabs that rely on context (rather than a single direct association), such as the People View, the Enrollment Flows View, etc

Copy link
Contributor

@benno benno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above

@Ioannis Ioannis force-pushed the CFM-511_Tab_navigation_resolves_wrong_ID_for_plugin_model_index_links branch from 7182820 to a926451 Compare May 1, 2026 05:35
@Ioannis Ioannis requested a review from benno May 2, 2026 16:15
@Ioannis
Copy link
Contributor Author

Ioannis commented May 2, 2026

See comment above

@benno pull request updated

@Ioannis Ioannis force-pushed the CFM-511_Tab_navigation_resolves_wrong_ID_for_plugin_model_index_links branch from 2780bcb to 76d0819 Compare May 3, 2026 03:49
@benno benno merged commit 2ebc349 into COmanage:develop May 5, 2026
@Ioannis Ioannis deleted the CFM-511_Tab_navigation_resolves_wrong_ID_for_plugin_model_index_links branch May 5, 2026 16:41
Sign in to join this conversation on GitHub.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants