Hello,

I recently got this error with PHP 5.3 and Pressflow.

Warning: preg_grep() expects parameter 2 to be array, null given in _authcache_get_http_header() (line 345 of /var/www/madfanboy.com/site/sites/all/modules/authcache/authcache.helpers.inc).

Any fix or suggestion?

Thanks

Comments

superfedya’s picture

Another error:
Warning: Parameter 2 to authcache_user() expected to be a reference, value given in module_invoke_all() (line 483 of /var/www/madfanboy.com/site/includes/module.inc).

100% sure it's PHP 5.3 compatibility issue.

maxmendez’s picture

function _authcache_get_http_header($regex, $default = NULL) {
  // The last header is the one that counts:
  $headers = preg_grep($regex, explode("\n", drupal_set_header()));
  if (!empty($headers) && preg_match($regex, array_pop($headers), $matches)) {
    return $matches[1]; // found it
  }
  return $default; // no such luck
}

I think the line 346 should be replaced by this :
$headers = preg_grep($regex, explode("\n", drupal_get_header()));

change:
drupal_set_header() -> drupal_get_header()

maxmendez’s picture

StatusFileSize
new566 bytes

My solution

Joshua Brunner’s picture

StatusFileSize
new596 bytes

authcache_1156520_2.patch work's only with pressflow installed. You should use: drupal_get_headers

demon326’s picture

The last patch fixes the errors, but it seems that the stops authcache from caching with a pressflow base.. pressflow debug spits out the following:

"Authcache prevented cachingNO_CACHE: "Page not cached."
"INFO: "Authcache.info JSON is empty!""

mattwmc’s picture

Issue summary: View changes

A bit old, but I still use pressflow and just installed Authcache.

The patches didn't work until I added '@' in front of preg_grep.

Not sure (not a php guy), but the problem went away with either the set or get header being used.

Edit: as mentioned above, if using pressflow, use the get_header:

$headers = @preg_grep($regex, explode("\n", drupal_get_header()));
kenorb’s picture

Status: Active » Needs review
kenorb’s picture

Status: Needs review » Closed (outdated)

Closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.