As per the discussion in #1293304: Break up locale.module, but how? and now that we have the negotiation functions cleaned up in #1222106: Unify language negotiation APIs, declutter terminology and friends, we can move the negotiation functionality to language module I think. There will need to be some upgrade path and cleanup on the way as well due to the required renames. Or if this is deemed too much to do at once, we can do the renames first maybe. Let's see what would be required anyway.

In this patch I did the following (items marked with (UP) will need an upgrade path, not included):

- moved the admin pages from locale.admin.inc to language.admin.inc with respective menu items and help text too.
- moved the LANGUAGE_NEGOTIATION_* constants to language.module and renamed them to language- from locale (UP)
- moved the locale_language_* negotiation functions from locale.inc to modules/language/language.negotiation.inc (UP due to negotiation assignments?)
- var locale_language_negotiation_session_param => language_negotiation_session_param (UP)
- var locale_language_negotiation_url_part => language_negotiation_url_part (UP)
- removed the special language switcher colors from locale.css, so that did not move to language.css; I think any designer would applaud this :)
- var locale_language_negotiation_url_prefixes => language_negotiation_url_prefixes (UP)
- var locale_language_negotiation_url_domains => language_negotiation_url_domains (UP)
- vars locale_language_negotiation_methods_weight_$type => language_negotiation_methods_weight_$type (UP)
- moved all negotiation info / type info hooks to language.module
- moved all language change hooks to language.module to change prefix/domain appropriately
- moved blocks to language.module (UP for the delta changes)

This will definitely not pass the upgrade tests. Also looking at how much do we need to include the modules/languages/language.negotiation.inc backend functions (that got moved from locale.inc). The less the better, however some hooks on language save for example use them. That appears to be an interesting area to get right/nice.

CommentFileSizeAuthor
#60 language_negotiation-1468930-60.interdiff.do_not_test.patch3.15 KBplach
#60 language_negotiation-1468930-60.patch178.38 KBplach
#57 language_negotiation-1468930-57.interdiff-51.do_not_test.patch1.59 KBplach
#57 language_negotiation-1468930-57.patch178.09 KBplach
#54 language_negotiation-1468930-54.interdiff.do_not_test.patch664 bytesplach
#54 language_negotiation-1468930-54.patch178.35 KBplach
#53 language_negotiation-1468930-53.interdiff.do_not_test.patch1.33 KBplach
#53 language_negotiation-1468930-53.patch178.47 KBplach
#53 language_negotiation-1468930-53.png11.14 KBplach
#51 language_negotiation-1468930-51.interdiff.do_not_test.patch4.19 KBplach
#51 language_negotiation-1468930-51.patch178.69 KBplach
#48 interdiff.patch44.63 KBdawehner
#46 1468930-move-language-negotiation-to-language-module-45.patch178.22 KBGábor Hojtsy
#45 1468930-move-language-negotiation-to-language-module-45.patch178.22 KBGábor Hojtsy
#42 1468930-move-language-negotiation-to-language-module-41.patch137.16 KBGábor Hojtsy
#41 1468930-move-language-negotiation-to-language-module-41.patch137.16 KBdawehner
#37 1468930-move-language-negotiation-to-language-module-37.patch139.85 KBdas-peter
#35 1468930-move-language-negotiation-to-language-module-35.patch139.22 KBdas-peter
#33 1468930-move-language-negotiation-to-language-module-33.patch139.67 KBdas-peter
#33 1468930-interdiff-26-33-do-not-test.diff5.5 KBdas-peter
#32 interdiff.txt17.47 KBdawehner
#29 1468930-move-language-negotiation-to-language-module-26.patch135.53 KBfubhy
#26 1468930-move-language-negotiation-to-language-module-25.patch119.62 KBfubhy
#23 1468930-move-language-negotiation-to-language-module-24.patch131.42 KBdawehner
#22 1468930-move-language-negotiation-to-language-module-22.patch136.1 KBdawehner
#20 1468930-move-language-negotiation-to-language-module-20.patch131.36 KBdawehner
#17 1468930-move-language-negotiation-to-language-module-16.patch129.68 KBdawehner
#15 1468930-move-language-negotiation-to-language-module-15.patch129.32 KBdawehner
#12 move-language-negotiation-to-language-module-12.patch124.13 KBdawehner
#10 move-language-negotiation-to-language-module-10.patch124.13 KBdawehner
#8 move-language-negotiation-to-language-module-8.patch120.91 KBGábor Hojtsy
#6 move-language-negotiation-to-language-module-6.patch104.98 KBGábor Hojtsy
#4 move-language-negotiation-to-language-module-4.patch103.86 KBGábor Hojtsy
#2 interdiff.txt5.58 KBGábor Hojtsy
#2 move-language-negotiation-to-language-module-2.patch98.71 KBGábor Hojtsy
move-language-negotiation-to-language-module.patch93.13 KBGábor Hojtsy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy’s picture

Status: Active » Needs review
Gábor Hojtsy’s picture

Realized I did not include anything of the base install/uninstall routines. The language install needs to do the preconfiguration of negotiation and it needs to uninstall stuff. The hook_enable() implementation is not needed anymore since we move in negotiation with languages, so data syncing is ensured explicitly.

Looking at the variables removed, I'm not sure what is language_content_type_negotiation and language_content_type_default, but I left there for now. I did not find them in any other code, but they might be dynamic based on something else?

Status: Needs review » Needs work

The last submitted patch, move-language-negotiation-to-language-module-2.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
103.86 KB

Updated several uses of the API as well as use of negotiation names without their constants and block names. Likely more to go, but interested in what the test bot would say to this.

Status: Needs review » Needs work

The last submitted patch, move-language-negotiation-to-language-module-4.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
104.98 KB

Found a couple missing includes so installation works great. Also ran a few tests and fixed wider spread failures. It is still going to fail at places.

Moved the constants to language.negotiation.inc too since they seemed to be needed more with the negotiation functions themselves then without them. (They were together before the patch in locale.inc too).

But more feedback would be great before I move on much farther. :)

Status: Needs review » Needs work

The last submitted patch, move-language-negotiation-to-language-module-6.patch, failed testing.

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
120.91 KB

It would help if I actually include the language.negotiation.inc file, right? :)

Status: Needs review » Needs work

The last submitted patch, move-language-negotiation-to-language-module-8.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
124.13 KB

One reason for the remaining test issues is that locale.inc isn't included by the locale module if it's not needed.
So just adding it all the time, only if locale.module is enabled.

Just some general work to get down the amount of broken tests

Status: Needs review » Needs work

The last submitted patch, move-language-negotiation-to-language-module-10.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
124.13 KB

Get up a patch which applies, though there are still some broken tests.

Status: Needs review » Needs work

The last submitted patch, move-language-negotiation-to-language-module-12.patch, failed testing.

dawehner’s picture

Here are some observations about the failing tests:

* Language list configuration: Simpletests uses for whatever reason 'en/...' as path, so disabling english let 404 all next request on the test

dawehner’s picture

Status: Needs work » Needs review
FileSize
129.32 KB

So some progress: the update tests are running now fine.

Therefore some new update functions had to be written.

Status: Needs review » Needs work

The last submitted patch, 1468930-move-language-negotiation-to-language-module-15.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
129.68 KB

Now just language list configuration is left. The rest which has to be done is about getting the redirecting in the admin ui working as expected.

Even there are such many test fails it's probably just a single one left

Status: Needs review » Needs work

The last submitted patch, 1468930-move-language-negotiation-to-language-module-16.patch, failed testing.

dawehner’s picture

So here is what happens.

On the current version of 8.x the languages.test doesn't enable locale.module, so locale_url_outbund_alter
isn't fired and based on that nothing is redirected.

With this patch the language negotiation is done by language.module so language_url_output_alter is runned, which rewrites the urls.

Now the question is why is the redirecting now working as expected, sadly i currently don't have an idea
why, because language_url_rewrite_session checks for active languages.

