In the admin pages I get these annoying warnings every now and then:

* warning: Cannot modify header information - headers already sent by (output started at /home/www/sos/banner_file.php:71) in /home/www/sos/includes/common.inc on line 139.
* warning: Cannot modify header information - headers already sent by (output started at /home/www/sos/banner_file.php:71) in /home/www/sos/includes/common.inc on line 139.

Comments

ñull’s picture

Also on other pages.

ñull’s picture

Aparently this warning comes up when one of the "Group display blocks" is not showing a banner. As a test I put two banners each on their own in a group and both groups' block enabled. So every now and then I only see one of the two banners, as if at random it would choose to show the second banner in the group, but there isn't a second banner.

I hope this added information helps to track the problem.

wulff’s picture

Status: Active » Fixed

Fixed in latest version of the cache handlers.

suit4’s picture

Status: Fixed » Active

even if i use the latest version, i get that annoying warning

warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/mydomain.org/httpdocs/trunk/banner_file.php:72) in /var/www/vhosts/mydomain.org/httpdocs/includes/common.inc on line 139.

and it is not only on the admin pages, but in every page displaying banners.

is there a workaround?

suit4’s picture

just a note about the error source:

this error only occurs, if using banner_file.php.

banner_file.php is called like this
banner_file.php?group=0&count=1&terms=0&max=1&path=files

the resulting error message is
Invalid argument supplied for foreach() in banner_file.php on line 72
This error message causes the ' Cannot modify header information' warning.

banner_file.php:
Line 72 tries to acces $struct[0][0][$group] (as an array), which is empty if you didn't assign
the banner to a group.

Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [0] => 
                )

        )

    [1] => Array
        (
            [8] => stdClass Object
                (
                    [views_this] => 0
                    [views] => 0
                    [views_day] => 0
                    [views_week] => 0
                    [views_day_max] => 0
                    [views_week_max] => 0
                    [views_max] => 0
                    [html] => document.write('<a href="/trunk/en/banner/8" title="http://drupal.org/" target="_blank"><img src="http://mydomain.org/files/testbanner1.png" width="468" height="60" alt="" /></a>');
                )

        )

    [2] => 1160046731
)

A workaround simply could be a default value at the problematic point.

My question is:
how do I add a banner to a banner group?
Yes, thats funny, but where do I do that?

alexkb’s picture

I was getting this same error (banner_file.php:72), even with all the banners being assigned a banner group id. Anyway, I did some more searching around and found a fix on http://drupal.org/node/66063#comment-175309

In summary, the proper format for a module file is for it not to have a closing php tag. However, the banner_file.php isn't a module, and it is called independantly - so in plain english - it should.

I've added it to the end of my banner_file.php, leaving no white space - and it seems to have fixed this particular problem for me.

alexkb’s picture

Hmm.. in actual fact its still doing it - and from what I can tell, its completely random - sometimes its the top banner, othertimes, its all banners - they don't display, and the admin log shows the banner_file.php:72 headers already sent fault. Maybe a post in the forums, might shed some light :/

cvining’s picture

Well, I too was seeing this error. Not all the time, but often.

Then I noticed the banner graphics weren't showing at all in MSIE. Just one of those X boxes, as if the graphic file wasn't available to server up. A look at the "properties" showed the URL for the banner graphic as

"http://sandbox.mydomain.com/system/files/logo-banner.gif"

Indeed, when I looked at the 'banner' table entry, in the 'cache' column, the above URL shows up. But my website is NOT at http://sandbox.mydomain.com, but actually http://www.mydomain.com. I had used the 'sandbox.' subdomain just to check things out. But it seems the banner module stores the full, absolute URL when you create the banner.

So, I went and edited & saved each banner. Now the "Cannot modify header" warning is gone and MSIE displays the banners correctly!

Other than that, I've had no trouble with the banner module and I like it a lot. Maybe in a future revision, it could store relative URLS, which should make it more friendly for certain multisite implementations too.

Thanks for all the fish!

- Cronin

sun’s picture

Please ensure that you also updated banner_file.php and banner_db.php in the root folder of your Drupal installation after updating Banner module. Updating both files solved these issues for me.

wulff’s picture

Status: Active » Closed (fixed)