notice: Undefined index: HTTP_REFERER in ... /front_page.module on line 292.

Ryan Palmer - June 18, 2008 - 05:43
Project:Front Page
Version:6.x-1.2
Component:Code
Category:bug report
Priority:normal
Assigned:Dublin Drupaller
Status:closed
Description

When using the front module to specify different front pages per role and override "Home" breadcrumb links, I get this error when directly accessing the site (typing the address instead of clicking through).

The error message received:

notice: Undefined index: HTTP_REFERER in /home/.xxx/yyyy/zzz.ca/sites/all/modules/front/front_page.module on line 292.

Contents of line 292:

<?php
 
//this checks to see if you are overriding HOME links on the site
 
if (variable_get('front_page_breadcrumb', 0)) {
   
// This checks to see if the referer is an internal HOME link or not.
   
$newhome variable_get('front_page_breadcrumb_redirect', 'node');
   
$ref = $_SERVER['HTTP_REFERER']; // LINE 292
   
global $user, $base_url;
   
$parsed_url=parse_url($base_url);
   
$domain = $parsed_url['host'];
    if (
stristr($ref, $domain)) {
     
drupal_goto($path = $newhome, $query = null, $fragment = null);
    }
  }
?>

Just a humble suggestion: add isset($_SERVER['HTTP_REFERER']) to the if construct that determines if home links should be overridden.

<?php
 
//this checks to see if you are overriding HOME links on the site
 
if (variable_get('front_page_breadcrumb', 0) && isset($_SERVER['HTTP_REFERER'])) {
   
// This checks to see if the referer is an internal HOME link or not.
   
$newhome variable_get('front_page_breadcrumb_redirect', 'node');
   
$ref = $_SERVER['HTTP_REFERER'];
    global
$user, $base_url;
   
$parsed_url=parse_url($base_url);
   
$domain = $parsed_url['host'];
    if (
stristr($ref, $domain)) {
     
drupal_goto($path = $newhome, $query = null, $fragment = null);
    }
  }
?>

Seems to work for me. Patch attached.

#1

Ryan Palmer - June 18, 2008 - 05:46

Patch really attached.

AttachmentSize
front_page.module.1.patch 245 bytes

#2

Dublin Drupaller - January 10, 2009 - 15:06
Assigned to:Anonymous» Dublin Drupaller
Status:active» fixed

Thanks for the patch, Ryan. Good catch. Patch has been committed.

#3

System Message - January 24, 2009 - 15:10
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.