? Pending

User tests: Successful: Unsuccessful:

avatar richard67
richard67
1 Oct 2019

Pull Request for Issue # .

Summary of Changes

This Pull Request (PR) changes the list query for the mail templates list so that no duplicates are shown anymore in the list. This is done by removing the language column from both the result set and the group by. The languages is later be glued to the result with another query in PHP and so not needed for this query.

Somehow this changes fixes also the editing of mail subject and content, which did not work for me without this PR but works now.

Furthermore, this PR removes filtering by language from the list because it does not make sense.

The reason for this is that while in database there is 1 record for each language + 1 with empty language, which is used for diplay of the common properties of all mail templates of this kind (template_id, which is not unique in the table but unique per language) and uses flags to link to the edit form for the reord for that particular language.

This is not the way how other things work regarding languages, but it makes sense here and is explained in a comment of the PR which added this new feature.

Testing Instructions

Please report back if tested with MySQL (or MariaDB) or PostgreSQL. I've tested both with success of course.

  1. Install clean 4.0-dev.
  2. Install some languages and publish their content languages. (optional)
  3. Go to the mail template list as shown by the red marks in following screenshot.

Snap 1

  1. Edit the mail template and toggle the body switcher element and enter any random text.
  2. Do the same with the title.
  3. Save and close.
  4. Edit again the same mail template for the same language to see if the changes have been applied.

Result: See section "Actual result" below.

  1. Apply the patch of this PR and refresh the page.
  2. Edit the mail template and toggle the body switcher element and enter any random text.
  3. Do the same with the title.
  4. Save and close.
  5. Edit again the same mail template for the same language to see if the changes have been applied.

Result: See section "Expected result" below.

Expected result

There is one record shown with ID "com_config.test_mail", which has for each language (content or site, not sure) 1 flag. By clicking on the flag you can edit the mail template for that particular language.

The filter options don't contain an option for filtering by language, same as the sort options, because that would not make sense in this kind of view for reasons stated in description above.

Unbenannt-3

Changing mail subject and content for a particular language works, i.e. you can see the real text and not only the language string when the edit toggle has been changed, and changes are saved and still there when editing again.

Actual result

There are two (in case if no language installed) or maybe more (in case if some languages installed) records shown with ID "com_config.test_mail", which has for each language (content or site, not sure) 1 flag. By clicking on the flag you can edit the mail template for that particular language.

The filter options contain an option for filtering by language, which does not make sense in this kind of view for reasons stated in description above. In opposite to that, the sort options don't contain an option to sort by language. Both together is inconsistent.

Unbenannt-4

Changing mail subject and content for a particular language doesn't work, i.e. changes are not there when editing again.

Documentation Changes Required

None.

avatar richard67 richard67 - open - 1 Oct 2019
avatar richard67 richard67 - change - 1 Oct 2019
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 1 Oct 2019
Category Administration
avatar richard67 richard67 - change - 1 Oct 2019
The description was changed
avatar richard67 richard67 - edited - 1 Oct 2019
avatar richard67 richard67 - change - 1 Oct 2019
The description was changed
avatar richard67 richard67 - edited - 1 Oct 2019
avatar richard67 richard67 - change - 1 Oct 2019
The description was changed
avatar richard67 richard67 - edited - 1 Oct 2019
avatar richard67 richard67 - change - 1 Oct 2019
The description was changed
avatar richard67 richard67 - edited - 1 Oct 2019
avatar richard67 richard67 - change - 1 Oct 2019
Title
[4.0] [WiP] Remove duplicates from mail templates list display
[4.0] Remove duplicates from mail templates list display
avatar richard67 richard67 - edited - 1 Oct 2019
avatar richard67 richard67 - change - 1 Oct 2019
The description was changed
avatar richard67 richard67 - edited - 1 Oct 2019
avatar richard67
richard67 - comment - 1 Oct 2019

@alikon @wilsonge Please test.

avatar richard67
richard67 - comment - 1 Oct 2019

@SharkyKZ You too please test, of course.

avatar alikon
alikon - comment - 1 Oct 2019

maybe i'm reading this quite fast & on phone,
but,
this smells to me like a very bad schema design

avatar richard67
richard67 - comment - 1 Oct 2019

Yes it is, but is not my fault.

Regarding this PR: Maybe easier solution than group by is just to select the 1 record with suitable template_id and language = '' (empty string)? @wilsonge What do you say? Leave this PR like it is, or make easier solution?

avatar alikon
alikon - comment - 1 Oct 2019

nothing personal @richard67 .... but a query on only 1 table that needs a DISTICINT.... talk for themself

avatar alikon
alikon - comment - 1 Oct 2019

i don't remeber if is 2nd or 3rd or even 1st normal form .... ?

avatar richard67
richard67 - comment - 1 Oct 2019

@alikon Same for ther group by which was there before, is unnecessary. Will change to simple solution now then is better.

avatar alikon
alikon - comment - 1 Oct 2019

my mystake i've just trying to fix a bug instead to go much more deeper as it was needed

avatar richard67
richard67 - comment - 1 Oct 2019

@alikon This list display is simply wrong designed, language filtering doesn't work and doesn't make sense there. That's why I leave this PR like it is. Simplified solution would only make sens if no language filtering. @wilsonge Pleace decide: Remove the language filtering, or reqwite this list display so it makes sense.

avatar alikon
alikon - comment - 1 Oct 2019

AFAIK joomla is multilanguage... or at it least it claim to be ...
that's why i've expressed concern when the original PR has been "merged" without tests...

avatar richard67
richard67 - comment - 1 Oct 2019

