in /home/glaad/domains/www.glaad.org/staging/sites/all/modules/contrib/redirect/redirect.module on line 1025

This happens with some configurations of mobile tools.

CommentFileSizeAuthor
#2 no_url_inbound_alter-1278190-1.patch2.34 KBdalin

Comments

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

Redirect only runs when Drupal has been fully bootstrapped, so I'm not sure how this is possible?

dalin’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new2.34 KB

This can be traced back to redirect_url_inbound_alter() Which isn't actually doing anything anyway (the redirects here are commented out). So I think the thing to do is remove redirect_url_inbound_alter() which also means that redirect_load_entity_from_path() is never used so that can be removed as well.

dave reid’s picture

Project: Redirect » Mobile Tools
Version: 7.x-1.0-beta3 » 7.x-2.x-dev
Status: Needs review » Needs work

This is a bug in mobile_tools() which causes hook_url_inbound_alter() to get invoked before a full bootstrap:

/**
 * Being called in the hook_boot() implementation
 * This function is in charge of redirection or displaying a notification
 * @param $device
 *   The device object array('type' => [mobile/desktop], 'group' => [group])
 */
function mobile_tools_device_redirect($device) {
  global $base_url;
  //only consider redirection if the mobile url and the destkop url are different
  $mobile_url = variable_get('mobile_tools_mobile_url', '');
  $desktop_url = variable_get('mobile_tools_desktop_url', '');
  if($mobile_url == $desktop_url){
    return;
  }
  // see if the user is currently requestin the mobile or desktop url
  $current_url_type = mobile_tools_site_type();
  // code takes into account path exceptions in the configuration.
  $pages = variable_get('mobile_tools_redirect_exceptions', '');
  $page_match = FALSE;
  if(isset($_GET['q']) && $pages != '') {
    //check if there is no exception in the redirect path (code comes from block.module)
    include_once './includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);
    $path = drupal_get_path_alias($_GET['q']);
    // Compare with the internal and path alias (if any).
    $page_match = drupal_match_path($path, $pages);
    if ($path != $_GET['q']) {
      $page_match = $page_match || drupal_match_path($_GET['q'], $pages);
    }
  }
  // check if exceptions are pages on which to redirect, or not to redirect
  if (variable_get('mobile_tools_redirect_exceptions_type', 0) == 'only-redirect') {
    $page_match = !$page_match;
  }
  // Redirections 
  if (!$page_match) {
    // The case where a mobile user is accessing the desktop site
    if ($device['type'] == 'mobile' && $current_url_type == 'desktop') {
        $destination_url = mobile_tools_get_redirect_url('mobile');
        mobile_tools_goto($destination_url);
    // The case where a desktop user is accessing the mobile site 
    } 
    elseif ($device['type'] == 'desktop' && $current_url_type == 'mobile') {
       $destination_url = mobile_tools_get_redirect_url('desktop');
       mobile_tools_goto($destination_url);
    }
  }
}

drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH); should be drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL) as there is no path bootstrap level.

dave reid’s picture

Also, loading a bootstrap to full from inside hook_boot() is also really, really bad. I cannot support this from the Redirect side.

devin carlson’s picture

Status: Needs work » Closed (duplicate)