[wp-testers] update_option() not always working in WP 3.0 beta 2

andrea andrea at blogsweek.com
Wed May 19 19:43:42 UTC 2010

Hi all,

In a plugin I store an object in an option, and the typical flow is as follows:

$value = get_option ($option_name);
$value->var1 = $new_var1;
update_option ($option_name, $value);
$value->var2 = $new_var2;
update_option ($option_name, $value);
$value->var3 = $new_var3;
update_option ($option_name, $value);

and so on. That used to work fine with WP 2.9.2, both with PHP4 and PHP5.

With WP 3.0 beta 2 and PHP4, no problem.

With WP 3.0 beta 2 and PHP5, apparently only the first update_option() call is
honored, and following calls are not honored because update_option() finds that

$newvalue === $oldvalue (lines 503-504 in wp-includes/functions.php)

and does not update the database. If I remove those two lines, the plugin works
again. If in my code I replace

update_option ($option_name, $value);


update_option ($option_name, 0);
update_option ($option_name, $value);

the plugin works as well.

According to a user report I received, the problem was first noted in
WordPress 3.0 alpha (svn13807 – 2010.03.23 @ 20.03).

Is this issue already known? Or am I missing something? If interested, the
plugin that stopped working in WP 3.0 is Menubar 4.7.

Thank you all

Andrea Tarantini

More information about the wp-testers mailing list