? Success

User tests: Successful: Unsuccessful:

avatar Bakual
Bakual
1 Sep 2016

Pull Request for Issue #11871.

The associations are not properly updated when making changes:

  • Removing an associated item doesn't remove it from the database #__associations table.
  • Setting the item language to All clears all other associations.

Summary of Changes

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.

Testing Instructions

From the original issue:

Multingual site with associations enabled.
3 content languages

Create 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.

Documentation Changes Required

None

avatar Bakual Bakual - open - 1 Sep 2016
avatar Bakual Bakual - change - 1 Sep 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 1 Sep 2016
Category Libraries
avatar joomla-cms-bot joomla-cms-bot - change - 1 Sep 2016
Labels Added: ?
avatar C-Lodder
C-Lodder - comment - 1 Sep 2016

Correct me if I'm wrong, but shouldn't you be using $query->clear()?

avatar Bakual
Bakual - comment - 1 Sep 2016

@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.

avatar Bakual
Bakual - comment - 1 Sep 2016

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.

avatar infograf768
infograf768 - comment - 1 Sep 2016

will test tomorrow.

avatar infograf768
infograf768 - comment - 1 Sep 2016

one fast remark though
if I remember well, com_categories are special cases

avatar joomla-cms-bot joomla-cms-bot - change - 1 Sep 2016
Category Libraries Administration Components Libraries
avatar Bakual
Bakual - comment - 1 Sep 2016

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.

avatar infograf768
infograf768 - comment - 1 Sep 2016

and com_menus?

avatar Bakual
Bakual - comment - 1 Sep 2016

and com_menus?

Done now as well. Anything else? ?

avatar infograf768
infograf768 - comment - 2 Sep 2016

First test
4 languages
I have 3 items associated
screen shot 2016-09-02 at 08 41 41

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:

screen shot 2016-09-02 at 08 46 01

If I do the same but also associating to en-GB.
Result: the es-ES one is no more associated to anything.

screen shot 2016-09-02 at 08 50 45

I have to associate the new it-IT article to ALL the already associated items to get what I expect.

screen shot 2016-09-02 at 08 53 15

avatar infograf768
infograf768 - comment - 2 Sep 2016

Second test:
I have 4 items associated. I change the language of one of the items to "All languages".
The other items remain associated.
It therefore solves #11871 ?
screen shot 2016-09-02 at 08 58 46

avatar Bakual
Bakual - comment - 2 Sep 2016

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.

avatar infograf768
infograf768 - comment - 2 Sep 2016

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.

avatar infograf768 infograf768 - test_item - 2 Sep 2016 - Tested successfully
avatar infograf768
infograf768 - comment - 2 Sep 2016

I have tested this item successfully on cad3291

@andrepereiradasilva

@jreys

@alikon

Please test this


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

avatar infograf768
infograf768 - comment - 2 Sep 2016

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?

avatar Bakual
Bakual - comment - 2 Sep 2016

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.

avatar alikon alikon - test_item - 2 Sep 2016 - Tested successfully
avatar alikon
alikon - comment - 2 Sep 2016

I have tested this item successfully on cad3291


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

avatar infograf768 infograf768 - change - 3 Sep 2016
Status Pending Ready to Commit
avatar infograf768
infograf768 - comment - 3 Sep 2016

RTC. Thanks!

Please set milestone to 3.6.3


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

avatar joomla-cms-bot joomla-cms-bot - change - 3 Sep 2016
Labels Added: ?
avatar wilsonge wilsonge - change - 3 Sep 2016
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
avatar wilsonge wilsonge - close - 3 Sep 2016
avatar wilsonge wilsonge - merge - 3 Sep 2016
avatar joomla-cms-bot joomla-cms-bot - close - 3 Sep 2016
avatar joomla-cms-bot joomla-cms-bot - change - 3 Sep 2016
Labels Removed: ?

Add a Comment

Login with GitHub to post a comment