Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

empty $headers results in error #12

Open
shaneonabike opened this issue Apr 25, 2012 · 0 comments
Open

empty $headers results in error #12

shaneonabike opened this issue Apr 25, 2012 · 0 comments

Comments

@shaneonabike
Copy link

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']);
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant