Skip to content

empty $headers results in error  #12

@shaneonabike

Description

@shaneonabike

This is a really great addition to CiviCRM btw.. fantastic theme.

On one of my clients is getting the following error and at first I was puzzled until I realized why!

  • Warning: strpos() expects parameter 1 to be string, array given in SimplyCivi_preprocess_page() (line 52 of /.../themes/simplycivi/template.php).

This should never happen.. well unless there are no headers in drupal_set_header() which means it will return an array of nothing unfortunately.

So my suggestion would be just to change this to ....

  //Play nicely with the page_title module if it is there.
  if (!module_exists('page_title')) {
    // Fixup the $head_title and $title vars to display better.
    $title = drupal_get_title();
    $headers = drupal_set_header();

    // if this is a 403 and they aren't logged in, tell them they need to log in
// [shaneonabike]: Added check for empty headers to skip this bizo
    if (!empty($headers) && strpos($headers, 'HTTP/1.1 403 Forbidden') && !$user->uid) {
      $title = t('Please login to continue');
    }
    $vars['title'] = $title;

    if (!drupal_is_front_page()) {
      $vars['head_title'] = $title .' | '. $vars['site_name'];
      if ($vars['site_slogan'] != '') {
        $vars['head_title'] .= ' – '. $vars['site_slogan'];
      }
    }
    $vars['head_title'] = strip_tags($vars['head_title']);
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions