Fatal error: Call to undefined method stdClass::get_network_property_defaults()
-
This seems to be the worst error that has been plaguing Advertising Manager for many years, and a fix apparently is not likely.
Basically, creating or editing a new ad fail with an empty page with a cryptic error on the logs, something like this (the error might be different depending on operating system and web server; I’m using nginx on Ubuntu):
PHP Warning: Creating default object from empty value in /var/www/clients/client3/web4/web/wp-content/plugins/advertising-manager/lib/Advman/Admin.php on line 55 PHP Fatal error: Call to undefined method stdClass::get_network_property_defaults() in /var/www/clients/client3/web4/web/wp-content/plugins/advertising-manager/lib/Advman/Admin.php on line 69 PHP Warning: Creating default object from empty value in /var/www/clients/client3/web4/web/wp-content/plugins/advertising-manager/lib/Advman/Admin.php PHP Fatal error: Call to undefined method stdClass::add_revision() in /var/www/clients/client3/web4/web/wp-content/plugins/advertising-manager/lib/OX/Swifty.php
A possible fix:
On
wp-content/plugins/advertising-manager/lib/Advman/Admin.php
, line 54, change:if ($value != $ad->name) { Advman_Admin::check_default($ad, $ad->name = $value; $changed = true; }
to
if (property_exists($ad, 'name')) { if ($value != $ad->name) { Advman_Admin::check_default($ad, $ad->name = $value; $changed = true; } }
On
wp-content/plugins/advertising-manager/lib/Advman/Admin.php
, line 62, change:if ($ad->active != $value) { $ad->active = $value; $changed = true; }
to:
if (property_exists($ad, 'active')) { if ($ad->active != $value) { $ad->active = $value; $changed = true; } }
On
wp-content/plugins/advertising-manager/lib/Advman/Admin.php
, line 69, change:$properties = $ad->get_network_property_defaults();
to
if (property_exists($ad, 'get_network_property_defaults')) { $properties = $ad->get_network_property_defaults(); } else { $properties = array(); }
On
/wp-content/plugins/advertising-manager/lib/OX/Swifty.php
, line 102, change:$ad->add_revision(); return $this->dal->update_ad($ad);
to:
if (property_exists($ad, 'add_revision')) { $ad->add_revision(); return $this->dal->update_ad($ad); } else { return NULL; }
This stops the errors, but it also means that the changes do not get saved.
For four years this problem has been plaguing many users. I <i>think</i> that the problem is with versions of PHP 5.4 or newer (I’m using 5.5), where calling things by reference have been seriously restricted. Thus, what seems to happen is that
$ad
is empty at some point, and, when passing it as a reference, a new, standard object is created, which of course has all the methods inside it missing. Then everything else fails.I’ve done a bit of testing. On
Admin.php
, insideprocess()
, at some point we have the following code:// For operations on a single ad if (is_numeric($target)) { $id = intval($target); $ad = $advman_engine->getAd($id); }
So technically this should return $ad as an object of the appropriate class. When creating/editing an ad, I’ve tested, and this returns an empty object. No wonder everything fails from then on.
Putting the following code immediately after the function declaration for
save_properties
:function save_properties(&$ad, $default = false) { global $advman_engine; if (empty($ad)) { ?> <div class="error"> <p> <strong>Error: </strong>$ad is empty! </p> </div> <?php }
will always print the error.
The code is a bit obscure for me to follow. Apparently,
$advman_engine
is an object of classOX_Swifty
, instantiated asAdvman_Dal
.getAd()
is a method which points toselect_ad()
inSwifty.php
. This, in turn, callsdal->select_ad()
which is a method declared inDal.php
… which is empty!An obscure reference made in 2010 (!) points to a fix to be done on
lib/OX/Ad.php
on line 168. Sadly, the domain where this blog used to be hosted is down (and has been down probably for years). Because the owner of that domain prevented this site to be crawled, Google doesn’t have a cached copy of it, and neither has Archive.org. Whatever the fix was, it is now gone forever.Looking at
lib/OX/Ad.php
, line 168 is not especially obvious. It points to the middle of the property extraction process (searching for tags). It’s possible thatAd.php
was quite different in 2010, when that bug was fixed. I looked a bit around that block of code to see if something is obviously wrong, but I couldn’t find anything. However, I found something which might get a clue. In some rare occasions, I can create a new ad. But when editing it and saving it, no changes are made. This tends to point to some error when saving/serializing properties.Anyway, I’m stumped. The developer has said that he’s back, and updating this plugin’s code. I hope he reads this and tests it out on a more recent version of PHP. I’m pretty sure it worked fine under PHP 5.3, and that strongly hints at a problem in passing things by reference…
- The topic ‘Fatal error: Call to undefined method stdClass::get_network_property_defaults()’ is closed to new replies.