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 { ...@@ -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 * @access public
* @return boolean * @return boolean
*/ */
public function StripData() { public function StripData($noHierarchyCache = true) {
unset($this->changed); unset($this->changed);
unset($this->unsetdata); unset($this->unsetdata);
unset($this->hierarchyCache);
unset($this->forceSave); unset($this->forceSave);
unset($this->newdevice); unset($this->newdevice);
unset($this->ignoredMessageIds); unset($this->ignoredMessageIds);
unset($this->backend2folderidCache);
if (isset($this->ignoredmessages) && is_array($this->ignoredmessages)) { if (isset($this->ignoredmessages) && is_array($this->ignoredmessages)) {
$imessages = $this->ignoredmessages; $imessages = $this->ignoredmessages;
...@@ -199,6 +201,14 @@ class ASDevice extends StateObject { ...@@ -199,6 +201,14 @@ class ASDevice extends StateObject {
$this->ignoredmessages = $unserializedMessage; $this->ignoredmessages = $unserializedMessage;
} }
if (!$noHierarchyCache && $this->hierarchyCache !== false && $this->hierarchyCache instanceof ChangesMemoryWrapper) {
$this->hierarchyCache->StripData();
}
else {
unset($this->hierarchyCache);
}
return true; return true;
} }
......
...@@ -69,11 +69,12 @@ class ZPushAdmin { ...@@ -69,11 +69,12 @@ class ZPushAdmin {
* *
* @param string $devid device id * @param string $devid device id
* @param string $user user to be looked up * @param string $user user to be looked up
* @param boolean $withHierarchyCache (opt) includes the HierarchyCache - default: false
* *
* @return ASDevice object * @return ASDevice object
* @access public * @access public
*/ */
static public function GetDeviceDetails($devid, $user) { static public function GetDeviceDetails($devid, $user, $withHierarchyCache = false) {
try { try {
$device = new ASDevice($devid, ASDevice::UNDEFINED, $user, ASDevice::UNDEFINED); $device = new ASDevice($devid, ASDevice::UNDEFINED, $user, ASDevice::UNDEFINED);
...@@ -127,7 +128,7 @@ class ZPushAdmin { ...@@ -127,7 +128,7 @@ class ZPushAdmin {
} }
} }
} }
$device->StripData(); $device->StripData(!$withHierarchyCache);
return $device; return $device;
} }
catch (StateNotFoundException $e) { catch (StateNotFoundException $e) {
......
...@@ -50,16 +50,18 @@ class WebserviceDevice { ...@@ -50,16 +50,18 @@ class WebserviceDevice {
/** /**
* Returns the details of a given deviceid of the Request::GetGETUser(). * Returns the details of a given deviceid of the Request::GetGETUser().
* *
* @param boolean $withHierarchyCache (opt) includes the HierarchyCache - default: false
*
* @access public * @access public
* @return ASDevice object * @return ASDevice object
*/ */
public function GetDeviceDetails($deviceId) { public function GetDeviceDetails($deviceId, $withHierarchyCache = false) {
$user = Request::GetGETUser(); $user = Request::GetGETUser();
$deviceId = preg_replace("/[^A-Za-z0-9]/", "", $deviceId); $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)); 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); 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