User tests: Successful: Unsuccessful:
The languagefilter plugin was not checking for the correct list of published content languages. This PR fixes that by querying the correct published content languages. In addition there is a small cleanup of the language module helper file.
@infograf768: Please add test instructions.
Milestone |
Added: |
Milestone |
Removed: |
||
Labels |
Added:
?
|
Labels |
Added:
?
|
Milestone |
Removed: |
Milestone |
Removed: |
||
Labels |
Added:
?
|
Labels |
Added:
?
|
Milestone |
Removed: |
||
Labels |
Added:
?
|
Labels |
Added:
?
|
Labels |
Removed:
?
|
Labels |
Removed:
?
|
Category | ⇒ | Multilanguage |
Status | New | ⇒ | Ready to Commit |
Status | Ready to Commit | ⇒ | Pending |
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-05-07 20:28:41 |
Closed_By | ⇒ | wilsonge |
IMHO there is no need to have $db as a protected class property...
If there is agreement, can we fix this before 3.4.2 (or we will live with a B/C legacy...)
Also beware the usage of !in_array($lang_code, $lang_codes)
: in_array() is very-very lenient and it is a really dangerous function to use...
Hi Roland!
@smz The $db is protected because then the parent class will initialize it.
I'm not sure what you mean with this... Maybe your concern was not to mix $db with other other possible uses of variables of the same name in parent classes...
But variables declared at the class level (class properties) follows these visibility rules:
So, with protected, you are sharing $db
with possible new classes extending PlgSystemLanguageFilter
and with JPlugin
which is PlgSystemLanguageFilter
parent class
For a better explanation, please see: http://php.net/manual/en/language.oop5.visibility.php
Choosing the lowest visibility needed is always good programming practice.
Furthermore, due to our (very) strict B/C policy, I think that once you introduce a public/protected method/property, you'll have to live with that until the next major Joomla release.
Care to explain why in_array() is really dangerous? You sound like we should remove it from the Joomla core altogether.
Maybe I've been too harsh and overprotective with that!
in_array()
is not the devil, and in this case it could had probably been fit, but the way it performs searches is quite permissive. If you have to check if something (string or integer) is present in an array's values, a safer way is to use array_key_exist() on the flipped (keys and values exchanged) array:
if (array_key_exist(array_flip($myarray))) ...
@smz The protected $db
is correct. There is some magic happening in the JPlugin constructor which will populate $db
automatically. It's similar to $app
.
See https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/plugin/plugin.php#L108
@smz I am fully aware of how visibility works in PHP. Follow the code and you will find magic in JPlugin as pointed out by Thomas. You are correct, the variable $db can be removed as you did in your PR #7130
As for the in_array, that is not the case here because the value we are checking for can only be string and no longer needed with your change.
As for B/C, it's not a problem anyway. Here we are looking at a plugin. This isn't meant to be extended and anyone doing so should be marked as a bad developer on next JaB.
B/C promise is only valid for library code and some other code which would break stuff for the end user. Like HTML output if changed drastically.
That's sadly not true. The b/c rules promised it for all code including extension code which is why we're so screwed in some areas (and why I wrote a long talk at Joomla Day Madrid moaning about it :P)
Umm, either you're interpreting what's published at http://developer.joomla.org/cms/development-strategy.html#backward_compatibility differently or there's a revision that isn't published, it says only /libraries is guaranteed right now. Otherwise you could make the argument you can't ever implement "new MVC" or the router refactorings in components without a major version bump.
Apparently I'm talking shit. But I was sure that's why we proxied the com_config MVC transition
Afaik com_config was rewritten before we adopted the new strategy.
There are also edge cases where components may be extended and/or interacted from other 3rd parties code. Com_config may have been such a case. Com_content may be another such tricky case where we would have to do changes sensible.
However officially, we do not guarantee B/C there
Labels |
Removed:
?
|
Thanks, @RolandD
This solves the issue we just discussed. Agree with @zero-24 for the @since :)
RTC for me as soon as this is corrected.
TEST: set a user default site language to another language than the default site language.
Set the languagefilter plugin to Automatic Change
Login in frontend with that user, the user should be redirected to the correct language.
before patch, the redirection was always to the site default language.