Support » Requests and Feedback » Bug in update_option()

Bug in update_option()

  • 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 🙂


Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Bug in update_option()’ is closed to new replies.