When viewing a commerce product page I see the following error, but only when logged in.

Notice: Array to string conversion in /sites/all/modules/performance/authcache/modules/authcache_p13n/frontcontroller/authcache.php on line 23

but when looking at the error log I'm seeing a different error for the same page

Warning: Cannot modify header information - headers already sent by (output started at /sites/all/modules/performance/authcache/modules/authcache_p13n/frontcontroller/authcache.php:23) in drupal_send_headers() (line 1221 of /includes/bootstrap.inc).

I afraid I don't even know where to begin to identify what's causing this.

CommentFileSizeAuthor
#4 authcache-patch.diff913 bytesryan88
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

znerol’s picture

Uh, this is weird. Looking at the source I cannot really tell what happens. Could you give some more information on the server software you are using, as well as on the PHP version?

The relevant part from the authcache.php frontcontroller script:

  20 // Relocate contents of $_SERVER variable to DRUPAL_ROOT by removing path
  21 // components pointing to the authcache front controller.
  22 $preg = '|' . preg_quote(substr($__file__, strlen($drupalroot) + 1), '|') . '|';
  23 $_SERVER = preg_replace($preg, 'authcache.php', $_SERVER);

The array-to-string warning origins at the line 23, however the only array parameter there is $_SERVER. Also preg_replace should operate on arrays even when $pattern and $replacement parameters are strings.

If you find the root cause which results in this warning, I'd be very interested in knowing about.

If you run into this on a production system, I recommend to use the safe_frontcontroller/authcache.php script instead. Copy it to the drupal root directory and follow the instructions given in the docblock. This will eliminate the need to dynamically discover the root directory and tamper with $_SERVER global completely.

znerol’s picture

Status: Active » Postponed (maintainer needs more info)
Mario Baron’s picture

I am getting the same error. I tried implementing:

If you run into this on a production system, I recommend to use the safe_frontcontroller/authcache.php script instead. Copy it to the drupal root directory and follow the instructions given in the docblock. This will eliminate the need to dynamically discover the root directory and tamper with $_SERVER global completely.

but, I had no luck and Notice is still showing.
I am using MAMP localhost
Server info:
Apache
PHP 5.3.27

ryan88’s picture

FileSize
913 bytes

I don't really know why the error is happening, but to make it go away, I looped through the $_SERVER variable and did the replace on each item. I attached a patch if interested.

znerol’s picture

Status: Postponed (maintainer needs more info) » Active

@ryan88: Very interesting. This indicates that under some circumstances there can be an entry on the $_SERVER variable which is not a string but an array. Can you identify the entry which causes this notice?

According to the PHP documentation, the argv key contains an array, but it should only be present when running from the command line (see this SO answer).

Do you have the vars-entry on your $_SERVER or is it something different?

harrrrrrr’s picture

I have the same problem when running on local MAMP stack, I tried on 5.3.20 & 5.4.10.

Here is the dump you've asked, the array is indeed in 'argv':

Array
(
    [protossl] => 
    [HTTP_AUTHORIZATION] => 
    [HTTP_HOST] => v***p.be.dev
    [HTTP_CONNECTION] => keep-alive
    [HTTP_ACCEPT] => */*
    [HTTP_X_REQUESTED_WITH] => XMLHttpRequest
    [HTTP_USER_AGENT] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36
    [HTTP_X_AUTHCACHE] => 1
    [HTTP_REFERER] => http://v***p.be.dev/
    [HTTP_ACCEPT_ENCODING] => gzip,deflate,sdch
    [HTTP_ACCEPT_LANGUAGE] => nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4,af;q=0.2,ca;q=0.2,de;q=0.2,es;q=0.2,fr;q=0.2,it;q=0.2,pl;q=0.2
    [HTTP_COOKIE] => cookie-agreed-nl=2; has_js=1; __utma=97863512.978894125.1401264938.1401264938.1401264938.1; __utmb=97863512.17.10.1401264938; __utmc=97863512; __utmz=97863512.1401264938.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
    [HTTP_IF_NONE_MATCH] => "1401266099"
    [HTTP_IF_MODIFIED_SINCE] => Wed, 28 May 2014 08:34:59 +0000
    [PATH] => /usr/bin:/bin:/usr/sbin:/sbin
    [SERVER_SIGNATURE] => 
    [SERVER_SOFTWARE] => Apache
    [SERVER_NAME] => v***p.be.dev
    [SERVER_ADDR] => 127.0.0.1
    [SERVER_PORT] => 80
    [REMOTE_ADDR] => 127.0.0.1
    [DOCUMENT_ROOT] => /Applications/MAMP/htdocs/v***p
    [SERVER_ADMIN] => you@example.com
    [SCRIPT_FILENAME] => /Applications/MAMP/htdocs/v***p/sites/all/modules/authcache/modules/authcache_p13n/frontcontroller/authcache.php
    [REMOTE_PORT] => 51078
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.1
    [REQUEST_METHOD] => GET
    [QUERY_STRING] => a=&r=frag/block/views-shopping_cart-block&o[q]=&v=null
    [REQUEST_URI] => /sites/all/modules/authcache/modules/authcache_p13n/frontcontroller/authcache.php?a=&r=frag/block/views-shopping_cart-block&o[q]=&v=null
    [SCRIPT_NAME] => /sites/all/modules/authcache/modules/authcache_p13n/frontcontroller/authcache.php
    [PHP_SELF] => /sites/all/modules/authcache/modules/authcache_p13n/frontcontroller/authcache.php
    [REQUEST_TIME_FLOAT] => 1401266775.77
    [REQUEST_TIME] => 1401266775
    [argv] => Array
        (
            [0] => a=&r=frag/block/views-shopping_cart-block&o[q]=&v=null
        )

    [argc] => 1
)

  • Commit 6585d3a on 7.x-2.x authored by ryan88, committed by znerol:
    Issue #2193085 by ryan88, marcus178: Fix array to string conversion...
znerol’s picture

Status: Active » Fixed

Fixed, thank you.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.