Commit 7d46686c authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #109 in ZP/z-push from bugfix/ZP-795-typo-small-fixes to develop

* commit '2676adfb':
  ZP-795 hhvm fix: GetCutOffDate in utils.php.
  ZP-795 hhvm fix: use break instead of continue in switch.
  ZP-795 hhvm fix: {} -> [].
  ZP-795 hhvm fix: use bool instead of boolean.
  ZP-795 remove unused code.
  ZP-795 fix indentation.
  ZP-795 add parentheses to be sure of what we want.
  ZP-795 fix some bad sprintf.
  ZP-795 remove useless assignment.
parents 1a029c27 2676adfb
...@@ -1192,7 +1192,7 @@ class BackendIMAP extends BackendDiff { ...@@ -1192,7 +1192,7 @@ class BackendIMAP extends BackendDiff {
$attachment = new SyncBaseAttachment(); $attachment = new SyncBaseAttachment();
$attachment->estimatedDataSize = isset($part->d_parameters['size']) ? $part->d_parameters['size'] : isset($part->body) ? strlen($part->body) : 0; $attachment->estimatedDataSize = isset($part->d_parameters['size']) ? $part->d_parameters['size'] : (isset($part->body) ? strlen($part->body) : 0);
$attachment->displayname = $attname; $attachment->displayname = $attname;
$attachment->filereference = $folderid . ":" . $id . ":" . $i; $attachment->filereference = $folderid . ":" . $id . ":" . $i;
...@@ -1213,7 +1213,7 @@ class BackendIMAP extends BackendDiff { ...@@ -1213,7 +1213,7 @@ class BackendIMAP extends BackendDiff {
$attachment = new SyncAttachment(); $attachment = new SyncAttachment();
$attachment->attsize = isset($part->d_parameters['size']) ? $part->d_parameters['size'] : isset($part->body) ? strlen($part->body) : 0; $attachment->attsize = isset($part->d_parameters['size']) ? $part->d_parameters['size'] : (isset($part->body) ? strlen($part->body) : 0);
$attachment->displayname = $attname; $attachment->displayname = $attname;
$attachment->attname = $folderid . ":" . $id . ":" . $i; $attachment->attname = $folderid . ":" . $id . ":" . $i;
......
...@@ -108,7 +108,7 @@ class LoopDetection extends InterProcessData { ...@@ -108,7 +108,7 @@ class LoopDetection extends InterProcessData {
*/ */
public static function GetProcessIdentifier() { public static function GetProcessIdentifier() {
if (!isset(self::$processident)) if (!isset(self::$processident))
self::$processident = sprintf('%04x%04', mt_rand(0, 0xffff), mt_rand(0, 0xffff)); self::$processident = sprintf('%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff));
return self::$processident; return self::$processident;
} }
......
...@@ -316,8 +316,8 @@ class StateManager { ...@@ -316,8 +316,8 @@ class StateManager {
*/ */
public function SetBackendStorage($data, $type = self::BACKENDSTORAGE_PERMANENT) { public function SetBackendStorage($data, $type = self::BACKENDSTORAGE_PERMANENT) {
if ($type == self::BACKENDSTORAGE_STATE) { if ($type == self::BACKENDSTORAGE_STATE) {
if (!$this->uuid) if (!$this->uuid)
throw new StateNotYetAvailableException(); throw new StateNotYetAvailableException();
// TODO serialization should be done in the StateMachine // TODO serialization should be done in the StateMachine
return $this->statemachine->SetState($data, $this->device->GetDeviceId(), IStateMachine::BACKENDSTORAGE, $this->uuid, $this->newStateCounter); return $this->statemachine->SetState($data, $this->device->GetDeviceId(), IStateMachine::BACKENDSTORAGE, $this->uuid, $this->newStateCounter);
......
...@@ -303,7 +303,7 @@ abstract class Backend implements IBackend { ...@@ -303,7 +303,7 @@ abstract class Backend implements IBackend {
} }
if (isset($this->stateStorage)) { if (isset($this->stateStorage)) {
try { try {
$this->storage_state = ZPush::GetDeviceManager()->GetStateManager()->SetBackendStorage($this->stateStorage, StateManager::BACKENDSTORAGE_STATE); ZPush::GetDeviceManager()->GetStateManager()->SetBackendStorage($this->stateStorage, StateManager::BACKENDSTORAGE_STATE);
} }
catch (StateNotYetAvailableException $snyae) { } catch (StateNotYetAvailableException $snyae) { }
catch(StateNotFoundException $snfe) { } catch(StateNotFoundException $snfe) { }
......
...@@ -52,9 +52,6 @@ class FolderSync extends RequestProcessor { ...@@ -52,9 +52,6 @@ class FolderSync extends RequestProcessor {
* @return boolean * @return boolean
*/ */
public function Handle ($commandCode) { public function Handle ($commandCode) {
// Maps serverid -> clientid for items that are received from the PIM
$map = array();
// Parse input // Parse input
if(!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_FOLDERSYNC)) if(!self::$decoder->getElementStartTag(SYNC_FOLDERHIERARCHY_FOLDERSYNC))
return false; return false;
...@@ -141,10 +138,6 @@ class FolderSync extends RequestProcessor { ...@@ -141,10 +138,6 @@ class FolderSync extends RequestProcessor {
$serverid = $changesMem->ImportFolderDeletion($folder); $serverid = $changesMem->ImportFolderDeletion($folder);
break; break;
} }
// TODO what does $map??
if($serverid)
$map[$serverid] = $folder->clientid;
} }
else { else {
ZLog::Write(LOGLEVEL_WARN, sprintf("Request->HandleFolderSync(): ignoring incoming folderchange for folder '%s' as status indicates problem.", $folder->displayname)); ZLog::Write(LOGLEVEL_WARN, sprintf("Request->HandleFolderSync(): ignoring incoming folderchange for folder '%s' as status indicates problem.", $folder->displayname));
......
...@@ -91,7 +91,7 @@ class GetItemEstimate extends RequestProcessor { ...@@ -91,7 +91,7 @@ class GetItemEstimate extends RequestProcessor {
elseif(self::$decoder->getElementStartTag(SYNC_CONVERSATIONMODE)) { elseif(self::$decoder->getElementStartTag(SYNC_CONVERSATIONMODE)) {
$spa->SetConversationMode(true); $spa->SetConversationMode(true);
if(($conversationmode = self::$decoder->getElementContent()) !== false) { if(($conversationmode = self::$decoder->getElementContent()) !== false) {
$spa->SetConversationMode((boolean)$conversationmode); $spa->SetConversationMode((bool)$conversationmode);
if(!self::$decoder->getElementEndTag()) if(!self::$decoder->getElementEndTag())
return false; return false;
} }
......
...@@ -213,7 +213,7 @@ class ItemOperations extends RequestProcessor { ...@@ -213,7 +213,7 @@ class ItemOperations extends RequestProcessor {
if(self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_DELETESUBFOLDERS)) { if(self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_DELETESUBFOLDERS)) {
$operation['deletesubfolders'] = true; $operation['deletesubfolders'] = true;
if (($dsf = self::$decoder->getElementContent()) !== false) { if (($dsf = self::$decoder->getElementContent()) !== false) {
$operation['deletesubfolders'] = (boolean)$dsf; $operation['deletesubfolders'] = (bool)$dsf;
if(!self::$decoder->getElementEndTag()) if(!self::$decoder->getElementEndTag())
return false; return false;
} }
......
...@@ -211,7 +211,7 @@ class Sync extends RequestProcessor { ...@@ -211,7 +211,7 @@ class Sync extends RequestProcessor {
if(self::$decoder->getElementStartTag(SYNC_DELETESASMOVES)) { if(self::$decoder->getElementStartTag(SYNC_DELETESASMOVES)) {
$spa->SetDeletesAsMoves(true); $spa->SetDeletesAsMoves(true);
if (($dam = self::$decoder->getElementContent()) !== false) { if (($dam = self::$decoder->getElementContent()) !== false) {
$spa->SetDeletesAsMoves((boolean)$dam); $spa->SetDeletesAsMoves((bool)$dam);
if(!self::$decoder->getElementEndTag()) { if(!self::$decoder->getElementEndTag()) {
return false; return false;
} }
...@@ -249,7 +249,7 @@ class Sync extends RequestProcessor { ...@@ -249,7 +249,7 @@ class Sync extends RequestProcessor {
if(self::$decoder->getElementStartTag(SYNC_CONVERSATIONMODE)) { if(self::$decoder->getElementStartTag(SYNC_CONVERSATIONMODE)) {
$spa->SetConversationMode(true); $spa->SetConversationMode(true);
if(($conversationmode = self::$decoder->getElementContent()) !== false) { if(($conversationmode = self::$decoder->getElementContent()) !== false) {
$spa->SetConversationMode((boolean)$conversationmode); $spa->SetConversationMode((bool)$conversationmode);
if(!self::$decoder->getElementEndTag()) if(!self::$decoder->getElementEndTag())
return false; return false;
} }
...@@ -876,7 +876,7 @@ class Sync extends RequestProcessor { ...@@ -876,7 +876,7 @@ class Sync extends RequestProcessor {
// check if the message is broken // check if the message is broken
if (ZPush::GetDeviceManager(false) && ZPush::GetDeviceManager()->DoNotStreamMessage($id, $data)) { if (ZPush::GetDeviceManager(false) && ZPush::GetDeviceManager()->DoNotStreamMessage($id, $data)) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): message not to be streamed as requested by DeviceManager.", $id)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): message not to be streamed as requested by DeviceManager, id = %s", $id));
$fetchstatus = SYNC_STATUS_CLIENTSERVERCONVERSATIONERROR; $fetchstatus = SYNC_STATUS_CLIENTSERVERCONVERSATIONERROR;
} }
} }
...@@ -1143,7 +1143,7 @@ class Sync extends RequestProcessor { ...@@ -1143,7 +1143,7 @@ class Sync extends RequestProcessor {
private function importMessage($spa, &$actiondata, $todo, $message, $clientid, $serverid, $foldertype, $messageCount) { private function importMessage($spa, &$actiondata, $todo, $message, $clientid, $serverid, $foldertype, $messageCount) {
// the importer needs to be available! // the importer needs to be available!
if ($this->importer == false) if ($this->importer == false)
throw StatusException(sprintf("Sync->importMessage(): importer not available", SYNC_STATUS_SERVERERROR)); throw StatusException("Sync->importMessage(): importer not available", SYNC_STATUS_SERVERERROR);
// mark this state as used, e.g. for HeartBeat // mark this state as used, e.g. for HeartBeat
self::$deviceManager->SetHeartbeatStateIntegrity($spa->GetFolderId(), $spa->GetUuid(), $spa->GetUuidCounter()); self::$deviceManager->SetHeartbeatStateIntegrity($spa->GetFolderId(), $spa->GetUuid(), $spa->GetUuidCounter());
......
...@@ -337,14 +337,10 @@ class Utils { ...@@ -337,14 +337,10 @@ class Utils {
$back = 60 * 60 * 24 * 31 * 6; $back = 60 * 60 * 24 * 31 * 6;
break; break;
default: default:
break; return 0; // unlimited
} }
if(isset($back)) { return time() - $back;
$date = time() - $back;
return $date;
} else
return 0; // unlimited
} }
/** /**
...@@ -441,18 +437,18 @@ class Utils { ...@@ -441,18 +437,18 @@ class Utils {
$len = strlen($string) - 1; $len = strlen($string) - 1;
while ($len > 0) { while ($len > 0) {
//look for '&-' sequence and replace it with '&' //look for '&-' sequence and replace it with '&'
if ($len > 0 && $string{($len-1)} == '&' && $string{$len} == '-') { if ($len > 0 && $string[$len-1] == '&' && $string[$len] == '-') {
$string = substr_replace($string, '&', $len - 1, 2); $string = substr_replace($string, '&', $len - 1, 2);
$len--; //decrease $len as this char has alreasy been processed $len--; //decrease $len as this char has alreasy been processed
} }
//search for '&' which weren't found in if clause above and //search for '&' which weren't found in if clause above and
//replace them with '+' as they mark an utf7-encoded char //replace them with '+' as they mark an utf7-encoded char
if ($len > 0 && $string{($len-1)} == '&') { if ($len > 0 && $string[($len-1)] == '&') {
$string = substr_replace($string, '+', $len - 1, 1); $string = substr_replace($string, '+', $len - 1, 1);
$len--; //decrease $len as this char has alreasy been processed $len--; //decrease $len as this char has alreasy been processed
} }
//finally "escape" all remaining '+' chars //finally "escape" all remaining '+' chars
if ($len > 0 && $string{($len-1)} == '+') { if ($len > 0 && $string[$len-1] == '+') {
$string = substr_replace($string, '+-', $len - 1, 1); $string = substr_replace($string, '+-', $len - 1, 1);
} }
$len--; $len--;
...@@ -479,18 +475,18 @@ class Utils { ...@@ -479,18 +475,18 @@ class Utils {
$len = strlen($string) - 1; $len = strlen($string) - 1;
while ($len > 0) { while ($len > 0) {
//look for '&-' sequence and replace it with '&' //look for '&-' sequence and replace it with '&'
if ($len > 0 && $string{($len-1)} == '+' && $string{$len} == '-') { if ($len > 0 && $string[$len-1] == '+' && $string[$len] == '-') {
$string = substr_replace($string, '+', $len - 1, 2); $string = substr_replace($string, '+', $len - 1, 2);
$len--; //decrease $len as this char has alreasy been processed $len--; //decrease $len as this char has alreasy been processed
} }
//search for '&' which weren't found in if clause above and //search for '&' which weren't found in if clause above and
//replace them with '+' as they mark an utf7-encoded char //replace them with '+' as they mark an utf7-encoded char
if ($len > 0 && $string{($len-1)} == '+') { if ($len > 0 && $string[$len-1] == '+') {
$string = substr_replace($string, '&', $len - 1, 1); $string = substr_replace($string, '&', $len - 1, 1);
$len--; //decrease $len as this char has alreasy been processed $len--; //decrease $len as this char has alreasy been processed
} }
//finally "escape" all remaining '+' chars //finally "escape" all remaining '+' chars
if ($len > 0 && $string{($len-1)} == '&') { if ($len > 0 && $string[$len-1] == '&') {
$string = substr_replace($string, '&-', $len - 1, 1); $string = substr_replace($string, '&-', $len - 1, 1);
} }
$len--; $len--;
......
...@@ -759,7 +759,7 @@ class ZPushAdmin { ...@@ -759,7 +759,7 @@ class ZPushAdmin {
$users = self::ListUsers($devid); $users = self::ListUsers($devid);
foreach ($users as $username) { foreach ($users as $username) {
$seen++; $seen++;
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZPushAdmin::FixStatesDeviceToUserLinking(): linking user '%s' to device '%d'", $username, $devid)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZPushAdmin::FixStatesDeviceToUserLinking(): linking user '%s' to device '%s'", $username, $devid));
if (ZPush::GetStateMachine()->LinkUserDevice($username, $devid)) if (ZPush::GetStateMachine()->LinkUserDevice($username, $devid))
$fixed++; $fixed++;
......
...@@ -384,7 +384,7 @@ class WBXMLDecoder extends WBXMLDefs { ...@@ -384,7 +384,7 @@ class WBXMLDecoder extends WBXMLDefs {
switch($byte) { switch($byte) {
case WBXML_SWITCH_PAGE: case WBXML_SWITCH_PAGE:
$this->tagcp = $this->getByte(); $this->tagcp = $this->getByte();
continue; break;
case WBXML_END: case WBXML_END:
$element[EN_TYPE] = EN_TYPE_ENDTAG; $element[EN_TYPE] = EN_TYPE_ENDTAG;
......
...@@ -75,7 +75,7 @@ class Webservice { ...@@ -75,7 +75,7 @@ class Webservice {
// the webservice command is handled by its class // the webservice command is handled by its class
if ($commandCode == ZPush::COMMAND_WEBSERVICE_USERS) { if ($commandCode == ZPush::COMMAND_WEBSERVICE_USERS) {
if (!defined("ALLOW_WEBSERVICE_USERS_ACCESS") || ALLOW_WEBSERVICE_USERS_ACCESS !== true) if (!defined("ALLOW_WEBSERVICE_USERS_ACCESS") || ALLOW_WEBSERVICE_USERS_ACCESS !== true)
throw new HTTPReturnCodeException(sprintf("Access to the WebserviceUsers service is disabled in configuration. Enable setting ALLOW_WEBSERVICE_USERS_ACCESS.", Request::GetAuthUser()), 403); throw new HTTPReturnCodeException("Access to the WebserviceUsers service is disabled in configuration. Enable setting ALLOW_WEBSERVICE_USERS_ACCESS", 403);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Webservice::HandleWebservice('%s'): executing WebserviceUsers service", $commandCode)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("Webservice::HandleWebservice('%s'): executing WebserviceUsers service", $commandCode));
......
...@@ -327,7 +327,7 @@ class ZPushTop { ...@@ -327,7 +327,7 @@ class ZPushTop {
$this->scrPrintAt($lc,0, sprintf("Open connections: %d\t\t\t\tUsers:\t %d\tZ-Push: %s ",count($this->activeConn),count($this->activeUsers), $this->getVersion())); $lc++; $this->scrPrintAt($lc,0, sprintf("Open connections: %d\t\t\t\tUsers:\t %d\tZ-Push: %s ",count($this->activeConn),count($this->activeUsers), $this->getVersion())); $lc++;
$this->scrPrintAt($lc,0, sprintf("Push connections: %d\t\t\t\tDevices: %d\tPHP-MAPI: %s", $this->pushConn, count($this->activeDevices),phpversion("mapi"))); $lc++; $this->scrPrintAt($lc,0, sprintf("Push connections: %d\t\t\t\tDevices: %d\tPHP-MAPI: %s", $this->pushConn, count($this->activeDevices),phpversion("mapi"))); $lc++;
$this->scrPrintAt($lc,0, sprintf(" Hosts:\t %d", $this->pushConn, count($this->activeHosts))); $lc++; $this->scrPrintAt($lc,0, sprintf(" Hosts:\t %d", count($this->activeHosts))); $lc++;
$lc++; $lc++;
$this->scrPrintAt($lc,0, "\033[4m". $this->getLine(array('pid'=>'PID', 'ip'=>'IP', 'user'=>'USER', 'command'=>'COMMAND', 'time'=>'TIME', 'devagent'=>'AGENT', 'devid'=>'DEVID', 'addinfo'=>'Additional Information')). str_repeat(" ",20)."\033[0m"); $lc++; $this->scrPrintAt($lc,0, "\033[4m". $this->getLine(array('pid'=>'PID', 'ip'=>'IP', 'user'=>'USER', 'command'=>'COMMAND', 'time'=>'TIME', 'devagent'=>'AGENT', 'devid'=>'DEVID', 'addinfo'=>'Additional Information')). str_repeat(" ",20)."\033[0m"); $lc++;
...@@ -503,7 +503,7 @@ class ZPushTop { ...@@ -503,7 +503,7 @@ class ZPushTop {
} }
else if ($cmds[0] == "option" || $cmds[0] == "o") { else if ($cmds[0] == "option" || $cmds[0] == "o") {
if (!isset($cmds[1]) || $cmds[1] == "") { if (!isset($cmds[1]) || $cmds[1] == "") {
$this->status = sprintf("Option value needs to be specified. See 'help' or 'h' for instructions", $cmds[1]); $this->status = "Option value needs to be specified. See 'help' or 'h' for instructions";
$this->statusexpire = $this->currenttime+5; $this->statusexpire = $this->currenttime+5;
} }
else if ($cmds[1] == "p" || $cmds[1] == "push" || $cmds[1] == "ping") else if ($cmds[1] == "p" || $cmds[1] == "push" || $cmds[1] == "ping")
......
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