? Success

User tests: Successful: Unsuccessful:

avatar smz
smz
28 May 2015

Description

There is no apparent issue involved, but two getCurrentLanguage() methods were using questionable code.

This PR greatly simplify that code (by making the two methods proxies to the official way to get the currently active language) and make it more robust

The methods are deprecated too, and any reference to them has been substituted with the correct (already existing) method.

Steps to test

To test that there is no regression:

  • have a multilingual site
  • create some tags and assign them to the different languages and to the "All" languages
  • assign those tags to some different articles in different languages (consistently and also inconsistently to the article's language)
  • publish a "Tags - Popular" module on "All pages" and for all languages. Set the "Display Number of Items" option to "Yes"
  • in Tags component options, under "Item Selection Options" select "Language filter: Current"

The reason to use "Tags" to test this PR is that the two involved methods are used by com_tags only (AFAIK...)

Expected result

With or without this patch the displayed tags, the number of items for each tag, and the available items under each tag should be the same

Additional comments

If you assigned tags in an inconsistent way (i.e. a "French" tag to an "English" article) and also if you assigned tags flagged as "All languages" to specific language articles, the displayed number of items for each tag will not match the number of items available under that tag for a particular language, but this is a separate issue and that behavior too will not be affected by this patch.

Thanks @bakual for suggesting the usage of JFactory::getLanguage()->getTag() to get the currently active language.

Votes

# of Users Experiencing Issue
0/1
Average Importance Score
3.00

avatar smz smz - open - 28 May 2015
avatar smz smz - change - 28 May 2015
The description was changed
avatar smz smz - change - 28 May 2015
The description was changed
avatar smz smz - change - 28 May 2015
The description was changed
avatar wilsonge
wilsonge - comment - 28 May 2015
avatar Bakual
Bakual - comment - 29 May 2015

I wonder since you say this is only used by com_tags, if we could additionally deprecate the helper methods and use JFactory::getLanguage()->getTag() directly in the places where those helper methods are called. It doesn't make sense to have to call a helper method which only has one line of code :smile:

avatar smz
smz - comment - 29 May 2015

OK! Will do later on today...
Deprecate should be @ 3.4.2 or @ 4.0 ?

avatar Bakual
Bakual - comment - 29 May 2015

Please use @deprecated 4.0 Use JFactory::getLanguage()->getTag() instead

avatar infograf768
infograf768 - comment - 29 May 2015
avatar smz
smz - comment - 29 May 2015

@infograf768 First, as I have just turned 60, a beg you to share with me your secret recipe for maintaining a good memory! :smile:

Yes, #784 introduced the language filter for tagged items, and the associated original tracker is the one you cited.

In that PR the getCurrentLanguage() was used in several instances, but that method itself must had been introduced sometime earlier as I don't see it defined there.

This PR doesn't seems to affect the functionality of #784 in any way (and it shouldn't from code analysis) as my test methodology, if not exactly equal to, is a very close relative to it of the one described in the tracker, and thus IMHO it is OK to have this accepted...

avatar smz smz - change - 29 May 2015
The description was changed
Title
Fixes getCurrentLanguage() methods
Deprecate getCurrentLanguage() methods
avatar smz smz - change - 29 May 2015
Title
Fixes getCurrentLanguage() methods
Deprecate getCurrentLanguage() methods
avatar smz
smz - comment - 29 May 2015

@bakual I deprecated the two methods as per your instructions and substituted all usages of them with the already existing correct method.

I also changed the title of this PR accordingly

avatar joomla-cms-bot joomla-cms-bot - change - 29 May 2015
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - change - 29 May 2015
Labels Added: ?
avatar Bakual
Bakual - comment - 29 May 2015

Thanks, looks great from code review.

avatar infograf768
infograf768 - comment - 29 May 2015

In that PR the getCurrentLanguage() was used in several instances, but that method itself must had been introduced sometime earlier as I don't see it defined there.

it was in that PR in cms/helper/content.php, ( e1993e1#diff-70a9f5171aac5ecc71b5c63f03bdfee1R258 ) and as you can read, I was already questioning some aspects of it, check browser language for example.
For cms/helper/helper.php this was introduced a bit later in 251410c#diff-0163ec31770d206724d25d3946742aeeR30

Which makes me wonder why we should keep ($detectBrowser = true) if we do not use the browser check anymore.
Is this really B/C?

avatar zero-24 zero-24 - change - 29 May 2015
Category Libraries
avatar zero-24 zero-24 - change - 29 May 2015
Status New Pending
Easy No Yes
avatar smz
smz - comment - 29 May 2015

Which makes me wonder why we should keep ($detectBrowser = true) if we do not use the browser check anymore.
Is this really B/C?

nope... I just forgot to remove the = true... oops!

avatar infograf768
infograf768 - comment - 29 May 2015

I meant in public static function getCurrentLanguage($detectBrowser = true)

avatar smz
smz - comment - 29 May 2015

Fixed: I left the two now ignored parameters there (but un-initialized) as they are public methods and thus the API doc is calling for those parameters. Correct?

avatar smz
smz - comment - 10 Jun 2015

@infograf768, @dgt41, can you please test this?

avatar smz
smz - comment - 10 Jun 2015

@infograf768, @dgt41, @Denitz: Can you please test this?

avatar infograf768
infograf768 - comment - 11 Jun 2015

No issue here. Behaviour is same.

avatar smz
smz - comment - 11 Jun 2015

As we have a "Go!" by @Bakual and @infograf768, can we have this set to RTC and merged for 3.4.2?

avatar Bakual Bakual - change - 11 Jun 2015
Labels Added: ?
avatar Bakual Bakual - change - 11 Jun 2015
Labels Added: ?
avatar Bakual Bakual - change - 11 Jun 2015
Milestone Added:
avatar Bakual Bakual - change - 11 Jun 2015
Milestone Added:
avatar Bakual Bakual - change - 11 Jun 2015
Milestone Removed:
avatar Bakual
Bakual - comment - 11 Jun 2015

According to SemVer this has to go into 3.5.0 since we deprecate something.

avatar smz
smz - comment - 11 Jun 2015

We can remove the deprecation, have good code merged and add the deprecation back @3.5.0. Or not?

avatar Bakual
Bakual - comment - 11 Jun 2015

Since it doesn't really fix anything but is code refactoring, it should go into 3.5.0 anyway. There is no reason to split the PR.

avatar smz
smz - comment - 11 Jun 2015

@Bakual
Actually, looking at the code mods, I have the feeling that there is an issue fixed by this PR: probably mod_tags_popular doesn't show the correct tags if the current language is not the one of your browser.

Unhappily while trying to see if this is indeed the case I discovered that probably we have a regression in the setting of categories associations. I'm thus concentrated on this at this time... will let you know and in case open an urgent issue....

avatar Bakual Bakual - change - 11 Jun 2015
Labels Removed: ?
avatar Bakual Bakual - change - 11 Jun 2015
Labels Removed: ?
avatar smz
smz - comment - 11 Jun 2015

Yes, we have a regression (unrelated to this). See #7151

avatar smz smz - change - 13 Jul 2015
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2015-07-13 08:10:34
Closed_By smz
avatar smz smz - close - 13 Jul 2015
avatar smz smz - close - 13 Jul 2015
avatar zero-24 zero-24 - change - 13 Jul 2015
Milestone Removed:

Add a Comment

Login with GitHub to post a comment