-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plural formulas are wiped out upon D7 upgrade #6051
Comments
Essentially, the fix is simply removing the |
Good catch! I also noticed |
Good point, @kiamlaluno! Should we tackle that one in this issue as well rather than opening another one? I agree about the proposed fix. |
Also, eventually (version 2.0?) it would be better to store the plural formulas and javascript callback as part of |
I would keep the issues separated, at least because this issue describes a more serious bug in code that is resetting to an empty array a state value the update from Drupal 7 correctly set; the other issue is just about code that deletes persistent variables that do not exist. This issue is more important and it should be fixed as soon as possible. |
PR available for review and testing. This PR removes the faulty initialization of |
@kiamlaluno, wondering if you may be available for testing and code-reviewing? |
I can confirm the PR correctly changes the code. |
Anyone available to do a code review for this upgrade bug? It's already WFM. |
In my previous comment, I can confirm the PR correctly changes the code. was supposed to mean I reviewed the code; I did not test it. (I apologize I was not clear about that.) |
(Yes, pr - works for me should have been replaced by the label that means I reviewed the code and did not find any flaw/error.) |
… upgrades By @argiepiano and @kiamlaluno.
… upgrades By @argiepiano and @kiamlaluno.
Thanks @kiamlaluno and @argiepiano! I have merged backdrop/backdrop#4399 into 1.x and 1.25.x for 1.25.2. |
Description of the bug
When you upgrade a multi-language site that contains plural formulas, those formulas are not transferred to Backdrop.
Steps To Reproduce
l10n_pconfig
. This module provides defaults for plural formulas, and also provides a UI to edit thosel10n_pconfig
will automatically define a plural formula. You can check this by inspecting the tablelanguages
. You'll see values in columnsplurals
(e.g. 2), andformula
(e.g.($n!=1)
)NOTE: In Backdrop, plural formulas are stored in the
state
table, under namelocale_translation_plurals
, keyed by langcode.state
table after the upgrade. You will see the namelocale_translation_plurals
, but its value is blank.Actual behavior
The formulas are not transferred.
Expected behavior
The formulas should be transferred. The
state
table should contain a value forlocale_translation_plurals
Additional information
The issue is
locale_update_1004()
. This is what's happening during the upgrade:update_prepare_language()
is called. Thestate
table storeslocale_translation_plurals
with the correct values from the D7languages
table 👍🏽locale_update_1004()
is run. This hook contains a line that wipes out the value previously stored 👎state_set('locale_translation_plurals', update_variable_get('locale_translation_plurals', array()));
The issue is that the variable
locale_translation_plurals
does not exist in D7. It never existed, in any version of D7. The plural formulas have always been stored in thelanguages
table in D7. Thus, since the variable does not exist,state_set()
simply wipes out the previously stored value.This line should be removed.
BTW, the origin of
locale_translation_plurals
as a state variable is murky. I believe it was present in the first alpha versions of Drupal 8, and was later removed in favor of a config setting. Apparently this never made it into Backdrop.PR: backdrop/backdrop#4399
The text was updated successfully, but these errors were encountered: