When strict error checking is enabled, this warning occurs, because the code attempts to treat a null value as an object without converting it first. Due to this, ads may not show on servers with strict mode - if error printing is enabled, the server prints the error in the JavaScript that serve.php is returning, causing a parsing failure.

function adserve_variable($variable, $value = NULL) {
  global $conf;
  static $variables = NULL, $overridden = NULL, $cache_loaded = array();

  // snip

    // Don't use getcwd as path may involve symbolic links
    $variables->ad_dir = dirname($_SERVER['SCRIPT_FILENAME']); // <== Line 320
    // 'debug' is an integer.
    $variables->debug = isset($values['debug']) ? (int)$values['debug'] : 0;
    // Cache types are comprised of only letters.
    $variables->adcache = isset($values['c']) ? preg_replace('/[^a-zA-Z]/', '', $values['c']) : 'none';
    // etc…

Since creating a new object after the static keyword seems to cause an error (static $variables = new stdClass() doesn't work), this simple patch just checks if $variables === NULL on the next line and turns it into a stdClass() if so.

CommentFileSizeAuthor
create-object.patch401 bytesGarrett Albright

Comments

Garrett Albright’s picture

Status: Active » Needs review

Oops. Updating issue to indicate that I've attached a patch.

Set error_reporting to E_ALL | E_STRICT in your php.ini to see this error, by the way.

jeremy’s picture

Status: Needs review » Reviewed & tested by the community
jeremy’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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