No Code Attached Yet ?
avatar phihu
phihu
18 Aug 2023

Hey everyone,
I rarely work with joomla, but ran into this issue.

The issue also seems to affect the filter functionality (but I had no time to properly test this) and might be related to issues #38355, #40068 and #40069.

At least for the wrong API return the cause seems quite clear (see below).

Steps to reproduce the issue

Request any article via the webservice/API that has tags assigned to it.
The ids and names of the tags are/might be mismatched (could have been caused by re-sorting/changes to the tags hierarchy/nesting).

This is the basic tag structure:

screen1
screen2

And an article with tags "M" (ID 2), "T" (ID 3) and "D" (ID 26) assigned to it.

Expected result

Result having matching IDs/names

...
state: 1,
tags: {
   2: "M...",
   3: "T...",
  26: "D..."
}
...

Actual result

IDs/name do not match

result

System information (as much as possible)

Joomla! Version: 4.3.3
PHP Version: 8.1.21

Additional comments

The cause for the mismatched API return can be found here:
api/components/com_content/src/View/Articles/JsonapiView.php

In both cases highlighted $tagsIds and $tagsNames do not (necessarily) match (automatically) and should be properly checked/associated with each other or their right order has to be guaranteed.

Perhaps it would be better to either fetch the tag data including the names based on the item ID (see TagsHelper::getTagIds) or to change the underlying queries, so that both the tags within the items object and the return from getTagIds have a guaranteed (and stable) order.
At first glance, getTagIds does not seem to have any order specified in the query - which means, it is not guaranteed.

Again, unfortunately I really know very little about joomla's structure and the effect changes might have, so unfortunately I cannot provide a fix.

avatar phihu phihu - open - 18 Aug 2023
avatar joomla-cms-bot joomla-cms-bot - change - 18 Aug 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 18 Aug 2023
avatar phihu phihu - change - 18 Aug 2023
The description was changed
avatar phihu phihu - edited - 18 Aug 2023
avatar phihu phihu - change - 18 Aug 2023
The description was changed
avatar phihu phihu - edited - 18 Aug 2023
avatar alikon alikon - change - 19 Aug 2023
Labels Added: ?
avatar alikon alikon - labeled - 19 Aug 2023
avatar alikon alikon - change - 20 Aug 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-08-20 07:23:13
Closed_By alikon
avatar alikon alikon - close - 20 Aug 2023
avatar alikon
alikon - comment - 20 Aug 2023

please test #41397

avatar phihu
phihu - comment - 20 Aug 2023

First of all: Thanks for the quick response!
You added ORDER BY statements to TagsHelper::getTagNames but none to TagsHelper::getTagIds, yet both methods are beeing called in JsonapiView.php. Further: Are you sure the order of the tag IDs derived from the item object are guaranteed/save?

avatar alikon
alikon - comment - 18 Sep 2023

@phihu i've refactored #41397 can you please test
thanks in advance

Add a Comment

Login with GitHub to post a comment