Bug in update_option() (3 posts)

  1. RoscoHead
    Posted 8 years ago #

    Hi, I think I've hit a bug in the update_option() function. The problem occurs when the $newvalue is an array containing arrays - it checks

    $oldvalue = get_option($option_name);
    if ( $newvalue) == $oldvalue) ) {

    to see if the value has changed. However this behaves incorrectly when the only change is in the order of elements of the sub-array, the comparison returns true, so the setting is never updated.

    My workaround is to do a comparison on the serialized versions instead:

    if ( maybe_serialize($newvalue) == maybe_serialize($oldvalue) ) {

    This seems to work, and doesn't seem to break anything, but it has only been minimally tested. If there's a better way to fix the problem, feel free to ignore my suggested fix :)


  2. onocrotalus
    Posted 8 years ago #

    I don't know enough to comment on your problem, but I think bugs should be searched for on http://trac.wordpress.org and reported there if new.

  3. RoscoHead
    Posted 8 years ago #

    Thanks, done.

Topic Closed

This topic has been closed to new replies.

About this Topic