? Success

User tests: Successful: Unsuccessful:

avatar andrepereiradasilva
andrepereiradasilva
14 Dec 2016

Summary of Changes

Removes custom code in JLanguageMultilang::isEnabled() in favour of JPluginHelper::isEnabled('system', 'languagefilter').

Testing Instructions

  1. Code review
  2. Use latest staging, apply patch and joomla multilanguage detection site/admin works as before.

Documentation Changes Required

None.

avatar andrepereiradasilva andrepereiradasilva - open - 14 Dec 2016
avatar andrepereiradasilva andrepereiradasilva - change - 14 Dec 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 14 Dec 2016
Category Libraries
avatar andrepereiradasilva andrepereiradasilva - change - 14 Dec 2016
The description was changed
avatar andrepereiradasilva andrepereiradasilva - edited - 14 Dec 2016
avatar csthomas
csthomas - comment - 15 Dec 2016

Personally I would like to use $app->getLanguageFilter(); everywhere and whole JLanguageMultilang class should be deprecated.

avatar infograf768
infograf768 - comment - 15 Dec 2016

I was going to suggest to do exactly the opposite...

  • the fact that we have there other methods in use as getSiteHomePages()
avatar csthomas
csthomas - comment - 15 Dec 2016

At first time I disagree with you but I can see it as:

  • app is initialized
  • app calls system plugins and our languagefilter
  • the plugin sets language by JMultilang::setLanguageFilter(true); JMultilang::enable();
  • now everybody can get boolean by JMultilang::getLanguageFilter(); JMultilang::isEnabled();
avatar andrepereiradasilva
andrepereiradasilva - comment - 15 Dec 2016

Personally I would like to use $app->getLanguageFilter(); everywhere and whole JLanguageMultilang class should be deprecated.

The admin app doesn't use that, only the site app. But JPluginHelper::isEnabled('system', 'languagefilter') can be used everywhere, as i proposed in PR #13159, but was rejected ....

avatar csthomas
csthomas - comment - 15 Dec 2016

Direct using JPluginHelper::isEnabled('system', 'languagefilter') is not a good idea because someone may want to write own plugin ex. languagefilter2.

avatar dgt41
dgt41 - comment - 15 Dec 2016

@andrepereiradasilva how about setting one more flag (default = false) in the app, and then calling the plugin in the stack will change that value (if multilingual enabled) using JMultilang::enable(); ??

e.g. after https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/application/site.php#L28

avatar andrepereiradasilva
andrepereiradasilva - comment - 15 Dec 2016

First: as @csthomas, my opinion, is that JLanguageMultilang class should be deprecated and their methods moved to JLanguageHelper (if needed).

IIRC, there are 3 methods doing basicly the same thing ...:

This IMO is not the best scenario.

Direct using JPluginHelper::isEnabled('system', 'languagefilter') is not a good idea because someone may want to write own plugin ex. languagefilter2.

And? What is different from now?

@andrepereiradasilva how about setting one more flag (default = false) in the app, and then calling the plugin in the stack will change that value (if multilingual enabled) using JMultilang::enable(); ??

From an architectural point, why should the app have an hardcode dependency with the language filter plugin? Isn't it a plugin like any other?

avatar csthomas
csthomas - comment - 15 Dec 2016

First: as @csthomas, my opinion, is that JLanguageMultilang class should be deprecated and their methods moved to JLanguageHelper (if needed).

Agree

IIRC, there are 3 methods doing basicly the same thing ...:

JApplicationSite::(get/set)LanguageFilter() https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/application/site.php#L591-L604
JLanguageMultilang::isEnabled() the one in this PR
JPluginHelper::isEnabled('system', 'languagefilter') that is a transversal method to check if any plugin is enabled.

This IMO is not the best scenario.

Agree

Direct using JPluginHelper::isEnabled('system', 'languagefilter') is not a good idea because someone may want to write own plugin ex. languagefilter2.

And? What is different from now?

Use JLanguageMultilang::isEnabled() and JLanguageMultilang::enable() or better move that functionality to JLanguageHelper. I suggest methods like:
isMultilang() and setMultilang($enable = true)

Plugin at least need to call JLanguageHelper::setMultilang().

From now we can replace JLanguageMultilang::isEnabled() with JLanguageHelper::isMultilang()

@andrepereiradasilva how about setting one more flag (default = false) in the app, and then calling the plugin in the stack will change that value (if multilingual enabled) using JMultilang::enable(); ??

From an architectural point, why should the app have an hardcode dependency with the language filter plugin? Isn't it a plugin like any other?

IMHO should not.
Should only base on JLanguageHelper::isMultilang()

JLanguageMultilang::getSiteHomePages() probably should be move to somewhere...

avatar infograf768
infograf768 - comment - 17 Dec 2016

Why change something that works perfectly and has always worked since it was implemented?
IMHO changing for the sake of changing is not a good idea.

avatar andrepereiradasilva
andrepereiradasilva - comment - 17 Dec 2016

IMO "works perfectly" is amatter of opinion, and is not equal to "not touch for ever".

The change proposed is not just for the sake of changing, i have better things to do than moving code around:

  • IMO it's better from a code learning and arquitecture perspective, to have all language stuff in one place (ex: JLanguage and JLanguageHelper).
  • We are making unnecessary db query in that function. We already can know from the following query if the language filter plugin is enabled.
    image
  • The current query does not check, for instance, the state or access of the language filter plugin, this leads to bugs
  • Having all in one class is one more easy to mantain and less error prone than making hardcoded queries in the code
avatar infograf768
infograf768 - comment - 17 Dec 2016

I was unclear in my comment. For me this PR is fine. I was commenting on the other proposals.

avatar andrepereiradasilva
andrepereiradasilva - comment - 2 Jan 2017

further analysing actually this PR will not work, because a user without access to language filter would not be able to see multilangue features.
So will close this

avatar andrepereiradasilva andrepereiradasilva - change - 2 Jan 2017
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2017-01-02 18:40:50
Closed_By andrepereiradasilva
avatar andrepereiradasilva andrepereiradasilva - close - 2 Jan 2017

Add a Comment

Login with GitHub to post a comment