I get this notice 3 times when the block cache is cleaned and rebuilt. E.g when installing a new module or disabling another one.
The $info array (result of call to language_types_info) looks like:
$info Array [3]
language Array [2]
name (string:24) Gebruikersinterfacetekst
description (string:182) Volgorde van de taaldetectie-methoden voor de gebruikersinterface. Als een vertaling ...
language_content Array [1]
fixed Array [1]
0 (string:16) locale-interface
language_url Array [1]
fixed Array [2]
0 (string:10) locale-url
1 (string:19) locale-url-fallback
While language_types_configurable() returns:
$configurable Array [2]
0 (string:8) language
1 (string:16) language_content
So the result of language_types_info() is not in line with (the stored info) returned by language_types_configurable(). The variable 'language_types' is set and contains this value:
language_types Array [3]
language (boolean) true
language_content (boolean) true
language_url (boolean) false
I have no idea about the correct solution:
- pass FALSE to the call to language_types_configurable().
- add an isset() check within the loop.
- this is a configuration problem: clean your variables table.
Anyone any ideas?
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | language-1096340-16.patch | 18.57 KB | plach |
| #14 | language-1096340-14.patch | 18.63 KB | plach |
| #11 | language-1096340-11.patch | 18.24 KB | plach |
| #10 | language-1096340-10.patch | 18.24 KB | plach |
| #10 | language-1096340-10-test.patch | 10.9 KB | plach |
Comments
Comment #1
bfroehle commentedYes, try deleting the 'language_types' variable. It's corrupted, but it's unclear why.
Comment #2
fietserwinThe why is here:
So, I played with entity_translation and entity_translation module hooks in, thereby making the setting being changed. Subsequently, I uninstalled entity_translation (unfortunately, the module is not yet mature enough to use it in my current project). Who's to blame? I don't think you can expect entity_translation to clean something in uninstall that they are not aware of. So I think this is minor bug in core, unable to update a setting if it mismatches current provided information.
Comment #3
plachsubscribing
Comment #4
plachBugs are fixed in the development version first, backported then.
Comment #5
plachThis is a major bug since after disabling a module altering language type information, the latter and language negotiation are not updated accordingly. This may lead to very tricky behaviors since a language type which was previously configurable might not be it anymore. A fixed language type is supposed to have a fixed (predictable) language negotiation configuration, while in this case it would retain the previous one which might be different.
Attatched there is a first (partial) attempt to fix the issue, posting it to see if the bot complains.
Related issue: #1060328: Removing a previously available language detection method breaks the configuration UI.
Comment #7
plachThis should be taken into consideration also when enabling modules.
Comment #9
plachThis one should pass. Working on some test coverage for this.
Comment #10
plachHere is an improved version with a complete test suite. Patch summary is coming tomorrow.
The test-only patch is supposed to fail to show how severe this bug is.
Comment #11
plachShould be: "Enable/disable locale_test only if we did not already before."
Added missing tag.
Powered by Dreditor.
Comment #12
plachComment #13
sun1) phpDoc summaries should be in the third-person form; i.e., "Updates...".
2) The _purge() summary should rather be along the lines of "Updates language configuration to removes any language providers that are no longer defined." -- or similar.
1) "... providers keyed by id." (not sure what $id actually is though).
2) (optional) should be all-lowercase.
It doesn't look like we'd ever pass something for $defined_providers. Therefore, the usefulness of this argument is unclear to me. If you have a contrib use-case in mind, then this use-case deserves to be mentioned in the phpDoc.
Should be !isset()
Each manually required drupal_static_reset() deserves an inline comment that explains why it is required. It's close to impossible to figure out the reasoning in existing code.
Especially the last one needs at least that, but actually even more reasoning.
The internal guts of these functions could use some more explanations in inline comments. If I would have to, I'd commit this patch as is, but that would merely be, because I trust you. And because I really hope that you won't be hit by a bus anytime soon. ;) Anyone else has no idea what the assignment of FALSE or TRUE for language types means, why it happens, and why we only store language providers for "fixed" types, but not for not "fixed" (whatever fixed means).
It's also unclear why there is a language_negotiation_set(), but no language_negotiation_get(); it seems the _purge() simply uses a certain variable instead.
Speaking of, using unset() in _purge() would dramatically increase the readability of the code.
Lastly, I don't understand why _set() needs to reset a static at the end, and _purge() does not.
This comment could include a short pointer for "why on earth" providers can suddenly be "no more available".
Why is a form submit handler working off values in $form? $form_state['values'] contains the user-submitted data, and if that needs adjustment, stateful information like this belongs into $form_state.
Since I don't see any changes in this patch that set #language_providers, I can only guess that proper storage/compilation of stateful form values is something we need to fix for D8 (as it would be an API change for D7). If that is the case, we need to create an issue for this.
"Implementation of" is outdated.
Powered by Dreditor.
Comment #14
plachThanks! Here is one addressing #13:
In both cases the
$defined_providersparameter was not actually needed: in the old code$form['#language_providers']was used to avoid callinglanguage_negotiation_info()again. Since it looked like over-engineering I just removed it._get() is defined but, as _set(), it wraps some logic around the raw variable value.
We cannot use
unset()since the value stored in the variable is different form the data structure accepted as parameter. I tried to improve readability by removing thearray_flip()call.Because, if I am not mistaken, there is no static caching involved in functions getting the value of
language_negotiation_$typevariables, whilelanguage_types_configurable()is cached.Comment #15
plachShould be "remove" I guess :(
"disabled"
Powered by Dreditor.
Comment #16
plachFixed typos above and other minor polishing.
Edit: here is the language negotiation API documentation: we might want to move it into a doc block at the beginning of language.inc with some adjustments (in a separate issue).
Comment #17
sunLooks mostly good to me now, but another review from someone else would be good to have.
Comment #18
gábor hojtsyReviewed the one before @sun's comments and this one too. I did not test, but looks promising that it passed tests. It looks big, but it is due to (a) tests (b) refactoring and moving code around. The patch is mostly just API-ification of some cleanup code so that it can be invoked when modules are enabled and disabled. Looks good IMHO.
Comment #19
gábor hojtsyComment #20
plachRelated issue: #1156576: Language negotiation is undocumented.
Comment #21
plachComment #22
dries commentedCommitted to 8.x. Given the size of the patch, and the fact that it introduces new (helper) functions, I'm not going to commit this to 7.x. I'd like to have @webchick look into that instead. Hence, moving this issue from 8.x to 7.x.
Comment #23
webchickWhew! Yeah, I don't quite have the brain-space for this sucker tonight.
plach, I'll try and catch you on IRC, though probably won't be able to until next week. :( I'll also try reading this when I'm not quite so exhausted. :)
Comment #24
webchickOk, went over this again this morning with a much fresher set of eyes and with plach to help me with a few questions. Overall, this is just taking some logic out of form submit functions, moving it to API functions, and then calling them from both the form and hook_enabled/disabled. It also greatly expands our tests for language negotiation, which is of tremendous help going forward.
Committed to 7.x. Thanks!
Comment #25
plachwebchick++
Comment #27
aspilicious commentedRemoving tags (needs backport to D7 queue cleanup)