@@ -90,6 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * Build a single dimension array with all nodes. |
| 93 | + * @param integer[] $cursor |
|
| 93 | 94 | */ |
| 94 | 95 | public function buildFeedFromCurrentState(?array $cursor = null, int $limit = 100, ?NodeInterface $node = null): array |
| 95 | 96 | { |
@@ -212,6 +213,8 @@ discard block |
||
| 212 | 213 | |
| 213 | 214 | /** |
| 214 | 215 | * Get delta feed with changes and cursor. |
| 216 | + * @param string $cursor |
|
| 217 | + * @param NodeInterface $node |
|
| 215 | 218 | */ |
| 216 | 219 | public function getDeltaFeed(?string $cursor = null, int $limit = 250, ?NodeInterface $node = null): array |
| 217 | 220 | { |
@@ -305,6 +308,7 @@ discard block |
||
| 305 | 308 | |
| 306 | 309 | /** |
| 307 | 310 | * Get event log. |
| 311 | + * @param NodeInterface $node |
|
| 308 | 312 | */ |
| 309 | 313 | public function getEventLog(int $limit = 100, int $skip = 0, ?NodeInterface $node = null, ?int &$total = null): Iterable |
| 310 | 314 | { |
@@ -523,6 +527,7 @@ discard block |
||
| 523 | 527 | |
| 524 | 528 | /** |
| 525 | 529 | * Get children with custom filter. |
| 530 | + * @param integer $limit |
|
| 526 | 531 | */ |
| 527 | 532 | protected function findNodeAttributesWithCustomFilter( |
| 528 | 533 | ?array $filter = null, |
@@ -246,7 +246,7 @@ |
||
| 246 | 246 | $delta[$share_member->getPath()] = $share_member; |
| 247 | 247 | } |
| 248 | 248 | } elseif ('undeleteCollection' === $log['operation'] || 'undeleteCollectionShare' === $log['operation']) { |
| 249 | - $log_node->doRecursiveAction(function ($sub_node) use (&$delta) { |
|
| 249 | + $log_node->doRecursiveAction(function($sub_node) use (&$delta) { |
|
| 250 | 250 | $delta[$sub_node->getPath()] = $sub_node; |
| 251 | 251 | }); |
| 252 | 252 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | 'message' => (string) $message['body'], |
| 99 | 99 | 'subject' => (string) $message['subject'], |
| 100 | 100 | 'locale' => (string) $message['locale'], |
| 101 | - 'sender' => function ($message) use ($server, $role_decorator) { |
|
| 101 | + 'sender' => function($message) use ($server, $role_decorator) { |
|
| 102 | 102 | if (!isset($message['sender'])) { |
| 103 | 103 | return null; |
| 104 | 104 | } |
@@ -109,10 +109,10 @@ discard block |
||
| 109 | 109 | return null; |
| 110 | 110 | } |
| 111 | 111 | }, |
| 112 | - 'created' => function ($message) { |
|
| 112 | + 'created' => function($message) { |
|
| 113 | 113 | return (new DateTime())->setTimestamp($message['_id']->getTimestamp())->format('c'); |
| 114 | 114 | }, |
| 115 | - 'node' => function ($message) use ($node_decorator, $fs) { |
|
| 115 | + 'node' => function($message) use ($node_decorator, $fs) { |
|
| 116 | 116 | if (isset($message['node'])) { |
| 117 | 117 | try { |
| 118 | 118 | return $node_decorator->decorate($fs->findNodeById($message['node']), ['id', 'name', '_links']); |
@@ -161,7 +161,7 @@ |
||
| 161 | 161 | $tpl = new Template($type); |
| 162 | 162 | |
| 163 | 163 | $attributes = compact('readonly', 'meta'); |
| 164 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
| 164 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
| 165 | 165 | |
| 166 | 166 | $stream = $tpl->get(); |
| 167 | 167 | $storage = $parent->getStorage(); |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | if ($index === $chunks) { |
| 286 | 286 | $attributes = compact('changed', 'created', 'readonly', 'meta', 'acl'); |
| 287 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
| 287 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
| 288 | 288 | $attributes = $this->_verifyAttributes($attributes); |
| 289 | 289 | |
| 290 | 290 | return $this->_put($session, $id, $p, $collection, $name, $attributes, $conflict); |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | $storage = $this->getStorage($id, $p, $collection); |
| 400 | 400 | $session = $storage->storeTemporaryFile($input, $this->server->getIdentity()); |
| 401 | 401 | $attributes = compact('changed', 'created', 'readonly', 'meta', 'acl'); |
| 402 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
| 402 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
| 403 | 403 | $attributes = $this->_verifyAttributes($attributes); |
| 404 | 404 | |
| 405 | 405 | return $this->_put($session, $id, $p, $collection, $name, $attributes, $conflict); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * |
| 118 | 118 | * @param string $id |
| 119 | 119 | * @param string $p |
| 120 | - * @param string $version |
|
| 120 | + * @param integer $version |
|
| 121 | 121 | */ |
| 122 | 122 | public function postRestore(int $version, ?string $id = null, ?string $p = null): Response |
| 123 | 123 | { |
@@ -406,6 +406,9 @@ discard block |
||
| 406 | 406 | |
| 407 | 407 | /** |
| 408 | 408 | * Get storage. |
| 409 | + * @param string|null $id |
|
| 410 | + * @param string|null $p |
|
| 411 | + * @param string|null $collection |
|
| 409 | 412 | */ |
| 410 | 413 | protected function getStorage($id, $p, $collection): StorageAdapterInterface |
| 411 | 414 | { |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | */ |
| 55 | 55 | protected function setErrorHandler(LoggerInterface $logger): self |
| 56 | 56 | { |
| 57 | - set_error_handler(function ($severity, $message, $file, $line) use ($logger) { |
|
| 57 | + set_error_handler(function($severity, $message, $file, $line) use ($logger) { |
|
| 58 | 58 | $log = $message.' in '.$file.':'.$line; |
| 59 | 59 | |
| 60 | 60 | switch ($severity) { |
@@ -144,7 +144,7 @@ |
||
| 144 | 144 | protected function deleteNode(NodeInterface $node, Blackhole $dummy): bool |
| 145 | 145 | { |
| 146 | 146 | if ($node instanceof Collection) { |
| 147 | - $node->doRecursiveAction(function (NodeInterface $node) use ($dummy) { |
|
| 147 | + $node->doRecursiveAction(function(NodeInterface $node) use ($dummy) { |
|
| 148 | 148 | if ($node instanceof Collection) { |
| 149 | 149 | $node->setStorage($dummy); |
| 150 | 150 | } |
@@ -113,20 +113,20 @@ discard block |
||
| 113 | 113 | 'mime' => (string) $attributes['mime'], |
| 114 | 114 | 'readonly' => (bool) $attributes['readonly'], |
| 115 | 115 | 'directory' => $node instanceof Collection, |
| 116 | - 'meta' => function ($node) { |
|
| 116 | + 'meta' => function($node) { |
|
| 117 | 117 | return (object) $node->getMetaAttributes(); |
| 118 | 118 | }, |
| 119 | - 'size' => function ($node) { |
|
| 119 | + 'size' => function($node) { |
|
| 120 | 120 | return $node->getSize(); |
| 121 | 121 | }, |
| 122 | - 'path' => function ($node) { |
|
| 122 | + 'path' => function($node) { |
|
| 123 | 123 | try { |
| 124 | 124 | return $node->getPath(); |
| 125 | 125 | } catch (\Exception $e) { |
| 126 | 126 | return null; |
| 127 | 127 | } |
| 128 | 128 | }, |
| 129 | - 'parent' => function ($node) { |
|
| 129 | + 'parent' => function($node) { |
|
| 130 | 130 | $parent = $node->getParent(); |
| 131 | 131 | |
| 132 | 132 | if (null === $parent || $parent->isRoot()) { |
@@ -135,17 +135,17 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | return $this->decorate($node->getParent(), ['id', 'name', '_links']); |
| 137 | 137 | }, |
| 138 | - 'access' => function ($node) use ($acl) { |
|
| 138 | + 'access' => function($node) use ($acl) { |
|
| 139 | 139 | return $acl->getAclPrivilege($node); |
| 140 | 140 | }, |
| 141 | - 'acl' => function ($node) use ($attributes) { |
|
| 141 | + 'acl' => function($node) use ($attributes) { |
|
| 142 | 142 | if ($node->isShareMember() && count($attributes['acl']) > 0) { |
| 143 | 143 | return $node->getAcl(); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | return null; |
| 147 | 147 | }, |
| 148 | - 'share' => function ($node) use ($fs) { |
|
| 148 | + 'share' => function($node) use ($fs) { |
|
| 149 | 149 | if ($node->isShared() || !$node->isSpecial()) { |
| 150 | 150 | return null; |
| 151 | 151 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | return null; |
| 157 | 157 | } |
| 158 | 158 | }, |
| 159 | - 'sharename' => function ($node) { |
|
| 159 | + 'sharename' => function($node) { |
|
| 160 | 160 | if (!$node->isShared()) { |
| 161 | 161 | return null; |
| 162 | 162 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | return null; |
| 168 | 168 | } |
| 169 | 169 | }, |
| 170 | - 'shareowner' => function ($node) use ($server, $fs, $decorator) { |
|
| 170 | + 'shareowner' => function($node) use ($server, $fs, $decorator) { |
|
| 171 | 171 | if (!$node->isSpecial()) { |
| 172 | 172 | return null; |
| 173 | 173 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | return null; |
| 182 | 182 | } |
| 183 | 183 | }, |
| 184 | - 'owner' => function ($node) use ($server, $decorator) { |
|
| 184 | + 'owner' => function($node) use ($server, $decorator) { |
|
| 185 | 185 | try { |
| 186 | 186 | return $decorator->decorate( |
| 187 | 187 | $server->getUserById($node->getOwner()), |
@@ -202,20 +202,20 @@ discard block |
||
| 202 | 202 | protected function getTimeAttributes(NodeInterface $node, array $attributes): array |
| 203 | 203 | { |
| 204 | 204 | return [ |
| 205 | - 'created' => function ($node) use ($attributes) { |
|
| 205 | + 'created' => function($node) use ($attributes) { |
|
| 206 | 206 | return $attributes['created']->toDateTime()->format('c'); |
| 207 | 207 | }, |
| 208 | - 'changed' => function ($node) use ($attributes) { |
|
| 208 | + 'changed' => function($node) use ($attributes) { |
|
| 209 | 209 | return $attributes['changed']->toDateTime()->format('c'); |
| 210 | 210 | }, |
| 211 | - 'deleted' => function ($node) use ($attributes) { |
|
| 211 | + 'deleted' => function($node) use ($attributes) { |
|
| 212 | 212 | if (false === $attributes['deleted']) { |
| 213 | 213 | return null; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | return $attributes['deleted']->toDateTime()->format('c'); |
| 217 | 217 | }, |
| 218 | - 'destroy' => function ($node) use ($attributes) { |
|
| 218 | + 'destroy' => function($node) use ($attributes) { |
|
| 219 | 219 | if (null === $attributes['destroy']) { |
| 220 | 220 | return null; |
| 221 | 221 | } |
@@ -243,14 +243,14 @@ discard block |
||
| 243 | 243 | return [ |
| 244 | 244 | 'shared' => $node->isShared(), |
| 245 | 245 | 'reference' => $node->isReference(), |
| 246 | - 'filter' => function ($node) use ($attributes) { |
|
| 246 | + 'filter' => function($node) use ($attributes) { |
|
| 247 | 247 | if (null === $attributes['filter']) { |
| 248 | 248 | return null; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | return json_decode($attributes['filter'], true); |
| 252 | 252 | }, |
| 253 | - 'mount' => function ($node) use ($fs, $attributes) { |
|
| 253 | + 'mount' => function($node) use ($fs, $attributes) { |
|
| 254 | 254 | $mount = $node->getAttributes()['mount']; |
| 255 | 255 | |
| 256 | 256 | if (!$node->isMounted() && !$node->isReference()) { |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict, $move) { |
|
| 182 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict, $move) { |
|
| 183 | 183 | if (true === $move) { |
| 184 | 184 | $node = $node->setParent($parent, $conflict); |
| 185 | 185 | } |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | return (new Response())->setCode(200)->setBody($result); |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - return $this->bulk($id, $p, function ($node) use ($attributes) { |
|
| 349 | + return $this->bulk($id, $p, function($node) use ($attributes) { |
|
| 350 | 350 | return [ |
| 351 | 351 | 'code' => 200, |
| 352 | 352 | 'data' => $this->node_decorator->decorate($node, $attributes), |
@@ -454,9 +454,9 @@ discard block |
||
| 454 | 454 | public function patch(?string $name = null, ?array $meta = null, ?bool $readonly = null, ?array $filter = null, ?array $acl = null, ?string $id = null, ?string $p = null): Response |
| 455 | 455 | { |
| 456 | 456 | $attributes = compact('name', 'meta', 'readonly', 'filter', 'acl'); |
| 457 | - $attributes = array_filter($attributes, function ($attribute) {return !is_null($attribute); }); |
|
| 457 | + $attributes = array_filter($attributes, function($attribute) {return !is_null($attribute); }); |
|
| 458 | 458 | |
| 459 | - return $this->bulk($id, $p, function ($node) use ($attributes) { |
|
| 459 | + return $this->bulk($id, $p, function($node) use ($attributes) { |
|
| 460 | 460 | foreach ($attributes as $attribute => $value) { |
| 461 | 461 | switch ($attribute) { |
| 462 | 462 | case 'name': |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | ); |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict) { |
|
| 542 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict) { |
|
| 543 | 543 | $result = $node->copyTo($parent, $conflict); |
| 544 | 544 | |
| 545 | 545 | return [ |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | ); |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | - return $this->bulk($id, $p, function ($node) use ($parent, $conflict) { |
|
| 603 | + return $this->bulk($id, $p, function($node) use ($parent, $conflict) { |
|
| 604 | 604 | $result = $node->setParent($parent, $conflict); |
| 605 | 605 | |
| 606 | 606 | return [ |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | $at = $this->_verifyAttributes(['destroy' => $at])['destroy']; |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - return $this->bulk($id, $p, function ($node) use ($force, $ignore_flag, $at) { |
|
| 653 | + return $this->bulk($id, $p, function($node) use ($force, $ignore_flag, $at) { |
|
| 654 | 654 | if (null === $at) { |
| 655 | 655 | $node->delete($force && $node->isDeleted() || $force && $ignore_flag); |
| 656 | 656 | } else { |
@@ -970,9 +970,9 @@ |
||
| 970 | 970 | //json_decode($stored, true), |
| 971 | 971 | } catch (\Exception $e) { |
| 972 | 972 | $this->logger->debug('failed zip node in multi node request ['.$node->getId().']', [ |
| 973 | - 'category' => get_class($this), |
|
| 974 | - 'exception' => $e, |
|
| 975 | - ]); |
|
| 973 | + 'category' => get_class($this), |
|
| 974 | + 'exception' => $e, |
|
| 975 | + ]); |
|
| 976 | 976 | } |
| 977 | 977 | } |
| 978 | 978 | |
@@ -34,68 +34,68 @@ |
||
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | return $response |
| 37 | - ->setOutputFormat(null) |
|
| 38 | - ->setBody(function () use ($file) { |
|
| 39 | - $stream = $file->get(); |
|
| 40 | - $name = $file->getName(); |
|
| 41 | - |
|
| 42 | - if (null === $stream) { |
|
| 43 | - return; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - $size = $file->getSize(); |
|
| 47 | - $length = $size; |
|
| 48 | - $start = 0; |
|
| 49 | - $end = $size - 1; |
|
| 50 | - |
|
| 51 | - if (isset($_SERVER['HTTP_RANGE'])) { |
|
| 52 | - header('Accept-Ranges: bytes'); |
|
| 53 | - $c_start = $start; |
|
| 54 | - $c_end = $end; |
|
| 55 | - list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2); |
|
| 56 | - |
|
| 57 | - if (strpos($range, ',') !== false) { |
|
| 58 | - header("Content-Range: bytes $start-$end/$size"); |
|
| 59 | - |
|
| 60 | - throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - if ($range == '-') { |
|
| 64 | - $c_start = $size - substr($range, 1); |
|
| 65 | - } else { |
|
| 66 | - $range = explode('-', $range); |
|
| 67 | - $c_start = $range[0]; |
|
| 68 | - $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - $c_end = ($c_end > $end) ? $end : $c_end; |
|
| 72 | - if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) { |
|
| 73 | - header("Content-Range: bytes $start-$end/$size"); |
|
| 74 | - |
|
| 75 | - throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - $start = (int) $c_start; |
|
| 79 | - $end = (int) $c_end; |
|
| 80 | - $length = (int) $end - $start + 1; |
|
| 81 | - fseek($stream, $start); |
|
| 82 | - header('HTTP/1.1 206 Partial Content'); |
|
| 83 | - header("Content-Range: bytes $start-$end/$size"); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - header('Content-Length: '.$length); |
|
| 87 | - $buffer = 1024 * 8; |
|
| 88 | - |
|
| 89 | - while (!feof($stream) && ($p = ftell($stream)) <= $end) { |
|
| 90 | - if ($p + $buffer > $end) { |
|
| 91 | - $buffer = $end - $p + 1; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - echo fread($stream, $buffer); |
|
| 95 | - flush(); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - fclose($stream); |
|
| 99 | - }); |
|
| 37 | + ->setOutputFormat(null) |
|
| 38 | + ->setBody(function () use ($file) { |
|
| 39 | + $stream = $file->get(); |
|
| 40 | + $name = $file->getName(); |
|
| 41 | + |
|
| 42 | + if (null === $stream) { |
|
| 43 | + return; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + $size = $file->getSize(); |
|
| 47 | + $length = $size; |
|
| 48 | + $start = 0; |
|
| 49 | + $end = $size - 1; |
|
| 50 | + |
|
| 51 | + if (isset($_SERVER['HTTP_RANGE'])) { |
|
| 52 | + header('Accept-Ranges: bytes'); |
|
| 53 | + $c_start = $start; |
|
| 54 | + $c_end = $end; |
|
| 55 | + list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2); |
|
| 56 | + |
|
| 57 | + if (strpos($range, ',') !== false) { |
|
| 58 | + header("Content-Range: bytes $start-$end/$size"); |
|
| 59 | + |
|
| 60 | + throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + if ($range == '-') { |
|
| 64 | + $c_start = $size - substr($range, 1); |
|
| 65 | + } else { |
|
| 66 | + $range = explode('-', $range); |
|
| 67 | + $c_start = $range[0]; |
|
| 68 | + $c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + $c_end = ($c_end > $end) ? $end : $c_end; |
|
| 72 | + if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) { |
|
| 73 | + header("Content-Range: bytes $start-$end/$size"); |
|
| 74 | + |
|
| 75 | + throw new Exception\InvalidRange('invalid offset/limit requested'); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + $start = (int) $c_start; |
|
| 79 | + $end = (int) $c_end; |
|
| 80 | + $length = (int) $end - $start + 1; |
|
| 81 | + fseek($stream, $start); |
|
| 82 | + header('HTTP/1.1 206 Partial Content'); |
|
| 83 | + header("Content-Range: bytes $start-$end/$size"); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + header('Content-Length: '.$length); |
|
| 87 | + $buffer = 1024 * 8; |
|
| 88 | + |
|
| 89 | + while (!feof($stream) && ($p = ftell($stream)) <= $end) { |
|
| 90 | + if ($p + $buffer > $end) { |
|
| 91 | + $buffer = $end - $p + 1; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + echo fread($stream, $buffer); |
|
| 95 | + flush(); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + fclose($stream); |
|
| 99 | + }); |
|
| 100 | 100 | } |
| 101 | 101 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | |
| 36 | 36 | return $response |
| 37 | 37 | ->setOutputFormat(null) |
| 38 | - ->setBody(function () use ($file) { |
|
| 38 | + ->setBody(function() use ($file) { |
|
| 39 | 39 | $stream = $file->get(); |
| 40 | 40 | $name = $file->getName(); |
| 41 | 41 | |