Closed (fixed)
Project:
Advertisement
Version:
6.x-1.1
Component:
adserve.php
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
18 Mar 2009 at 17:26 UTC
Updated:
10 Apr 2009 at 17:40 UTC
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.
| Comment | File | Size | Author |
|---|---|---|---|
| create-object.patch | 401 bytes | Garrett Albright |
Comments
Comment #1
Garrett Albright commentedOops. Updating issue to indicate that I've attached a patch.
Set error_reporting to
E_ALL | E_STRICTin your php.ini to see this error, by the way.Comment #2
jeremy commentedThanks. Fix applied to 6.x-2.x-dev.
Comment #3
jeremy commentedFix also applied to 6.x-1.x-dev. Thanks!