Skip to content

Commit

Permalink
Allow device info to be reloaded within same request.
Browse files Browse the repository at this point in the history
Needed so when we check remote wipe status during long running
PING/SYNC requests we don't keep checking the same, originally loaded
data.
  • Loading branch information
mrubinsk committed Jan 3, 2016
1 parent 73448d6 commit 104f263
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
18 changes: 16 additions & 2 deletions framework/ActiveSync/lib/Horde/ActiveSync/State/Base.php
Expand Up @@ -196,16 +196,25 @@ public function getPolicyKey($devId)
* Return a device wipe status
*
* @param string $devId
* @param boolean $refresh If true, reload the device's rwstatus flag.
* @since 2.31.0
*
* @return integer
*/
public function getDeviceRWStatus($devId)
public function getDeviceRWStatus($devId, $refresh = false)
{
/* See if we have it already */
if (empty($this->_deviceInfo) || $this->_deviceInfo->id != $devId) {
throw new Horde_ActiveSync_Exception('Device not loaded.');
}

/* Should we refresh? */
if ($refresh) {
$this->loadDeviceInfo(
$this->_deviceInfo->user, $this->_deviceInfo->id, array('force' => true)
);
}

return $this->_deviceInfo->rwstatus;
}

Expand Down Expand Up @@ -955,10 +964,15 @@ abstract public function setDeviceRWStatus($devId, $status);
*
* @param object $device
* @param string $user
* @param array $params Additional parameters:
* - force: (boolean) If true, reload the device info even if it's
* already loaded. Used to refresh values such as device_rwstatus that
* may have changed during a long running PING/SYNC. DEFAULT: false.
* @since 2.31.0
*
* @return Horde_ActiveSync_Device
*/
abstract public function loadDeviceInfo($device, $user = null);
abstract public function loadDeviceInfo($device, $user = null, $params = array());

/**
* Check that a given device id is known to the server. This is regardless
Expand Down
9 changes: 7 additions & 2 deletions framework/ActiveSync/lib/Horde/ActiveSync/State/Sql.php
Expand Up @@ -541,14 +541,19 @@ public function updateState(
*
* @param string $devId The device id to obtain
* @param string $user The user to retrieve user-specific device info for
* @param array $params Additional parameters:
* - force: (boolean) If true, reload the device info even if it's
* already loaded. Used to refresh values such as device_rwstatus that
* may have changed during a long running PING/SYNC. DEFAULT: false.
* @since 2.31.0
*
* @return Horde_ActiveSync_Device The device object
* @throws Horde_ActiveSync_Exception
*/
public function loadDeviceInfo($devId, $user = null)
public function loadDeviceInfo($devId, $user = null, $params = array())
{
// See if we already have this device, for this user loaded
if (!empty($this->_deviceInfo) && $this->_deviceInfo->id == $devId &&
if (empty($params['force']) && !empty($this->_deviceInfo) && $this->_deviceInfo->id == $devId &&
!empty($this->_deviceInfo) &&
$user == $this->_deviceInfo->user) {
return $this->_deviceInfo;
Expand Down

0 comments on commit 104f263

Please sign in to comment.