User tests: Successful: Unsuccessful:
Pull Request for Issue #11871.
The associations are not properly updated when making changes:
#__associations
table.All
clears all other associations.JModelAdmin::save
now deletes all associations for the currently saved item based on its association key plus if present on the associated items ids.
If language is set to All
, the saved item isn't added to the $associations
array anymore. However it now always saves the associations, regardless of the language of the saved item.
From the original issue:
Multingual site with associations enabled.
3 content languagesCreate an article in each content language and associate them.
Then edit one of these articles and change its language to ALL.
The article saves with this correct warning:A content item set to All languages can't be associated. Associations have not been set.
The problem is that the 2 other articles are no more associated between them.
Additionally test with at least 4 content languages:
1. Associate an item to 3 other items and save
2. Remove the association of two items and save
3. Expected result would be to only have the remaining two items associated but you get 2 pairs of associations now, the removed ones build one (unexpected) and the saved one builds another one (expected).
Apply patch and try again and you should only get the saved pair. The removed ones aren't associated to anything anymore.
Also test other cases like removing all associations.
None
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
@infograf768 One thing I was unsure was the behavior of the association data in the form when switching the language to "All".
With this PR, changes made to the association would stick. The warning message would be a bit misleading.
Another way would be to leave the existing association entries alone and just remove the edited item. But then you need to query the database first (since we don't know the existing state) and then decide if we need to delete one item or in case there would be only one left both of them.
Correct me if I'm wrong, but shouldn't you be using $query->clear()?
Why or where do you think so? $query = $db->getQuery(true)
gives you always a clean query.
$query->clear()
imho is used when you want to clear certain aspects of an existing query to run a similar query again.
will test tomorrow.
one fast remark though
if I remember well, com_categories are special cases
Category | Libraries | ⇒ | Administration Components Libraries |
one fast remark though
if I remember well, com_categories are special cases
Good memory. Did it for categories in the category model as well.
and com_menus?
and com_menus?
Done now as well. Anything else?
First test
4 languages
I have 3 items associated
I create a new item in a 4th language and associate it to one of the items (here the it-IT one to the fr-FR one, without selecting anything else in the association tabs for the 2 other languages).
I expect the 4 items to be associated.
Result: I lose the existing associations:
If I do the same but also associating to en-GB.
Result: the es-ES one is no more associated to anything.
I have to associate the new it-IT article to ALL the already associated items to get what I expect.
For the first test, I would say it is expected behavior. If you assign your italian article only to one other article, it should not magically associate with additional articles. It should only associate with the ones I have chosen. And that is what it does and what it did before this PR afaik.
If you want to assign your italian article to an existing association group, simplest way is to add it from an existing associated article.
If you want to assign your italian article to an existing association group, simplest way is to add it from an existing associated article.
It is indeed what it did before this PR. Would be nice to let the user choose though.
I have tested this item
@andrepereiradasilva
Please test this
Concerning the message, we get now for articles
COM_CONTENT_ERROR_ALL_LANGUAGE_ASSOCIATED="A content item set to All languages can't be associated. Associations have not been set. "
and similar for other components.
code is
JFactory::getApplication()->enqueueMessage(
JText::_(strtoupper($this->option) . '_ERROR_ALL_LANGUAGE_ASSOCIATED'),
'warning'
);
and similar for categories and menus except that we raise Notice instead of warning.
Do you think we could use an alert at saving time when the item is not new and its language is changed to All while it already has associations?
It is indeed what it did before this PR. Would be nice to let the user choose though.
Imho, that would become overly complex.
Do you think we could use an alert at saving time when the item is not new and its language is changed to All while it already has associations?
It sure could be done using JavaScript checking, but I would be the wrong person to do that. And I'm not sure if we should.
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC. Thanks!
Please set milestone to 3.6.3
Labels |
Added:
?
|
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-09-03 10:45:52 |
Closed_By | ⇒ | wilsonge |
Labels |
Removed:
?
|
Correct me if I'm wrong, but shouldn't you be using
$query->clear()
?