Skip to content

Commit

Permalink
Only save to backend if the data is dirty.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Oct 4, 2013
1 parent acc1a55 commit f1907a8
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions framework/ActiveSync/lib/Horde/ActiveSync/Device.php
Expand Up @@ -60,6 +60,13 @@ class Horde_ActiveSync_Device
*/
protected $_state;

/**
* Dirty flag
*
* @var boolean
*/
protected $_dirty = false;

/**
* Const'r
*
Expand All @@ -77,15 +84,22 @@ public function __construct(Horde_ActiveSync_State_Base $state, array $data = ar
*/
public function &__get($property)
{
return $this->_properties[$property];
if (isset($this->_properties[$property])) {
return $this->_properties[$property];
} else {
return null;
}
}

/**
* Setter
*/
public function __set($property, $value)
{
$this->_properties[$property] = $value;
if ($value != $this->_properties[$property]) {
$this->_dirty = true;
$this->_properties[$property] = $value;
}
}

/**
Expand Down Expand Up @@ -216,7 +230,10 @@ public function getLastSyncTimestamp()

public function save()
{
$this->_state->setDeviceInfo($this);
if ($this->_dirty) {
$this->_state->setDeviceInfo($this);
$this->_dirty = false;
}
}

}
}

0 comments on commit f1907a8

Please sign in to comment.