Hi
Today morning, i've found this error : Fatal error: Cannot access empty property in /var/www/raccourci.fr/drupal/sites/all/modules/ad/adserve.inc on line 133
What' s the problem?

This is the code on the line 133 :

if (!$overridden) {
    if (isset($conf)) {
      foreach ($conf as $var => $val) {
        $variables->$var = $val;
        if ($variables->debug) {
          echo "Override $var: '$val'<br />\n";
        }
      }
      $overridden = TRUE;
    }
  }

I think that line : $variables->$var = $val;
Is the problem
particulary ->$var

Comments

Shutnic’s picture

 if (!empty($var)) {
                $variables->$var = $val;
                if ($variables->debug) {
                    echo "Override $var: '$val'<br />\n";
                }
             } 
bbc’s picture

Same problem here on 6.x-2.2. I got the error on attempts to flush the cache, run database updates and when running cron. I tried the suggested change from Shutnic in comment #1 above and it solved the problem for me.

Also, this appears to be a duplicate of http://drupal.org/node/877482

Thanks Shutnic!

WeRockYourWeb.com’s picture

Thanks Shutnic, I replaced lines 130-145 with the following and flushing cache works now:

  if (!$overridden) {
    if (isset($conf)) {
      foreach ($conf as $var => $val) {
if (!empty($var)) {
                $variables->$var = $val;
                if ($variables->debug) {
                    echo "Override $var: '$val'<br />\n";
                }
             } 
        if ($variables->debug) {
          echo "Override $var: '$val'<br />\n";
        }
      }
      $overridden = TRUE;
    }
  }
Priyanka Singh’s picture

wow ..thanks Shutnic..it worked...

bbc’s picture

It seems this issue remains in 6.x-2.3 and 6.x-2.4. In this case, I was getting the error "The external command could not be executed due to an application error" when attempting to upgrade the module using drush. Downloading the latest version manually and reapplying the patch from above to adserve.inc took care of the issue.

john franklin’s picture

Could you do me a favor? On a test version of your site add a "var_dump(array_keys($conf));" between the isset() and foreach() lines. Somewhere in your $conf you you have an empty key, NULL or 0, none of which belong in your site's config array.

WeRockYourWeb.com’s picture

Getting the error again with the latest release (with or without the patch), and when I try to add var_dump(array_keys($conf)); or update the module, this error shows up as well: Parse error: syntax error, unexpected '!' in /modules/ad/adserve.inc on line 342

andrewfn’s picture

The fix in #3 worked perfectly for me,
Thanks WeRockYourWeb.com
Can we get this into a patch?

andrewfn’s picture

Issue summary: View changes

This problem is still here.
Just had the annoyance of having to re-patch the latest dev
Please could it get committed?

lrwebks’s picture

Status: Active » Closed (outdated)

Drupal 6 is EOL and no longer supported. Closing this as outdated for that reason. Thanks for your contribution!