Skip to content

[6.2] [AI] Fix Associations::getAssociations() returning the requested item itself - #48574

Merged
MacJoom merged 2 commits into
joomla:6.2-devfrom
tecpromotion:6.2/fix/associations-exclude-self
Oct 5, 2026
Merged

MacJoom merged 2 commits into
joomla:6.2-devfrom
tecpromotion:6.2/fix/associations-exclude-self

Conversation

@tecpromotion

@tecpromotion tecpromotion commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request resolves # .

  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

PR #39189 added support for passing an array of IDs to Associations::getAssociations(). Since then the check "Do not return itself as result" no longer works in two cases:

  • Array of IDs: the associated item ID is compared with $id, which is an array, so the comparison is always true. The fix compares it with the requested ID of the current row ($item->pk).
  • Single ID passed as string: the PR removed the $id = (int) $id; cast, so a strict comparison with a numeric string (e.g. '5') is always true. The fix casts $id in the comparison.

In both cases the requested item was returned as its own association.

Testing Instructions

  1. Set up a multilingual site (e.g. en-GB and de-DE) with item associations enabled in the "System - Language Filter" plugin.
  2. Create an en-GB article and a de-DE article and associate them. Note the ID of the en-GB article (5 in the example below).
  3. Temporarily add the following code to the index.php of the frontend template (replace 5 with your ID) and open the frontend:
$assoc = \Joomla\CMS\Language\Associations::getAssociations('com_content', '#__content', 'com_content.item', [5]);
var_dump(array_keys($assoc[5]));

$assoc = \Joomla\CMS\Language\Associations::getAssociations('com_content', '#__content', 'com_content.item', '5');
var_dump(array_keys($assoc));
  1. Apply the PR and reload the page.
  2. Check that associations still work as before: language switcher module on an associated article and category, "Associations" column in the backend article list, and the associations shown in the article view (option "Associations" set to "Show").

Actual result BEFORE applying this Pull Request

Both calls return en-GB and de-DE, so the requested article is listed as its own association.

Expected result AFTER applying this Pull Request

Both calls return only de-DE.

Link to documentations

Please select:

  • Documentation link for guide.joomla.org:

  • No documentation changes for guide.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@drmenzelit

Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on 8d77759


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/48574.

@MacJoom

MacJoom commented Oct 5, 2026

Copy link
Copy Markdown
Member

I have tested this item ✅ successfully on 8d77759

Tested on 6.2-dev nightly build


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/48574.

@joomla-cms-bot joomla-cms-bot added PR-6.2-dev RTC This Pull Request is Ready To Commit labels Oct 5, 2026
@drmenzelit

Copy link
Copy Markdown
Contributor

RTC

@Fedik Fedik added the bug label Oct 5, 2026
@MacJoom
MacJoom merged commit 350429c into joomla:6.2-dev Oct 5, 2026
56 checks passed
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Oct 5, 2026
@MacJoom

MacJoom commented Oct 5, 2026

Copy link
Copy Markdown
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants