@@ -37,55 +37,55 @@ |
||
37 | 37 | * @since 8.1.0 |
38 | 38 | */ |
39 | 39 | interface IMemcache extends ICache { |
40 | - /** |
|
41 | - * Set a value in the cache if it's not already stored |
|
42 | - * |
|
43 | - * @param string $key |
|
44 | - * @param mixed $value |
|
45 | - * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 |
|
46 | - * @return bool |
|
47 | - * @since 8.1.0 |
|
48 | - */ |
|
49 | - public function add($key, $value, $ttl = 0); |
|
40 | + /** |
|
41 | + * Set a value in the cache if it's not already stored |
|
42 | + * |
|
43 | + * @param string $key |
|
44 | + * @param mixed $value |
|
45 | + * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 |
|
46 | + * @return bool |
|
47 | + * @since 8.1.0 |
|
48 | + */ |
|
49 | + public function add($key, $value, $ttl = 0); |
|
50 | 50 | |
51 | - /** |
|
52 | - * Increase a stored number |
|
53 | - * |
|
54 | - * @param string $key |
|
55 | - * @param int $step |
|
56 | - * @return int | bool |
|
57 | - * @since 8.1.0 |
|
58 | - */ |
|
59 | - public function inc($key, $step = 1); |
|
51 | + /** |
|
52 | + * Increase a stored number |
|
53 | + * |
|
54 | + * @param string $key |
|
55 | + * @param int $step |
|
56 | + * @return int | bool |
|
57 | + * @since 8.1.0 |
|
58 | + */ |
|
59 | + public function inc($key, $step = 1); |
|
60 | 60 | |
61 | - /** |
|
62 | - * Decrease a stored number |
|
63 | - * |
|
64 | - * @param string $key |
|
65 | - * @param int $step |
|
66 | - * @return int | bool |
|
67 | - * @since 8.1.0 |
|
68 | - */ |
|
69 | - public function dec($key, $step = 1); |
|
61 | + /** |
|
62 | + * Decrease a stored number |
|
63 | + * |
|
64 | + * @param string $key |
|
65 | + * @param int $step |
|
66 | + * @return int | bool |
|
67 | + * @since 8.1.0 |
|
68 | + */ |
|
69 | + public function dec($key, $step = 1); |
|
70 | 70 | |
71 | - /** |
|
72 | - * Compare and set |
|
73 | - * |
|
74 | - * @param string $key |
|
75 | - * @param mixed $old |
|
76 | - * @param mixed $new |
|
77 | - * @return bool |
|
78 | - * @since 8.1.0 |
|
79 | - */ |
|
80 | - public function cas($key, $old, $new); |
|
71 | + /** |
|
72 | + * Compare and set |
|
73 | + * |
|
74 | + * @param string $key |
|
75 | + * @param mixed $old |
|
76 | + * @param mixed $new |
|
77 | + * @return bool |
|
78 | + * @since 8.1.0 |
|
79 | + */ |
|
80 | + public function cas($key, $old, $new); |
|
81 | 81 | |
82 | - /** |
|
83 | - * Compare and delete |
|
84 | - * |
|
85 | - * @param string $key |
|
86 | - * @param mixed $old |
|
87 | - * @return bool |
|
88 | - * @since 8.1.0 |
|
89 | - */ |
|
90 | - public function cad($key, $old); |
|
82 | + /** |
|
83 | + * Compare and delete |
|
84 | + * |
|
85 | + * @param string $key |
|
86 | + * @param mixed $old |
|
87 | + * @return bool |
|
88 | + * @since 8.1.0 |
|
89 | + */ |
|
90 | + public function cad($key, $old); |
|
91 | 91 | } |
@@ -25,14 +25,14 @@ |
||
25 | 25 | namespace OC; |
26 | 26 | |
27 | 27 | class NaturalSort_DefaultCollator { |
28 | - public function compare($a, $b) { |
|
29 | - $result = strcasecmp($a, $b); |
|
30 | - if ($result === 0) { |
|
31 | - if ($a === $b) { |
|
32 | - return 0; |
|
33 | - } |
|
34 | - return ($a > $b) ? -1 : 1; |
|
35 | - } |
|
36 | - return ($result < 0) ? -1 : 1; |
|
37 | - } |
|
28 | + public function compare($a, $b) { |
|
29 | + $result = strcasecmp($a, $b); |
|
30 | + if ($result === 0) { |
|
31 | + if ($a === $b) { |
|
32 | + return 0; |
|
33 | + } |
|
34 | + return ($a > $b) ? -1 : 1; |
|
35 | + } |
|
36 | + return ($result < 0) ? -1 : 1; |
|
37 | + } |
|
38 | 38 | } |
@@ -25,12 +25,12 @@ |
||
25 | 25 | use OC\BackgroundJob\QueuedJob; |
26 | 26 | |
27 | 27 | class CallableJob extends QueuedJob { |
28 | - protected function run($serializedCallable) { |
|
29 | - $callable = unserialize($serializedCallable); |
|
30 | - if (is_callable($callable)) { |
|
31 | - $callable(); |
|
32 | - } else { |
|
33 | - throw new \InvalidArgumentException('Invalid serialized callable'); |
|
34 | - } |
|
35 | - } |
|
28 | + protected function run($serializedCallable) { |
|
29 | + $callable = unserialize($serializedCallable); |
|
30 | + if (is_callable($callable)) { |
|
31 | + $callable(); |
|
32 | + } else { |
|
33 | + throw new \InvalidArgumentException('Invalid serialized callable'); |
|
34 | + } |
|
35 | + } |
|
36 | 36 | } |
@@ -29,12 +29,12 @@ |
||
29 | 29 | * Wrap a command in the background job interface |
30 | 30 | */ |
31 | 31 | class CommandJob extends QueuedJob { |
32 | - protected function run($serializedCommand) { |
|
33 | - $command = unserialize($serializedCommand); |
|
34 | - if ($command instanceof ICommand) { |
|
35 | - $command->handle(); |
|
36 | - } else { |
|
37 | - throw new \InvalidArgumentException('Invalid serialized command'); |
|
38 | - } |
|
39 | - } |
|
32 | + protected function run($serializedCommand) { |
|
33 | + $command = unserialize($serializedCommand); |
|
34 | + if ($command instanceof ICommand) { |
|
35 | + $command->handle(); |
|
36 | + } else { |
|
37 | + throw new \InvalidArgumentException('Invalid serialized command'); |
|
38 | + } |
|
39 | + } |
|
40 | 40 | } |
@@ -24,23 +24,23 @@ |
||
24 | 24 | namespace OC\Template; |
25 | 25 | |
26 | 26 | class ResourceNotFoundException extends \LogicException { |
27 | - protected $resource; |
|
28 | - protected $webPath; |
|
27 | + protected $resource; |
|
28 | + protected $webPath; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @param string $resource |
|
32 | - * @param string $webPath |
|
33 | - */ |
|
34 | - public function __construct($resource, $webPath) { |
|
35 | - parent::__construct('Resource not found'); |
|
36 | - $this->resource = $resource; |
|
37 | - $this->webPath = $webPath; |
|
38 | - } |
|
30 | + /** |
|
31 | + * @param string $resource |
|
32 | + * @param string $webPath |
|
33 | + */ |
|
34 | + public function __construct($resource, $webPath) { |
|
35 | + parent::__construct('Resource not found'); |
|
36 | + $this->resource = $resource; |
|
37 | + $this->webPath = $webPath; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function getResourcePath() { |
|
44 | - return $this->webPath . '/' . $this->resource; |
|
45 | - } |
|
40 | + /** |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function getResourcePath() { |
|
44 | + return $this->webPath . '/' . $this->resource; |
|
45 | + } |
|
46 | 46 | } |
@@ -23,35 +23,35 @@ |
||
23 | 23 | namespace OC\Memcache; |
24 | 24 | |
25 | 25 | trait CASTrait { |
26 | - abstract public function get($key); |
|
26 | + abstract public function get($key); |
|
27 | 27 | |
28 | - abstract public function set($key, $value, $ttl = 0); |
|
28 | + abstract public function set($key, $value, $ttl = 0); |
|
29 | 29 | |
30 | - abstract public function remove($key); |
|
30 | + abstract public function remove($key); |
|
31 | 31 | |
32 | - abstract public function add($key, $value, $ttl = 0); |
|
32 | + abstract public function add($key, $value, $ttl = 0); |
|
33 | 33 | |
34 | - /** |
|
35 | - * Compare and set |
|
36 | - * |
|
37 | - * @param string $key |
|
38 | - * @param mixed $old |
|
39 | - * @param mixed $new |
|
40 | - * @return bool |
|
41 | - */ |
|
42 | - public function cas($key, $old, $new) { |
|
43 | - //no native cas, emulate with locking |
|
44 | - if ($this->add($key . '_lock', true)) { |
|
45 | - if ($this->get($key) === $old) { |
|
46 | - $this->set($key, $new); |
|
47 | - $this->remove($key . '_lock'); |
|
48 | - return true; |
|
49 | - } else { |
|
50 | - $this->remove($key . '_lock'); |
|
51 | - return false; |
|
52 | - } |
|
53 | - } else { |
|
54 | - return false; |
|
55 | - } |
|
56 | - } |
|
34 | + /** |
|
35 | + * Compare and set |
|
36 | + * |
|
37 | + * @param string $key |
|
38 | + * @param mixed $old |
|
39 | + * @param mixed $new |
|
40 | + * @return bool |
|
41 | + */ |
|
42 | + public function cas($key, $old, $new) { |
|
43 | + //no native cas, emulate with locking |
|
44 | + if ($this->add($key . '_lock', true)) { |
|
45 | + if ($this->get($key) === $old) { |
|
46 | + $this->set($key, $new); |
|
47 | + $this->remove($key . '_lock'); |
|
48 | + return true; |
|
49 | + } else { |
|
50 | + $this->remove($key . '_lock'); |
|
51 | + return false; |
|
52 | + } |
|
53 | + } else { |
|
54 | + return false; |
|
55 | + } |
|
56 | + } |
|
57 | 57 | } |
@@ -23,32 +23,32 @@ |
||
23 | 23 | namespace OC\Memcache; |
24 | 24 | |
25 | 25 | trait CADTrait { |
26 | - abstract public function get($key); |
|
26 | + abstract public function get($key); |
|
27 | 27 | |
28 | - abstract public function remove($key); |
|
28 | + abstract public function remove($key); |
|
29 | 29 | |
30 | - abstract public function add($key, $value, $ttl = 0); |
|
30 | + abstract public function add($key, $value, $ttl = 0); |
|
31 | 31 | |
32 | - /** |
|
33 | - * Compare and delete |
|
34 | - * |
|
35 | - * @param string $key |
|
36 | - * @param mixed $old |
|
37 | - * @return bool |
|
38 | - */ |
|
39 | - public function cad($key, $old) { |
|
40 | - //no native cas, emulate with locking |
|
41 | - if ($this->add($key . '_lock', true)) { |
|
42 | - if ($this->get($key) === $old) { |
|
43 | - $this->remove($key); |
|
44 | - $this->remove($key . '_lock'); |
|
45 | - return true; |
|
46 | - } else { |
|
47 | - $this->remove($key . '_lock'); |
|
48 | - return false; |
|
49 | - } |
|
50 | - } else { |
|
51 | - return false; |
|
52 | - } |
|
53 | - } |
|
32 | + /** |
|
33 | + * Compare and delete |
|
34 | + * |
|
35 | + * @param string $key |
|
36 | + * @param mixed $old |
|
37 | + * @return bool |
|
38 | + */ |
|
39 | + public function cad($key, $old) { |
|
40 | + //no native cas, emulate with locking |
|
41 | + if ($this->add($key . '_lock', true)) { |
|
42 | + if ($this->get($key) === $old) { |
|
43 | + $this->remove($key); |
|
44 | + $this->remove($key . '_lock'); |
|
45 | + return true; |
|
46 | + } else { |
|
47 | + $this->remove($key . '_lock'); |
|
48 | + return false; |
|
49 | + } |
|
50 | + } else { |
|
51 | + return false; |
|
52 | + } |
|
53 | + } |
|
54 | 54 | } |
@@ -29,21 +29,21 @@ |
||
29 | 29 | * Listen to hooks and update the mount cache as needed |
30 | 30 | */ |
31 | 31 | class UserMountCacheListener { |
32 | - /** |
|
33 | - * @var IUserMountCache |
|
34 | - */ |
|
35 | - private $userMountCache; |
|
32 | + /** |
|
33 | + * @var IUserMountCache |
|
34 | + */ |
|
35 | + private $userMountCache; |
|
36 | 36 | |
37 | - /** |
|
38 | - * UserMountCacheListener constructor. |
|
39 | - * |
|
40 | - * @param IUserMountCache $userMountCache |
|
41 | - */ |
|
42 | - public function __construct(IUserMountCache $userMountCache) { |
|
43 | - $this->userMountCache = $userMountCache; |
|
44 | - } |
|
37 | + /** |
|
38 | + * UserMountCacheListener constructor. |
|
39 | + * |
|
40 | + * @param IUserMountCache $userMountCache |
|
41 | + */ |
|
42 | + public function __construct(IUserMountCache $userMountCache) { |
|
43 | + $this->userMountCache = $userMountCache; |
|
44 | + } |
|
45 | 45 | |
46 | - public function listen(Manager $manager) { |
|
47 | - $manager->listen('\OC\User', 'postDelete', [$this->userMountCache, 'removeUserMounts']); |
|
48 | - } |
|
46 | + public function listen(Manager $manager) { |
|
47 | + $manager->listen('\OC\User', 'postDelete', [$this->userMountCache, 'removeUserMounts']); |
|
48 | + } |
|
49 | 49 | } |
@@ -29,80 +29,80 @@ |
||
29 | 29 | use OCP\Files\Storage\IStorageFactory; |
30 | 30 | |
31 | 31 | class StorageFactory implements IStorageFactory { |
32 | - /** |
|
33 | - * @var array[] [$name=>['priority'=>$priority, 'wrapper'=>$callable] $storageWrappers |
|
34 | - */ |
|
35 | - private $storageWrappers = []; |
|
32 | + /** |
|
33 | + * @var array[] [$name=>['priority'=>$priority, 'wrapper'=>$callable] $storageWrappers |
|
34 | + */ |
|
35 | + private $storageWrappers = []; |
|
36 | 36 | |
37 | - /** |
|
38 | - * allow modifier storage behaviour by adding wrappers around storages |
|
39 | - * |
|
40 | - * $callback should be a function of type (string $mountPoint, Storage $storage) => Storage |
|
41 | - * |
|
42 | - * @param string $wrapperName name of the wrapper |
|
43 | - * @param callable $callback callback |
|
44 | - * @param int $priority wrappers with the lower priority are applied last (meaning they get called first) |
|
45 | - * @param \OCP\Files\Mount\IMountPoint[] $existingMounts existing mount points to apply the wrapper to |
|
46 | - * @return bool true if the wrapper was added, false if there was already a wrapper with this |
|
47 | - * name registered |
|
48 | - */ |
|
49 | - public function addStorageWrapper($wrapperName, $callback, $priority = 50, $existingMounts = []) { |
|
50 | - if (isset($this->storageWrappers[$wrapperName])) { |
|
51 | - return false; |
|
52 | - } |
|
37 | + /** |
|
38 | + * allow modifier storage behaviour by adding wrappers around storages |
|
39 | + * |
|
40 | + * $callback should be a function of type (string $mountPoint, Storage $storage) => Storage |
|
41 | + * |
|
42 | + * @param string $wrapperName name of the wrapper |
|
43 | + * @param callable $callback callback |
|
44 | + * @param int $priority wrappers with the lower priority are applied last (meaning they get called first) |
|
45 | + * @param \OCP\Files\Mount\IMountPoint[] $existingMounts existing mount points to apply the wrapper to |
|
46 | + * @return bool true if the wrapper was added, false if there was already a wrapper with this |
|
47 | + * name registered |
|
48 | + */ |
|
49 | + public function addStorageWrapper($wrapperName, $callback, $priority = 50, $existingMounts = []) { |
|
50 | + if (isset($this->storageWrappers[$wrapperName])) { |
|
51 | + return false; |
|
52 | + } |
|
53 | 53 | |
54 | - // apply to existing mounts before registering it to prevent applying it double in MountPoint::createStorage |
|
55 | - foreach ($existingMounts as $mount) { |
|
56 | - $mount->wrapStorage($callback); |
|
57 | - } |
|
54 | + // apply to existing mounts before registering it to prevent applying it double in MountPoint::createStorage |
|
55 | + foreach ($existingMounts as $mount) { |
|
56 | + $mount->wrapStorage($callback); |
|
57 | + } |
|
58 | 58 | |
59 | - $this->storageWrappers[$wrapperName] = ['wrapper' => $callback, 'priority' => $priority]; |
|
60 | - return true; |
|
61 | - } |
|
59 | + $this->storageWrappers[$wrapperName] = ['wrapper' => $callback, 'priority' => $priority]; |
|
60 | + return true; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Remove a storage wrapper by name. |
|
65 | - * Note: internal method only to be used for cleanup |
|
66 | - * |
|
67 | - * @param string $wrapperName name of the wrapper |
|
68 | - * @internal |
|
69 | - */ |
|
70 | - public function removeStorageWrapper($wrapperName) { |
|
71 | - unset($this->storageWrappers[$wrapperName]); |
|
72 | - } |
|
63 | + /** |
|
64 | + * Remove a storage wrapper by name. |
|
65 | + * Note: internal method only to be used for cleanup |
|
66 | + * |
|
67 | + * @param string $wrapperName name of the wrapper |
|
68 | + * @internal |
|
69 | + */ |
|
70 | + public function removeStorageWrapper($wrapperName) { |
|
71 | + unset($this->storageWrappers[$wrapperName]); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Create an instance of a storage and apply the registered storage wrappers |
|
76 | - * |
|
77 | - * @param \OCP\Files\Mount\IMountPoint $mountPoint |
|
78 | - * @param string $class |
|
79 | - * @param array $arguments |
|
80 | - * @return \OCP\Files\Storage |
|
81 | - */ |
|
82 | - public function getInstance(IMountPoint $mountPoint, $class, $arguments) { |
|
83 | - return $this->wrap($mountPoint, new $class($arguments)); |
|
84 | - } |
|
74 | + /** |
|
75 | + * Create an instance of a storage and apply the registered storage wrappers |
|
76 | + * |
|
77 | + * @param \OCP\Files\Mount\IMountPoint $mountPoint |
|
78 | + * @param string $class |
|
79 | + * @param array $arguments |
|
80 | + * @return \OCP\Files\Storage |
|
81 | + */ |
|
82 | + public function getInstance(IMountPoint $mountPoint, $class, $arguments) { |
|
83 | + return $this->wrap($mountPoint, new $class($arguments)); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * @param \OCP\Files\Mount\IMountPoint $mountPoint |
|
88 | - * @param \OCP\Files\Storage $storage |
|
89 | - * @return \OCP\Files\Storage |
|
90 | - */ |
|
91 | - public function wrap(IMountPoint $mountPoint, $storage) { |
|
92 | - $wrappers = array_values($this->storageWrappers); |
|
93 | - usort($wrappers, function ($a, $b) { |
|
94 | - return $b['priority'] - $a['priority']; |
|
95 | - }); |
|
96 | - /** @var callable[] $wrappers */ |
|
97 | - $wrappers = array_map(function ($wrapper) { |
|
98 | - return $wrapper['wrapper']; |
|
99 | - }, $wrappers); |
|
100 | - foreach ($wrappers as $wrapper) { |
|
101 | - $storage = $wrapper($mountPoint->getMountPoint(), $storage, $mountPoint); |
|
102 | - if (!($storage instanceof \OCP\Files\Storage)) { |
|
103 | - throw new \Exception('Invalid result from storage wrapper'); |
|
104 | - } |
|
105 | - } |
|
106 | - return $storage; |
|
107 | - } |
|
86 | + /** |
|
87 | + * @param \OCP\Files\Mount\IMountPoint $mountPoint |
|
88 | + * @param \OCP\Files\Storage $storage |
|
89 | + * @return \OCP\Files\Storage |
|
90 | + */ |
|
91 | + public function wrap(IMountPoint $mountPoint, $storage) { |
|
92 | + $wrappers = array_values($this->storageWrappers); |
|
93 | + usort($wrappers, function ($a, $b) { |
|
94 | + return $b['priority'] - $a['priority']; |
|
95 | + }); |
|
96 | + /** @var callable[] $wrappers */ |
|
97 | + $wrappers = array_map(function ($wrapper) { |
|
98 | + return $wrapper['wrapper']; |
|
99 | + }, $wrappers); |
|
100 | + foreach ($wrappers as $wrapper) { |
|
101 | + $storage = $wrapper($mountPoint->getMountPoint(), $storage, $mountPoint); |
|
102 | + if (!($storage instanceof \OCP\Files\Storage)) { |
|
103 | + throw new \Exception('Invalid result from storage wrapper'); |
|
104 | + } |
|
105 | + } |
|
106 | + return $storage; |
|
107 | + } |
|
108 | 108 | } |