Download & Extend

PHP 5.3 Warning: preg_grep() expects parameter 2 to be array

Project:Authenticated User Page Caching (Authcache)
Version:6.x-1.0-rc2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

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

#1

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.

#2

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()

#3

My solution

AttachmentSize
authcache_1156520_2.patch 566 bytes

#4

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

AttachmentSize
authcache.helpers.inc_.patch 596 bytes
nobody click here