In the PHPdoc of the function WP_Widget::update()
located under wp-includes/widgets.php
it says the following:
/**
* ...
* This function should check that $new_instance is set correctly.
* The newly calculated value of $instance should be returned.
* If "false" is returned, the instance won't be saved/updated.
* ...
*/
It is unclear to me why the $old_instance
is needed when updating the values and how can it be used to validate that the $new_instance
is set correctly.
As the comment says, you should validate the values of the new instance. What happens if one of these values is invalid? You can either set a predefined default value or use the value from the old instance, because that must be valid.
So a very simple update code could look like this:
function update( $new_instance, $old_instance )
{
return array_merge( $old_instance, $new_instance );
}
There is no better way to get this information, so WordPress just passes it along in case you need it. But you are free to ignore it completely.