After installing the multilink module, I'm seeing multiple notices in the drupal logs. Otherwise the module appears to operating correctly (and saved me tons of time!)

The full notice is "Notice: Undefined offset: 0 in _multilink_redirect_cached_language_from_url() (line 70 of ................./public_html/sites/all/modules/multilink/multilink_redirect_cached/multilink_redirect_cached.module)."

Here's the referenced function:

/*
 * Get language from url, return language object.
 */
function _multilink_redirect_cached_language_from_url() {
  // Due to an apparent bug somewhere in Drupal language processing,
  // locale_language_from_url() doesn't work because it expects $_GET['q'] to
  // include the language prefix, but the prefix has already been removed.
  // As a work-around, temporarily set $_GET['q'] to request_path().
  // This works because request_path() statically caches the original value.
  // See: http://drupal.org/node/1286208
  $languages = language_list();
  $saveq = $_GET['q'];
  $_GET['q'] = request_path();
  $language_id = locale_language_from_url($languages);
  $_GET['q'] = $saveq;

  return $languages[$language_id];
}

Drupal is 7.35. I've got the multilink, multilink filter, multilink redirect, and multilink redirect cache modules enabled. I have both content translation and entity translation enabled but I'm primarily using entity translation. I have global redirect disabled.

I noticed that the error appears on multiple pages on the site and has appeared for both internal and external page referrers.

Since it seems related to the cache, I tried clearing all caches, but that did not help.

Disabling multilink_redirect_cached causes the errors to stop.

I'm not sure what else to do to try to diagnose this issue. Suggestions are welcome.

CommentFileSizeAuthor
#4 log message.JPG24.03 KBAbqSteve
#2 language_configure.jpg125.89 KBAbqSteve
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Andy Inman’s picture

It looks like locale_language_from_url is returning FALSE, possibly because of your language configuration. Please look at admin/config/regional/language/configure and what options you have enabled there.

AbqSteve’s picture

FileSize
125.89 KB

I've attached a screen shot of that configuration page.

Andy Inman’s picture

Well, those settings look reasonable. You probably don't need all those options turned on, but I don't imagine that's relevant to this issue.

I don't know what to suggest next. I doubt if this problem is generic, as it would probably have been reported already - the module hasn't changed for a long time. So, I'd guess it's something related to your specific configuration, but I have no idea what it might be.

One question - do you really need the redirect cached sub-module? For example, if you expect your site visitors to be logged-in, then you don't really need it, as cached pages wouldn't be used anyway. Disabling the redirect parts of MultiLink, the in-content link generation will still work. The advantage of the redirection feature is that somebody who clicks a link, say, http://www.triggerpoints.net/de/information would get automatically redirected to the English version if, according to their browser configuration etc, their preferred language were English. If you disable the redirect, they would have to switch languages manually, that's all.

If you know PHP, or have access to somebody who does, add some debug messages to investigate further. The initial question is *why* is Drupal's locale_language_from_url function returning FALSE (apparently). Otherwise, I'd suggest you just do without that redirect function.

AbqSteve’s picture

FileSize
24.03 KB

I added a watchdog right before the return:
watchdog('MultiLink Monitor', "language_id - $language_id");

I attached an interesting snippet from the logs. It looks like the error is not always thrown. Sometimes $language_id is set and sometimes it's blank.

AbqSteve’s picture

Regarding your question about needing the module, it makes a big difference for me in that I don't have to hand translate a lot of internal links on the site. The users aren't logged in.

Also, thanks for the thoughtful response.

Andy Inman’s picture

Closing this, issue not confirmed as related to this module.

Andy Inman’s picture

Status: Active » Closed (cannot reproduce)
Demian’s picture

I was just testing multilink and I stumbled upon this while using HTTPRL Spider.
Note that I was using only URL language detection mode e.g www.example.com/lang/node/nid.

httprl spider calls all nodes without aliases, therefore without a language url prefix.
I tested manually to request a node page /node/nid and the same error returned.

So, for anyone interested, it seems that the error appears when you request a node page directly without any indication of previous language preference. I can happen from bots requesting-searching pages in that way, be it hss, malicious bots or even legitimate search engine bots.

Andy Inman’s picture

Status: Closed (cannot reproduce) » Needs work

Thanks @Demian. That makes sense, I'll take a look.

Andy Inman’s picture

I've added a fix for this in the current dev version. @Demian please let me know if that fixes things for you.

Andy Inman’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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