@alikon Listen: I have not made this wrong design for how this mail template function uses languages. I have made a PR to fix an issue with it so it works like it should at the moment, and I've tested that it works on MySQL and PG. Shall George decide on what to do, I wrote about the alternatives above, but there is nothing wrong on this PR here. And don't request from me to change this PR here to repair all the maldesign in that function: I know how yolub would react when it was your PR and someone would request that. Basta.

avatar alikon
alikon - comment - 1 Oct 2019

don't over react,
i'm just pointing something that it's plain wrong, not about your PR where you are trying to fix something...and i 've fallen on the same issues myself fixing only the GROUP BY syntax , instead of trying to discover the root issue...
but ok calm down
... simply ignore my feedback....

avatar richard67
richard67 - comment - 1 Oct 2019

@alikon I agree with you that there is something wrong. What is wrong is that this email template component works differently regarding languages and multilanguage than all other stuff does. So this PR makes a fix so that it works like that, differently, and wrong in my opinion, too, but maybe we are both wrong and all is right for it. But if you and me are right and it is wrong, then it has to be rewritten with another PR.

avatar alikon
alikon - comment - 1 Oct 2019

or simply revert the original pr which has been demonstrated to be simply wrong
sorry to be honest/blunt/toxic

avatar richard67
richard67 - comment - 1 Oct 2019

@alikon Regarding DISTINCT ... : https://github.com/joomla/joomla-cms/blob/4.0-dev/administrator/components/com_content/Model/ArticlesModel.php#L207 ? So it seems not to be very uncommon in Joomla to use it. It should also not be necessary there if all would have been done right, but it seems to me that if we wanna fix that everywhere, it could be a big story.

avatar richard67
richard67 - comment - 1 Oct 2019

Language filtering is definitely not intended for this view. I will remove it and simplify the database query.

avatar richard67 richard67 - change - 1 Oct 2019
Labels Added: ?
avatar richard67 richard67 - change - 1 Oct 2019
The description was changed
avatar richard67 richard67 - edited - 1 Oct 2019
avatar richard67
richard67 - comment - 1 Oct 2019

PR is ready for test now. SQL simplified and filtering by language removed.

avatar richard67 richard67 - change - 1 Oct 2019
Title
[4.0] Remove duplicates from mail templates list display
[4.0] Remove duplicate items and filtering by language from mail templates list display
avatar richard67 richard67 - edited - 1 Oct 2019
avatar richard67 richard67 - change - 1 Oct 2019
Title
[4.0] Remove duplicate items and filtering by language from mail templates list display
[4.0] Remove duplicate items from list and filtering by language in mail templates list display
avatar richard67 richard67 - edited - 1 Oct 2019
avatar richard67 richard67 - change - 1 Oct 2019
The description was changed
avatar richard67 richard67 - edited - 1 Oct 2019
avatar richard67 richard67 - change - 1 Oct 2019
The description was changed
avatar richard67 richard67 - edited - 1 Oct 2019
avatar richard67
richard67 - comment - 1 Oct 2019

@alikon Please test. DISTINCT and GROUP BY has been removed, SQL is very simple now ;-)

avatar richard67
richard67 - comment - 2 Oct 2019

The more I think about this component and it’s data structures, the less I think it is bad design. If you customize all mail subjects of all languages, you need to have the original setting somewhere if you want to be able to undo your changes for some language. And the defaults are same for all languages because they are language strings, so it would be silly to save them in extra columns in each language-specific records. And the default language strings can’t be hard coded in PHP because different for each extension. So I think meanwhile it is even clever, it just is different how we do it elsewhere for the reason explained here.

avatar richard67
richard67 - comment - 2 Oct 2019

I’ll fix the review results tonight after work (German time zone).

avatar brianteeman
brianteeman - comment - 2 Oct 2019

Fairly certain that this language stuff was discussed in the original PR and explained there

avatar richard67
richard67 - comment - 2 Oct 2019

@brianteeman Thanks for the hint, i've found it: #22126 (comment).

avatar richard67 richard67 - change - 2 Oct 2019
The description was changed
avatar richard67 richard67 - edited - 2 Oct 2019
avatar richard67
richard67 - comment - 2 Oct 2019

@Hackwar Since you know the history of the mail templates: Could you check and report back if this PR here is correct? I think filtering by language doesn't make any sense in the list display, but let me know if I'm wrong and how it was intended to work, e.g. show less flags for that 1 item in the list (which is the master item with empty language), or whatever else was intended.

avatar alikon alikon - test_item - 2 Oct 2019 - Tested successfully
avatar alikon
alikon - comment - 2 Oct 2019

I have tested this item successfully on bbf633f

let me ping @infograf768 i would like to hear his opinion


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

avatar Hackwar
Hackwar - comment - 2 Oct 2019

This PR is not correct. You are supposed to filter by language, because not all mail templates are always customised in all languages. By default, a mail template has no language specific implementation.

avatar brianteeman
brianteeman - comment - 2 Oct 2019

Thought so ;)

avatar richard67
richard67 - comment - 3 Oct 2019

Ok, it has to be fixed in a different way then. Will make new PR in a while when I have time. Thanks for reviewing and clarifications.

avatar richard67 richard67 - change - 3 Oct 2019
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2019-10-03 08:12:19
Closed_By richard67
avatar richard67 richard67 - close - 3 Oct 2019
avatar richard67
richard67 - comment - 3 Oct 2019

@Hackwar Can I assume that the record with empty language (master record) where the defaults are stored always exists? As far as I understand the functionality, it has to be there.

avatar richard67
richard67 - comment - 3 Oct 2019

I have it, new PR is in preparation.

avatar richard67
richard67 - comment - 3 Oct 2019

New PR is #26456 btw.

Add a Comment

Login with GitHub to post a comment