Commit 59c8a9cb authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-1197 Make stripping of HierarchyCache from ASDevice optional, expose

optional stripping to webservice (default: strip).

Released under the Affero GNU General Public License (AGPL) version 3.
parent 98894c0e
......@@ -175,18 +175,20 @@ class ASDevice extends StateObject {
}
/**
* Removes internal data from the object, so this data can not be exposed
* Removes internal data from the object, so this data can not be exposed.
*
* @param boolean $noHierarchyCache (opt) strips the hierarchy cache - default: true
*
* @access public
* @return boolean
*/
public function StripData() {
public function StripData($noHierarchyCache = true) {
unset($this->changed);
unset($this->unsetdata);
unset($this->hierarchyCache);
unset($this->forceSave);
unset($this->newdevice);
unset($this->ignoredMessageIds);
unset($this->backend2folderidCache);
if (isset($this->ignoredmessages) && is_array($this->ignoredmessages)) {
$imessages = $this->ignoredmessages;
......@@ -199,6 +201,14 @@ class ASDevice extends StateObject {
$this->ignoredmessages = $unserializedMessage;
}
if (!$noHierarchyCache && $this->hierarchyCache !== false && $this->hierarchyCache instanceof ChangesMemoryWrapper) {
$this->hierarchyCache->StripData();
}
else {
unset($this->hierarchyCache);
}
return true;
}
......
......@@ -69,11 +69,12 @@ class ZPushAdmin {
*
* @param string $devid device id
* @param string $user user to be looked up
* @param boolean $withHierarchyCache (opt) includes the HierarchyCache - default: false
*
* @return ASDevice object
* @access public
*/
static public function GetDeviceDetails($devid, $user) {
static public function GetDeviceDetails($devid, $user, $withHierarchyCache = false) {
try {
$device = new ASDevice($devid, ASDevice::UNDEFINED, $user, ASDevice::UNDEFINED);
......@@ -127,7 +128,7 @@ class ZPushAdmin {
}
}
}
$device->StripData();
$device->StripData(!$withHierarchyCache);
return $device;
}
catch (StateNotFoundException $e) {
......
......@@ -50,16 +50,18 @@ class WebserviceDevice {
/**
* Returns the details of a given deviceid of the Request::GetGETUser().
*
* @param boolean $withHierarchyCache (opt) includes the HierarchyCache - default: false
*
* @access public
* @return ASDevice object
*/
public function GetDeviceDetails($deviceId) {
public function GetDeviceDetails($deviceId, $withHierarchyCache = false) {
$user = Request::GetGETUser();
$deviceId = preg_replace("/[^A-Za-z0-9]/", "", $deviceId);
ZLog::Write(LOGLEVEL_INFO, sprintf("WebserviceDevice::GetDeviceDetails('%s'): getting device details from state of user '%s'", $deviceId, $user));
ZPush::GetTopCollector()->AnnounceInformation(sprintf("Retrieved details of device '%s'", $deviceId), true);
return ZPushAdmin::GetDeviceDetails($deviceId, $user);
return ZPushAdmin::GetDeviceDetails($deviceId, $user, $withHierarchyCache);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment