Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-35090

Bug in I18nFilter in combination with locale.default.request

    Details

      Description

      Our portal-ext.properties has (among other things) following values:

      locales=en_US,de_DE
      locale.default.request=true
      locale.prepend.friendly.url.style=2

      We want to always have the language-code in the URL - e.g. www.example.com/en/whatever
      Even if English is the default language.

      With 6.0.6 CE this worked well but it seems broken in 6.1.1 CE.
      I've been digging and debugging and the problem seems to be in the I18nFilter class around lines 130-150:

      132: String i18nPathLanguageId = i18nLanguageId;
      133:
      134: Locale locale = LocaleUtil.fromLanguageId(i18nLanguageId);
      135:
      136: if (!LanguageUtil.isDuplicateLanguageCode(locale.getLanguage()))

      { 137: i18nPathLanguageId = locale.getLanguage(); 138: }

      139: else {
      140: Locale priorityLocale = LanguageUtil.getLocale(
      141: locale.getLanguage());
      142:
      143: if (locale.equals(priorityLocale))

      { 144: i18nPathLanguageId = locale.getLanguage(); 145: }

      146: }
      147:
      148: Locale i18nPathLocale = LocaleUtil.fromLanguageId(i18nPathLanguageId);
      149:
      150: if (!LanguageUtil.isAvailableLocale(i18nPathLocale))

      { 151: return null; 152: }

      A new guest visits the site for the first time and English is default.
      1) i18nLanguageId is "en_US"
      2) Because there are no duplicate languages (e.g. no "en_UK", "en_AU"...) i18nPathLanguageId is set to "en", which is correct.
      3) Now the i18nPathLocale is only "en" (without the "US")
      4) The result in line 150 is that LanguageUtil.isAvailableLocale(i18nPathLocale) = false and the function return null.

      The problem is that the isAvailableLocale()-test is done with i18nPathLocale (="en") but the available locales are "en_US" and "de_DE".

      Lines 148-152 are the only thing that changed between 6.0 and 6.1 which also explains why this worked in 6.0.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              michael.saechang Michael Saechang
              Reporter:
              jan.zarnikov Jan Zarnikov (Inactive)
              Participants of an Issue:
              Recent user:
              Esther Sanz
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                7 years, 14 weeks, 6 days ago

                  Packages

                  Version Package
                  6.0.X EE
                  6.1.30 EE GA3
                  6.2.3 CE GA4