dawehner’s picture

Status: Needs work » Needs review
FileSize
131.36 KB

So lets see what the testbot is thinking about that.

Status: Needs review » Needs work

The last submitted patch, 1468930-move-language-negotiation-to-language-module-20.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
136.1 KB

Okay this time everything should work.

dawehner’s picture

The drupal community is too fast

das-peter’s picture

Status: Needs review » Needs work

Here's the result of my visual review (supported by drupalcs ;) ).
Next step from my side will be a test of the upgrade path.

+++ b/core/modules/language/language.admin.inc
@@ -163,6 +163,11 @@ function language_admin_overview_form_submit($form, &$form_state) {
+    // If a language is disabled take sure
+    if ($language->enabled == FALSE && $langcode == $GLOBALS['language_interface']->langcode) {

Comment looks broken here.

+++ b/core/modules/language/language.admin.inc
@@ -436,3 +441,374 @@ function language_admin_predefined_list() {
+      '#field_prefix' => url('', array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=')

A comma should follow the last multiline array item.

+++ b/core/modules/language/language.admin.inc
@@ -436,3 +441,374 @@ function language_admin_predefined_list() {
+        // Validation error if the prefix is blank for a non-default language, and value is for selected negotiation type.

Line exceeds 80 characters; contains 122 characters

+++ b/core/modules/language/language.admin.inc
@@ -436,3 +441,374 @@ function language_admin_predefined_list() {
+    else if (isset($count[$value]) && $count[$value] > 1) {

Use "elseif" in place of "else if"

+++ b/core/modules/language/language.admin.inc
@@ -436,3 +441,374 @@ function language_admin_predefined_list() {
+      // Validation error if there are two languages with the same domain/prefix.

Line exceeds 80 characters; contains 81 characters

+++ b/core/modules/language/language.admin.inc
@@ -436,3 +441,374 @@ function language_admin_predefined_list() {
+        // Validation error if the domain is blank for a non-default language, and value is for selected negotiation type.

Line exceeds 80 characters; contains 122 characters

+++ b/core/modules/language/language.admin.inc
@@ -436,3 +441,374 @@ function language_admin_predefined_list() {
+    else if (isset($count[$value]) && $count[$value] > 1) {

Use "elseif" in place of "else if"

+++ b/core/modules/language/language.admin.inc
@@ -436,3 +441,374 @@ function language_admin_predefined_list() {
+      // Validation error if there are two languages with the same domain/domain.

Line exceeds 80 characters; contains 81 characters

+++ b/core/modules/language/language.admin.inc
@@ -436,3 +441,374 @@ function language_admin_predefined_list() {
+        form_error($form['domain'][$langcode], t('The domain for %language may only contain the domain name, not a protocol and/or port.', array( '%language' => $name)));

There should be no white space after an opening "(" : array( '%language' => ...

+++ b/core/modules/language/language.negotiation.inc
@@ -0,0 +1,465 @@
+    // ('the language-range') that matches this site language ('the language tag').

Line exceeds 80 characters; contains 83 characters.

+++ b/core/modules/language/language.negotiation.inc
@@ -0,0 +1,465 @@
+          // Remove protocol and add http:// so parse_url works

Inline comments must end in full-stops, exclamation marks, or question marks.

+++ b/core/modules/language/language.test
@@ -41,6 +41,8 @@ class LanguageListTest extends DrupalWebTestCase {
+    debug($this->getUrl());
+    debug(url('admin/config/regional/language', array('absolute' => TRUE)));

Leftover debug statements

+++ b/core/modules/locale/locale.install
@@ -485,6 +417,83 @@ function locale_update_8005() {
+  $variable_names = array('language_negotiation_language_interface', 'language_negotiation_language_content', 'language_negotiation_language_url');

If the line declaring an array spans longer than 80 characters, each element should be broken into its own line.

+++ b/core/modules/locale/locale.install
@@ -485,6 +417,83 @@ function locale_update_8005() {
+  $value = variable_get('locale_language_negotiation_url_part',0);
+++ b/core/modules/locale/locale.install
@@ -485,6 +417,83 @@ function locale_update_8005() {
+  $value = variable_get('locale_language_negotiation_url_domains',0);

No space found after comma in function call

+++ b/core/modules/locale/locale.test
@@ -3006,6 +3008,8 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase {
+    debug($language_types);
+    debug($type);

Leftover debug statements

fubhy’s picture

Title: Move negotiation functionality from locale module to language module » Clean up and move the code for the negotiation functionality from locale module to language module

I found quite a few code style issues in the stuff that we are moving around here. So let's clean that up in the same step if you guys are ok with that.

fubhy’s picture

Assigned: Unassigned » fubhy
Status: Needs work » Needs review
FileSize
119.62 KB

Please note that there are a few slightly unrelated code style (basically only formatting) fixes but since we are moving this stuff over anyways I think this is ok.

dawehner’s picture

Assigned: fubhy » Unassigned

I just reviewed the interdiff. They are looking fine. Some are fixing documentation/80 chars, obvious some of the leftover debug() statements.

So from my perspective this looks RTBC, though das-peter said he wants to test the upgrade path a bit better.

Status: Needs review » Needs work

The last submitted patch, 1468930-move-language-negotiation-to-language-module-25.patch, failed testing.

fubhy’s picture

fubhy’s picture

Status: Needs work » Needs review
das-peter’s picture

Assigned: Unassigned » das-peter
Status: Needs review » Needs work

I found some flaws in the upgrade path. I'll provide a new patch asap.

dawehner’s picture

Assigned: das-peter » Unassigned
Status: Needs work » Needs review
FileSize
17.47 KB

Okay the changes for language.negotiation.inc also looks fine. Here is a interdiff between #23 and #29
Let's see what peter is doing.

das-peter’s picture

Here we go.
Changes:

  • Updated the upgrade path to include some missing variables.
  • Fixed a variable name (locale_language_negotiation_methods_weight_)
  • Fixed UI for path prefix configuration. Don't show path prefixes.

Status: Needs review » Needs work

The last submitted patch, 1468930-move-language-negotiation-to-language-module-33.patch, failed testing.

das-peter’s picture

Status: Needs work » Needs review
FileSize
139.22 KB

*grml* I'm still trying to get used to phpStorm :) Next try...

Status: Needs review » Needs work

The last submitted patch, 1468930-move-language-negotiation-to-language-module-35.patch, failed testing.

das-peter’s picture

Status: Needs work » Needs review
FileSize
139.85 KB

Forgot to adjust the tests to check for the proper values.
Adjusting that revealed another issue with the upgrade path - the order of some variable values wasn't maintained. This is now fixed as well.

fubhy’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @dereine and @das-peter! Looking good now (at least to me).

sun’s picture

Status: Reviewed & tested by the community » Needs work

This is a huge patch. I wasn't able to review all changes in detail, and actually I hope that we're really just moving most functions around without any other changes.

Due to its size, I more or less randomly jumped around within this patch, and identified the following issues:

+++ b/core/modules/language/language.admin.inc
@@ -436,3 +442,375 @@ function language_admin_predefined_list() {
+function language_negotiation_configure_url_form($form, &$form_state) {
...
+  language_negotiation_include();

None of these form constructor functions should include support files directly. Form functions always have to use form_load_include().

This bug existed before already, so no need to fix it in this monster. However, please create a follow-up issue for that. (this fix can/should be backported)

+++ b/core/modules/language/language.module
@@ -211,3 +259,281 @@ function language_css_alter(&$css) {
+function language_negotiation_include() {
...
+  include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'language') . '/language.negotiation.inc';

Why isn't this using module_load_include()?

Speaking of, you could add an optional &$form_state = NULL parameter to this helper function, so you can also call this function from form constructors. However, we can do that in a follow-up issue (as mentioned above).

+++ b/core/modules/language/language.module
@@ -211,3 +259,281 @@ function language_css_alter(&$css) {
+function language_modules_enabled($modules) {
+  include_once DRUPAL_ROOT . '/core/includes/language.inc';

The manual include statements look a bit odd, given that there is a language_negotiation_include() helper function, which is used in ~70% of all other cases.

+++ b/core/modules/locale/locale.install
@@ -377,10 +309,10 @@ function locale_update_8005() {
-    // string can only be retrieved from the first plural's PLID given no
-    // other indication. The last plural variant is never referenced, so we
-    // need to store the LID directly for that. We never know whether we are
-    // on the last plural though, so we always remember LID too.
+    // string can only be retrieved from the first plural's PLID given no other
+    // indication. The last plural variant is never referenced, so we need to
+    // store the LID directly for that. We never know whether we are on the last
+    // plural though, so we always remember LID too.

All of these comment changes/fixes are totally outside of the scope for this issue/patch. The comments are actually not changed, only re-formatted and adjusted to fit within 80 chars. Don't do this for monster patches like this.

+++ b/core/modules/locale/locale.install
@@ -485,6 +417,112 @@ function locale_update_8005() {
+function locale_update_8006() {
...
+      if (isset($type_settings['file']) && $type_settings['file'] == 'core/includes/locale.inc') {

+++ b/core/modules/locale/locale.module
@@ -406,140 +362,9 @@ function locale_entity_info_alter(&$entity_info) {
-function locale_language_negotiation_info() {
...
-  $file = '/core/includes/locale.inc';
...
-    'file' => $file,

For some reason, it looks like the file path in the old language negotiation info contained a leading slash, whereas the new one does not. No leading slash is definitely correct and consistent with the rest of Drupal code, but the update function checks for the exact path without leading slash.

We probably want to use strpos() !== FALSE here (type-agnostic comparison).

+++ b/core/modules/locale/locale.install
@@ -485,6 +417,112 @@ function locale_update_8005() {
+    'locale_language_from_browser' => 'language_from_brow',

"from_brow" should be "from_browser"?

+++ b/core/modules/locale/locale.module
@@ -11,6 +11,8 @@
+include_once DRUPAL_ROOT . '/core/includes/locale.inc';

This unconditional loading of locale.inc in locale.module's global scope could use a comment that explains why that is needed. (It looks bogus to me.)

+++ b/core/modules/simpletest/tests/upgrade/upgrade.language.test
@@ -133,7 +139,8 @@ class LanguageUpgradePathTestCase extends UpgradePathTestCase {
+    include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'language') . '/language.negotiation.inc';

(and elsewhere) Why isn't this using module_load_include()?

Gábor Hojtsy’s picture

@sun: yes, the patch mostly only moves stuff around verbatim. It is unfortunate that we don't have a good diff tool to be able to see that :/ I think unless there are fundamental changes with the patch, it would be great to get in and then continue refine the code at its "final" place. As-is now this 140k patch needs a reroll anytime even simple patches like #1156576: Language negotiation is undocumented get committed. So from a pure patch/resource management perspective, getting in the moving-around soon would be great.

All: can we work on resolving @sun's findings so we can get this in soon? Thanks for all your hard work!

dawehner’s picture

Status: Needs work » Needs review
FileSize
137.16 KB

Oh that's definitive a good point: #1506868: Rewrite language_negotiation_include to support form_state and use it in language.admin.inc

* Rechanged the comment in locale.install
* Used strpos() !== FALSE to detect the updated variable
* "from_brow" should be "from_browser"? ups, right.
* +include_once DRUPAL_ROOT . '/core/includes/locale.inc'; I actually don't see a reason to do that, because it's included in locale_init anyway.
*

@@ -133,7 +139,8 @@ class LanguageUpgradePathTestCase extends UpgradePathTestCase {

Let's use here language_nego...include as well.

Gábor Hojtsy’s picture

Uploading for retest, since we seems like never got an answer from testbot.

Status: Needs review » Needs work

The last submitted patch, 1468930-move-language-negotiation-to-language-module-41.patch, failed testing.

Gábor Hojtsy’s picture

So looks like removing the locale.inc inclusions was not harmless after all. What is a great achievement of this patch is the almost entire removal of locale.inc. After this patch, only the following things remain in locale.inc:

// Best effort XSS protection for interface translation.
locale_string_is_safe()

// Interface translation JS handling.
_locale_parse_js_file()
_locale_invalidate_js()
_locale_rebuild_js()

// Country utility function.
country_get_list()

// Date format translation utility functions.
locale_date_format_save()
locale_get_localized_date_format()

There are a few bad things about locale.inc. First it contains all kinds of stuff, like as you can see, interface translation sanitization to JS parsing to providing a country list (which otherwise locale module does not manage itself). It is also included right away from locale_init() so in effect, all page loads, that have locale.module loaded will have these utility functions loaded too. This was added in D7 with/for date format localization I think (IMHO mistakenly). This resulted in massive problems like #1219236: Locale module includes 1350+ lines of unneeded code on all page loads which lead us to componentize the things from locale.inc and move stuff out gradually. Since only the above functions will be left there, I think we can easily move those to either "their right place" or en-masse to the locale.module file with which they are loaded at all times anyway. We can refactor them from there afterwards. That would help us get rid of these uninspiring includes splintered all around.

There is very minimal functionality left there after this patch, and I hope we can get rid of that file sooner than later anyway, so we don't need to debate when to include it and how :)

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
178.22 KB

Attached patch moves country_get_list() to system.module (it is the only place it is being used and locale.inc is included merely for this). Moved the rest to locale.module. With this, all references to locale.inc could be removed (except two places in the upgrade path that changes callback locations formerly in locale.inc).

RIP to locale.inc (finally). Now this needs review. It would be great to fast-track the inclusion of this, since its a huge code move and has the danger of getting outdated very fast. Also very logical :)

Gábor Hojtsy’s picture

http://qa.drupal.org/pifr/test/251424 says it passed but no feedback here. Uploading for retest.

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

All of sun's concerns are now resolved, so back to RTBC as it was 2 weeks ago. It would be important to get this in sooner than later because it moves around huge chunks of code (with minimal change), and is easily going outdated :/

dawehner’s picture

FileSize
44.63 KB

I'm sorry for not being able to do some work in the last days.

Here is an interdiff, which looks fine, so it's RTBC from my side as well.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, interdiff.patch, failed testing.

sun’s picture

Status: Needs work » Reviewed & tested by the community

I didn't re-review, but if anything is left, we can fix that after committing #46

plach’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
178.69 KB
4.19 KB

I love this patch! I found some minor issue which we could neglect, but I thought the following one might deserve a further reroll:

+++ b/core/modules/language/language.install
@@ -7,10 +7,34 @@
+  require_once DRUPAL_ROOT . '/core/includes/language.inc';
+
+  // We cannot rely on language negotiation hooks here, because locale module is
+  // not enabled yet. Therefore language_negotiation_set() cannot be used.
+  $info = language_negotiation_info();
+  $method = $info[LANGUAGE_NEGOTIATION_URL];
+  $method_fields = array('callbacks', 'file', 'cache');
+  $negotiation = array();
+
+  // Store only the needed data.
+  foreach ($method_fields as $field) {
+    if (isset($method[$field])) {
+      $negotiation[LANGUAGE_NEGOTIATION_URL][$field] = $method[$field];
+    }
+  }
+
+  // Enable URL language detection for each (core) configurable language type.
+  foreach (language_types_get_configurable() as $type) {
+    variable_set("language_negotiation_$type", $negotiation);
+  }

Now we can rely on language negotiation hooks, so we can use the regular API functions.

+++ b/core/modules/language/language.module
@@ -211,3 +259,281 @@ function language_css_alter(&$css) {
+      'info' => t('Language switcher (@type)', array('@type' => $info[$type]['name'])),

The language type name is supposed to be passed through t(), hence we need to avoid double-escaping it.

+++ b/core/modules/locale/locale.install
@@ -485,6 +417,112 @@ function locale_update_8005() {
+  $language_types = variable_get('language_types', array(
+    LANGUAGE_TYPE_INTERFACE => TRUE,
+    LANGUAGE_TYPE_CONTENT => FALSE,
+    LANGUAGE_TYPE_URL => FALSE,
+  ));

We can use language_types_get_default() here.

+++ b/core/modules/locale/locale.install
@@ -485,6 +417,112 @@ function locale_update_8005() {
+    if (stristr($variable_name, 'language_negotiation_methods_weight_') !== FALSE){

Missing space before the opening brace.

-5 days to next Drupal core point release.

Gábor Hojtsy’s picture

Status: Needs review » Needs work

t() does not escape any strings, so it should still be used with @. Also, update functions should not use API functions like language_types_get_default() or their results would be unpredictable (if the return value of e function ever changes). Therefore I think these two changes should not have happened. I agree with the rest.

plach’s picture

t() does not escape any strings, so it should still be used with @.

You are right, but reason for the problem you can see below is that block's info is supposed not to be sanitized (see block.admin.inc:128). Hence I guess my motivation was wrong but the fix was right.

Block admin page

Also, update functions should not use API functions like language_types_get_default() or their results would be unpredictable (if the return value of e function ever changes)

I reverted the locale.install hunk because I don't want a discussion to hold up this moster patch. That said we are talking about an install function not an update one, hence IMO we can assume a predictable state. Also an API function implies a contract, if the the contract changes things normally break, not only in the update (install!) functions and they must be fixed anyway. I think using API functions (which we are doing anyway, however) is only decreasing the risk of doing something wrong.

plach’s picture

Removed also the wrong comment in the block info hunk.

plach’s picture

+++ b/core/modules/language/language.install
@@ -7,10 +7,34 @@
+  // We cannot rely on language negotiation hooks here, because locale module is
+  // not enabled yet. Therefore language_negotiation_set() cannot be used.
+  $info = language_negotiation_info();
+  $method = $info[LANGUAGE_NEGOTIATION_URL];

Sorry for being a PITA but if we keep this code we should call language_language_negotiation_info() here.

-5 days to next Drupal core point release.

Gábor Hojtsy’s picture

Status: Needs review » Needs work

@plach: look, I debated the use of API functions in the update function, not in the install function. You reverted the install function, which I did not debate and left the API use in the update function which I did. Just look in locale_update_8006().

Also, looks like it does indeed make good sense to use ! in the block function. So what about documenting it there that the block title is escaped later? (In place of the wrong comment you added and removed).

plach’s picture

I'm terribly sorry, I don't know how I could misunderstand your comment. Probably I was so focused on the language.install hunk that I totally forget about the minor change in locale.install :)

Rerolled the patch as per #56. The interdiff is against #51.

A minor concern I have with this patch is it introduces a dependency from include-level code to module-level code when including language.negotiation.inc in some places. However this should go away when we migrate to PSR-0 classes.

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

Agreed. Looks good now, should get in as soon as possible :)

Dries’s picture

Status: Reviewed & tested by the community » Needs work

Patch needs re-roll.

plach’s picture

Assigned: Unassigned » catch
Status: Needs work » Reviewed & tested by the community
FileSize
178.38 KB
3.15 KB

Rerolled.

plach’s picture

Assigned: catch » Unassigned

Sorry, wrong issue.

Gábor Hojtsy’s picture

Should be still good to go! Let's get this in! :)

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Reviewed. Looks good and applies now. Committed to 8.x. Thanks.

plach’s picture

Woo-hoo!

Gábor Hojtsy’s picture

Issue tags: -sprint

Superb, thank you! :) Added a change notification at http://drupal.org/node/1528520 - it is a logical reorganization, so I don't think it needs a CHANGELOG.txt entry. Moving off-sprint.

Automatically closed -- issue fixed for 2 weeks with no activity.