Skip to content

Conversation

@richard67
Copy link
Member

@richard67 richard67 commented Oct 1, 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.

@richard67 richard67 changed the title [4.0] [WiP] Remove duplicates from mail templates list display [4.0] Remove duplicates from mail templates list display Oct 1, 2019
@richard67 richard67 marked this pull request as ready for review October 1, 2019 19:17
@richard67
Copy link
Member Author

@alikon @wilsonge Please test.

@richard67
Copy link
Member Author

@SharkyKZ You too please test, of course.

@alikon
Copy link
Contributor

alikon commented Oct 1, 2019

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

@richard67
Copy link
Member Author

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?

@alikon
Copy link
Contributor

alikon commented Oct 1, 2019

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

@alikon
Copy link
Contributor

alikon commented Oct 1, 2019

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

@richard67
Copy link
Member Author

richard67 commented Oct 1, 2019

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

@alikon
Copy link
Contributor

alikon commented Oct 1, 2019

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

@richard67
Copy link
Member Author

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

@alikon
Copy link
Contributor

alikon commented Oct 1, 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...

@richard67
Copy link
Member Author

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

@alikon
Copy link
Contributor

alikon commented Oct 1, 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....

@richard67
Copy link
Member Author

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

@alikon
Copy link
Contributor

alikon commented Oct 1, 2019

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

@richard67
Copy link
Member Author

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

@richard67
Copy link
Member Author

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

@richard67
Copy link
Member Author

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

@richard67 richard67 changed the title [4.0] Remove duplicates from mail templates list display [4.0] Remove duplicate items and filtering by language from mail templates list display Oct 1, 2019
@richard67 richard67 changed the 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 Oct 1, 2019
@richard67
Copy link
Member Author

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

@richard67
Copy link
Member Author

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.

@richard67
Copy link
Member Author

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

@brianteeman
Copy link
Contributor

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

@richard67
Copy link
Member Author

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

@richard67
Copy link
Member Author

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

@alikon
Copy link
Contributor

alikon commented Oct 2, 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.

@Hackwar
Copy link
Member

Hackwar commented Oct 2, 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.

@brianteeman
Copy link
Contributor

Thought so ;)

@richard67
Copy link
Member Author

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.

@richard67 richard67 closed this Oct 3, 2019
@richard67
Copy link
Member Author

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

@richard67
Copy link
Member Author

I have it, new PR is in preparation.

@richard67
Copy link
Member Author

New PR is #26456 btw.

@richard67 richard67 deleted the 4.0-dev-mail-templates-sql-1 branch October 3, 2019 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants