diff options
author | Matthias Held <ilovemilk@wusa.io> | 2019-06-03 20:37:56 +0300 |
---|---|---|
committer | Matthias Held <ilovemilk@wusa.io> | 2019-06-03 20:37:56 +0300 |
commit | 1570ee81336ebcc20cfea32ef842f899294dfc1c (patch) | |
tree | 246c80a55bd31b15cae2e133ed8e1090e6819b9b | |
parent | 950b356fabe83fc7f49e772be56799a1ce6b6ace (diff) |
fix missing user session by checking if they exist
-rw-r--r-- | lib/Connector/Sabre/RequestPlugin.php | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/lib/Connector/Sabre/RequestPlugin.php b/lib/Connector/Sabre/RequestPlugin.php index 4816ee5..0fbff41 100644 --- a/lib/Connector/Sabre/RequestPlugin.php +++ b/lib/Connector/Sabre/RequestPlugin.php @@ -108,20 +108,23 @@ class RequestPlugin extends ServerPlugin public function beforeHttpPropFind(RequestInterface $request, ResponseInterface $response) { - $propfindCount = $this->config->getUserValue($this->userSession->getUser()->getUID(), Application::APP_ID, 'propfind_count:'.$this->session->getId(), 0); - if ($propfindCount + 1 < self::PROPFIND_COUNT) { - // less than PROPFIND_COUNT + 1 PROPFIND requests - $this->config->setUserValue($this->userSession->getUser()->getUID(), Application::APP_ID, 'propfind_count:'.$this->session->getId(), $propfindCount + 1); - } else { - // more than PROPFIND_COUNT PROPFIND requests and no file is uploading - $sequenceId = $this->config->getUserValue($this->userSession->getUser()->getUID(), Application::APP_ID, 'sequence_id', 0); - $sequence = $this->service->findSequenceById([$sequenceId]); - if (sizeof($sequence) > 0) { - // get old sequence id - // start a new sequence by increasing the sequence id - $this->config->setUserValue($this->userSession->getUser()->getUID(), Application::APP_ID, 'sequence_id', $sequenceId + 1); - $this->config->setUserValue($this->userSession->getUser()->getUID(), Application::APP_ID, 'propfind_count:'.$this->session->getId(), 0); - $this->classifySequence($sequence); + if ($this->userSession !== null && $this->userSession->getUser() !== null) { + // only process the propfind request if there is a active user session + $propfindCount = $this->config->getUserValue($this->userSession->getUser()->getUID(), Application::APP_ID, 'propfind_count:'.$this->session->getId(), 0); + if ($propfindCount + 1 < self::PROPFIND_COUNT) { + // less than PROPFIND_COUNT + 1 PROPFIND requests + $this->config->setUserValue($this->userSession->getUser()->getUID(), Application::APP_ID, 'propfind_count:'.$this->session->getId(), $propfindCount + 1); + } else { + // more than PROPFIND_COUNT PROPFIND requests and no file is uploading + $sequenceId = $this->config->getUserValue($this->userSession->getUser()->getUID(), Application::APP_ID, 'sequence_id', 0); + $sequence = $this->service->findSequenceById([$sequenceId]); + if (sizeof($sequence) > 0) { + // get old sequence id + // start a new sequence by increasing the sequence id + $this->config->setUserValue($this->userSession->getUser()->getUID(), Application::APP_ID, 'sequence_id', $sequenceId + 1); + $this->config->setUserValue($this->userSession->getUser()->getUID(), Application::APP_ID, 'propfind_count:'.$this->session->getId(), 0); + $this->classifySequence($sequence); + } } } } |