I added a second banner, and immediately it was the only banner which would display (of two entered and activated). Now after a couple minutes of browsing and not seeing the banner change from the second one entered, no banners are being displayed, and I get the following error three times in the message area:

warning: Invalid argument supplied for foreach() in /home/rpgmap/public_html/modules/ad/ad.module on line 1848.

Comments

jeremy’s picture

Assigned: Unassigned » jeremy

Did you enable the file cache? This message suggests that you have the file cache enabled. If so, try disabling it and see if your problem goes away. (It is configured at administer -> ads -> settings.)

It would also help to gather some debug information. Can you edit the module and add the following line, then reload the page and send me the resulting output? Go to line 1847 and insert three lines that read:

  echo '<pre>';
  print_r($cache)
  echo '</pre>';

Thus, the resulting area of code will look like this:

      if ($cache) {
        echo '<pre>';
        print_r($cache);
        echo '<pre>';
        // Process each group.
        foreach ($cache['ad'] as $group => $ads) {

It will be very helpful if you can collect this information -- I'd like to understand what's going wrong for your installation and to get this problem resolved. Thanks for helping beta test this module.

Steel Rat’s picture

Yes, I enabled file cache, since the only other option was none.

I'll try adding those lines and get you the output.

Steel Rat’s picture

I added those three debug lines, and now the error output shows:



    * warning: Invalid argument supplied for foreach() in /home/rpgmap/public_html/modules/ad/ad.module on line 1851.
    * warning: Invalid argument supplied for foreach() in /home/rpgmap/public_html/modules/ad/ad.module on line 1851.
    * warning: Invalid argument supplied for foreach() in /home/rpgmap/public_html/modules/ad/ad.module on line 1851.
    * warning: Cannot modify header information - headers already sent by (output started at /home/rpgmap/public_html/modules/ad/ad.module:1848) in /home/rpgmap/public_html/modules/ad/adserve.php on line 354.

Nothing is printing before the ForEach..

Steel Rat’s picture

Looks like both my banners went to Expired, even though I had manually emptied the fields.

Anyway, I changed cacheing back to none, and re-activated the banners. No more errors displaying.

But I briefly got this ouput on the screen all by itself:

Array
(
[last_sync] => 1170269266
)

Array
(
[last_sync] => 1170269266
)

Array
(
[last_sync] => 1170269266
)

jeremy’s picture

Status: Active » Fixed

These errors were because you didn't have any active ads. I've added a test to be sure there are ads before trying to loop through them to prevent these errors from happening. The real bug is why your ads are being expired which is being tracked in another issue.

Steel Rat’s picture

Status: Fixed » Active

So I think the "Stopped working" perception on my part was that all the banners suddenly expired, as mentioned in another issue.

jeremy’s picture

Correct. So why did you mark this issue as active again?

jeremy’s picture

Status: Active » Fixed

Ah, looking at timestamps I think you were updating this issue at the same time I was. Marking "fixed" again.

Anonymous’s picture

Status: Fixed » Closed (fixed)