Skip to content
Browse files

fix for 4582: "uknown error" when saving user profile

Changed coordinates were detected due to direct comparison of float numbers
in row editor. This caused unexpected state when saving unchanged user
profile details.

Fixed by adding epsilon threshold.
  • Loading branch information...
following committed Oct 28, 2012
1 parent b298bfc commit 42c1f54f99debd7095fff81972006f389832f2f6
Showing with 8 additions and 1 deletion.
  1. +8 −1 htdocs/lib2/logic/rowEditor.class.php
@@ -346,7 +346,14 @@ function setValue($sField, $sValue)
return false;
$sFormatedValue = $this->pFormatValue($this->fields[$sField]['type'], $sValue);
if ($this->fields[$sField]['value'] != $sFormatedValue)
if ($this->fields[$sField]['type'] == RE_TYPE_FLOAT)
// Direct float comparison is deprecated and can result in last-digit errors.
// Floats in OC database are only used for reasonably large numbers like coordinates,
// waylengths and time estimates, so using a fixed epsilon threshold is safe:
$changed = (abs($sFormatedValue - $this->fields[$sField]['value']) >= 1e-13);
$changed = ($sFormatedValue != $this->fields[$sField]['value']);
if ($changed)
$this->fields[$sField]['value'] = $sFormatedValue;
$this->fields[$sField]['changed'] = true;

0 comments on commit 42c1f54

Please sign in to comment.
You can’t perform that action at this time.