? ? Pending

User tests: Successful: 2 Razzo1987, drmenzelit Unsuccessful: 0

avatar infograf768
infograf768
19 Feb 2021

Summary of Changes

Multilingual site
When using a Create Article menu item using a specific category, whatever the language set for that category, the default language field is always set to the site language and can also be modified, which can cause unwanted errors.
In a multilingual site, an article tagged to a specific language should only be in a category tagged to the same language or All languages.

  1. The first correction comes from #6966 where the intention was, when creating an article in backend to propose in the create article form by default the same language as the language filter articles manager was set to . Thanks to @Bakual for helping me finding this :)
    As this was not limited to Administration, it was forcing as default the site default language when creating an article in frontend.

$data->set('language', $app->input->getString('language', (!empty($filters['language']) ? $filters['language'] : null)));

This is now corrected here by limiting it to admin

We never remarked that overseen aspect because we had already a way in frontend to do that in the HtmlView.php

// Propose current language as default when creating new article
if (empty($this->item->id) && Multilanguage::isEnabled())
{
$lang = Factory::getLanguage()->getTag();
$this->form->setFieldAttribute('language', 'default', $lang);
}

  1. To prevent a user a to submit an article with the wrong language when a specific category is selected in the menu item, we then first have to check if this parameter is set in the view.
    If it is, then we should not propose as default the site language (which can be modifed) but instead code the FormModel preprocessForm() method to check the language of the category and, if not set to All languages, force the article to be set to the same language and read-only.

Note: The patch not only prevents error when the Create Article menu item deals with a specific category set to the same language as the site language, but also, cherry on the cake, let's create such menu items with a category set to another language than the site language. Both read-only.

For example:
One can have a Create Article menu item tagged to French and thus displayed in French frontend, with an English tagged specific category. The language field will be rightfully set as English per default and read-only.
As when one can do the more, one can do the less, let's test it.

Testing Instructions

Multilingual site with 2 languages.
Let's do the cherry on the cake :)
Create a Create Article menu item tagged to French with a specific category tagged to English in a French tagged menu.
Set access to Special.
Login frontend and click on the menu item.
Check the category and the language before submitting.
Check the Articles Manager for the new article.

Expected result AFTER applying this Pull Request

Creating the menu item
Screen Shot 2021-02-19 at 09 58 48

Screen Shot 2021-02-19 at 09 59 08

Frontend menu item displayed

Screen Shot 2021-02-19 at 09 59 45

Article form showing category

Screen Shot 2021-02-19 at 10 00 13

Article form showing read-only language field

Screen Shot 2021-02-19 at 10 00 25

Articles Manager showing newly created article

Screen Shot 2021-02-19 at 10 04 22

Note

One can have multiple Create Article menu items set to use different specific category (See my screenshot above).
Beware: once there is (are) such Create Article menu item(s), there should never be also a Create Article menu item NOT set to use a specific category.

avatar infograf768 infograf768 - open - 19 Feb 2021
avatar infograf768 infograf768 - change - 19 Feb 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 19 Feb 2021
Category Administration com_content Front End
avatar richard67
richard67 - comment - 19 Feb 2021

Does this PR also solve or answer #32369 ?

avatar infograf768
infograf768 - comment - 19 Feb 2021

Does this PR also solve or answer #32369 ?

Only partly. That poster is very much confused. ;)
I replied to him.

avatar infograf768 infograf768 - change - 19 Feb 2021
The description was changed
avatar infograf768 infograf768 - edited - 19 Feb 2021
avatar infograf768 infograf768 - change - 20 Feb 2021
Labels Added: ?
avatar infograf768
infograf768 - comment - 20 Feb 2021

@Quy Done. Tested changes OK without really knowing why it is better. ;)

avatar Razzo1987 Razzo1987 - test_item - 20 Feb 2021 - Tested successfully
avatar Razzo1987
Razzo1987 - comment - 20 Feb 2021

I have tested this item successfully on 9434ce6

Test FR 1 before patch
Test FR 2 after patch
immagine


Work correctly


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

avatar Quy
Quy - comment - 20 Feb 2021

@Quy Done. Tested changes OK without really knowing why it is better. ;)

To reduce the exposure of a code base to SQL Injection attacks by sending the query and the data separately.

For more information: https://www.techfry.com/joomla/prepared-statements-in-joomla-4

avatar drmenzelit drmenzelit - test_item - 22 Feb 2021 - Tested successfully
avatar drmenzelit
drmenzelit - comment - 22 Feb 2021

I have tested this item successfully on 5153193


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

avatar infograf768 infograf768 - change - 22 Feb 2021
Status Pending Ready to Commit
avatar infograf768
infograf768 - comment - 22 Feb 2021

rtc

tks for testing


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

avatar richard67 richard67 - alter_testresult - 23 Feb 2021 - Razzo1987: Tested successfully
avatar richard67
richard67 - comment - 23 Feb 2021

The commit after @Razzo1987 's test was just a clean branch update, so that test is still valid. I've restored the test result in the issue tracker so it's properly counted.

avatar chmst chmst - close - 24 Feb 2021
avatar chmst chmst - merge - 24 Feb 2021
avatar chmst chmst - change - 24 Feb 2021
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2021-02-24 10:47:24
Closed_By chmst
Labels Added: ?
avatar chmst
chmst - comment - 24 Feb 2021

Thanks!

avatar chnnst
chnnst - comment - 25 Feb 2021

@infograf768 Can you explain how to test this One can have multiple Create Article menu items set to use different specific category ?

What is expected result if you create 10 article menu items set to use different specific category ?

avatar drmenzelit
drmenzelit - comment - 25 Feb 2021

@chnnst you can create several menu items of type "create article" and in each one you define the category where the article should be stored.
Menu 1: Create article for Blog (Category Blog selected)
Menu 2: Create article for News (Category News selected)
Menu 3: Create article for Politics (Category Politics selected)
.....

Add a Comment

Login with GitHub to post a comment