Hello,
I have set a multilingual site using 2 front pages (with a multilingual variable)
I use prefix and my default language is english :

http://www.mysite.com/en ->works
http://www.mysite.com/fr ->works
http://www.mysite.com -> broken

I don't know why it doesn't work =( ?
Any helps?

thx

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Barfly’s picture

in fact :
i look in cache directory and the "_.html" is empty so when i go to "http://www.mysite.com" i have a blank page =(
Boost can't cache my "http://www.mysite.com" page.

BlueDragon-1’s picture

Interesting... On my multilingual site it's exactly the opposite: the http://www.mysite.com is cached (but not served from the cache) and the other ones like http://www.mysite.com/fr or http://www.mysite.com/en are not cached at all. :-O

Barfly’s picture

Furthermore Boost only cache my "/en" and "/fr" frontpage but doesn't cache my others pages

EDIT:
i dig in the boost.module and found that for all my pages (except frontpages) i have:
$_boost['menu_item']['status'] which have "404" value.

So when i comment line 165 $_boost['menu_item']['status'] != 200 my pages are cached (both english and french pages).

$_boost['menu_item']['status'] is important?

das-peter’s picture

Status: Active » Needs review
FileSize
1.62 KB

Attached patch should provide some basic url language prefix support.
I didn't do extensive tests since I was just playing around with boost to check whether it fits my needs.
Thus it's likely that there are still some issues left.

danny1997’s picture

I just tested the patch in #4 and it works.

Thanks a lot.

bgm’s picture

Title: i 18n front page pb » i18n front page pb
Status: Needs review » Fixed

I had the same issue and tested/reviewed the fix. Committed to 7.x-1.x. Thanks for the patch!

geerlingguy’s picture

Status: Fixed » Active

Hmm... Just updated to latest -dev release (on a site that doesn't use any multilingual features), and I'm now getting the following warning on every page request:

Notice: Use of undefined constant LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX - assumed 'LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX' in boost_parse_url() (line 373 of ../drupal7/sites/all/modules/boost/boost.module).
geerlingguy’s picture

If I simply add quotation marks around that constant, the warning is gone.

--- boost.module (saved version)
+++ (current document)
@@ -370,7 +370,7 @@
   parse_str($parts['query'], $parts['query_array']);
 
   // Check if language prefix for urls is enabled.
-  if (variable_get('locale_language_negotiation_url_part') == LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX) {
+  if (variable_get('locale_language_negotiation_url_part') == 'LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX') {
     // Get languages grouped by status and select only the enabled ones.
     $languages = language_list('enabled');
     $languages = $languages[1];
das-peter’s picture

Status: Active » Needs work

Ouch there must be something wrong.
Could it be that locale.inc isn't loaded at that point of the bootstrap?

@geerlingguy: Adding quotation marks may make the warning vanish but the problem still persists. LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX is a constant, adding quotation marks makes out of a constant a string. But what we really need is the (value of the) constant which is defined in locale.inc.
If the constant isn't load at that point of the bootstrap I think we should replace the constant with 0 and add a comment that tells us that this value has to be the same as the one of LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX.

krak’s picture

Notice: Use of undefined constant LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX - assumed 'LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX' в функции boost_parse_url()

Sorry. I see in prior post answer. Wait solvation.

havran’s picture

I try replace LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX with value 0 and i get another error

Fatal error: Call to undefined function language_url_split_prefix() in /data/www/htdocs.mogd7/sites/all/modules/contrib/boost/boost.module on line 378

Edit: i try add

require_once DRUPAL_ROOT . '/includes/locale.inc';

just before

  // Check if language prefix for urls is enabled.
  if (variable_get('locale_language_negotiation_url_part') == 0) {
    // Get languages grouped by status and select only the enabled ones.
    $languages = language_list('enabled');
    $languages = $languages[1];
    list($language, $parts['path']) = language_url_split_prefix($parts['path'], $languages);
  }

and i still get same error.

havran’s picture

I think this patch can work:

# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- HEAD
+++ Modified In Working Tree
@@ -370,7 +370,7 @@
   parse_str($parts['query'], $parts['query_array']);
 
   // Check if language prefix for urls is enabled.
-  if (variable_get('locale_language_negotiation_url_part') == LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX) {
+  if (drupal_multilingual() && variable_get('locale_language_negotiation_url_part') == LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX) {
     // Get languages grouped by status and select only the enabled ones.
     $languages = language_list('enabled');
     $languages = $languages[1];
bgm’s picture

Status: Needs work » Needs review

Not the most elegant, but this would do the trick:

   // Check if language prefix for urls is enabled.
-  if (variable_get('locale_language_negotiation_url_part') == LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX) {
+  if (defined('LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX') && variable_get('locale_language_negotiation_url_part') == LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX) {

The bug only occurs when the locale module is not loaded. I had to test on a blank site to reproduce the bug (disabling locale/i18n wasn't enough, although I guess some other module was causing locale.inc to load).

das-peter’s picture

What I'm really concerned about is the fact that locale.inc sometimes isn't loaded.
If this is the correct behaviour, means this is triggered by some sort of configuration, I think the new check with defined() is a good way to go.
Has already someone the insight when or why locale.inc is load or not?

bgm’s picture

Seems to me that locale.inc is loaded only from locale.module (in hook_init, hook_language_types_info and a few other hooks), so it seems normal that we get that warning when the locale module is not enabled.

I'll commit my patch from #13 for now and see if we get further feedback before closing the issue.

geerlingguy’s picture

#15 Confirmed: I don't have locale enabled on my site.

das-peter’s picture

Thanks for figuring this out.
I took a look too and it looks like we could have another problem here. The locale module doesn't implement hook_boot(), but it implements hook_init().
The locale.api.php say's somewhere:

... However
* modules implementing hook_boot() should be aware that language initialization
* did not happen yet and thus they cannot rely on translated variables. ...

I guess boost uses hook_boot() (I'm not sure, I don't use it yet) to do the necessary operations and that's simply to early to rely on the include of the locale module.
The question now is if boost_parse_url() is used at boot time. If so we can't rely on the constant nor use the function language_url_split_prefix() - means we've to include the locale.inc on our own.
Unfortunately an additional include could affect the performance.
If language_url_split_prefix() is used after hook_init() it should be fine to use the defined() check.

What are the opinions here?

bgm’s picture

Boost uses hook_init(), not hook_boot(). And reading from the description of hook_boot, it seems like hook_init is the right thing to do.

The function in hook_init() basically determines if the page needs to be cached. Once the cache is generated, it's the rewrite rules in the .htaccess which bypass completely PHP.

das-peter’s picture

Thank you very much for the clarification :)
This means we're really close to theoretical approve the approach of using defined().
One last question at this point, is there a need to consider the module weight? The locale module has a weight of 0, according to this documentation boost has -90.
As far as I know hook_init() is invoked by using module_invoke_all('init'); which uses module_implements() and this again ensures the modules that actually implement the hook are loaded. This means we should be on the safe side when we use defined() as the locale module should be loaded (if enabled) when boost_init() is called.
Please correct me if I'm wrong! :)

matthewv789’s picture

Thank you, bgm et al, I just updated Boost to the latest released version of 7.x-1.x-dev, which seems to include that patch, and the warning is now gone.

bgm’s picture

Status: Needs review » Fixed

@ das-peter : yep, sounds right. The language itself is set in the bootstrap, so I think we're safe on that side too, and no need to worry about the weights.

Although someone reported a related issue in #1370776: Fatal error: Call to undefined function language_url_split_prefix() in boost.module on line 377, but that bug is not directly related (occurs while posting content as a non-anonymous user). I'll close this issue for now since it seems OK.

Thanks for all the feedback!

bgm’s picture

I have committed havran's fix from #12, since there were still issues being reported in #1370776: Fatal error: Call to undefined function language_url_split_prefix() in boost.module on line 377.

Status: Fixed » Closed (fixed)

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

dedisoft’s picture

Status: Closed (fixed) » Needs review

Same problem here with the last dev version.

If I clean the cache, the front page is shown. But Boost saves a blank page to it's cache folder.

So the next visit render a blank page (if no language prefix is present).

Edit : when I go to the front page, after cleaning the cache, then I'm redirected to the front page with the default language prefix. So Boost store a blank page with no prefix (file _.html) and the complete page with the prefix (file en_.html)...

dedisoft’s picture

Deactivate Boost solves temporary my issue.

bgm’s picture

Status: Needs review » Closed (fixed)

@ dedisoft: what you describe sounds like a different bug. Please open a new issue with more detailed information, and how to reproduce it on a test site.

bgm’s picture

dedisoft’s picture

Thanks

Marvine’s picture

I have the same issue :
Front page is ok (mysite.net) and working with Boost
but all the other pages are ko (mysite.net/fr/page1 , mysite.net/en/page2 ...) and working without Boost !

I use i18n module with the latest dev version of Boost module.

Is there any specific configuration for Boost or i18n modules to work together ?

>>> problem solved > bad .htaccess

patrickroma’s picture

Same problem here as Marvine...

Anonymous’s picture

What happens, do you get a blank page cached ?

When you use firebug is there a redirect to a default page ?