user_set_preference(): minor optimisation

Don't update if the values already match...
This commit is contained in:
martinlanghoff
2007-09-19 07:01:41 +00:00
parent 1f3c9d097f
commit a1244706be
+3
View File
@@ -786,6 +786,9 @@ function set_user_preference($name, $value, $otheruserid=NULL) {
// no pernament storage for not-logged-in user and guest
} else if ($preference = get_record('user_preferences', 'userid', $userid, 'name', addslashes($name))) {
if ($preference->value === $value) {
return true;
}
if (!set_field('user_preferences', 'value', addslashes((string)$value), 'id', $preference->id)) {
$return = false;
}