@@ -29,20 +29,20 @@ |
||
29 | 29 | * @since 25.0.0 |
30 | 30 | */ |
31 | 31 | class TrustedServerRemovedEvent extends Event { |
32 | - private string $urlHash; |
|
32 | + private string $urlHash; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @since 25.0.0 |
|
36 | - */ |
|
37 | - public function __construct(string $urlHash) { |
|
38 | - parent::__construct(); |
|
39 | - $this->urlHash = $urlHash; |
|
40 | - } |
|
34 | + /** |
|
35 | + * @since 25.0.0 |
|
36 | + */ |
|
37 | + public function __construct(string $urlHash) { |
|
38 | + parent::__construct(); |
|
39 | + $this->urlHash = $urlHash; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @since 25.0.0 |
|
44 | - */ |
|
45 | - public function getUrlHash(): string { |
|
46 | - return $this->urlHash; |
|
47 | - } |
|
42 | + /** |
|
43 | + * @since 25.0.0 |
|
44 | + */ |
|
45 | + public function getUrlHash(): string { |
|
46 | + return $this->urlHash; |
|
47 | + } |
|
48 | 48 | } |
@@ -33,30 +33,30 @@ |
||
33 | 33 | * @template-implements IEventListener<UserChangedEvent> |
34 | 34 | */ |
35 | 35 | class UserChangedListener implements IEventListener { |
36 | - private IAvatarManager $avatarManager; |
|
36 | + private IAvatarManager $avatarManager; |
|
37 | 37 | |
38 | - public function __construct(IAvatarManager $avatarManager) { |
|
39 | - $this->avatarManager = $avatarManager; |
|
40 | - } |
|
38 | + public function __construct(IAvatarManager $avatarManager) { |
|
39 | + $this->avatarManager = $avatarManager; |
|
40 | + } |
|
41 | 41 | |
42 | - public function handle(Event $event): void { |
|
43 | - if (!($event instanceof UserChangedEvent)) { |
|
44 | - return; |
|
45 | - } |
|
42 | + public function handle(Event $event): void { |
|
43 | + if (!($event instanceof UserChangedEvent)) { |
|
44 | + return; |
|
45 | + } |
|
46 | 46 | |
47 | - $user = $event->getUser(); |
|
48 | - $feature = $event->getFeature(); |
|
49 | - $oldValue = $event->getOldValue(); |
|
50 | - $value = $event->getValue(); |
|
47 | + $user = $event->getUser(); |
|
48 | + $feature = $event->getFeature(); |
|
49 | + $oldValue = $event->getOldValue(); |
|
50 | + $value = $event->getValue(); |
|
51 | 51 | |
52 | - // We only change the avatar on display name changes |
|
53 | - if ($feature === 'displayName') { |
|
54 | - try { |
|
55 | - $avatar = $this->avatarManager->getAvatar($user->getUID()); |
|
56 | - $avatar->userChanged($feature, $oldValue, $value); |
|
57 | - } catch (NotFoundException $e) { |
|
58 | - // no avatar to remove |
|
59 | - } |
|
60 | - } |
|
61 | - } |
|
52 | + // We only change the avatar on display name changes |
|
53 | + if ($feature === 'displayName') { |
|
54 | + try { |
|
55 | + $avatar = $this->avatarManager->getAvatar($user->getUID()); |
|
56 | + $avatar->userChanged($feature, $oldValue, $value); |
|
57 | + } catch (NotFoundException $e) { |
|
58 | + // no avatar to remove |
|
59 | + } |
|
60 | + } |
|
61 | + } |
|
62 | 62 | } |
@@ -29,69 +29,69 @@ |
||
29 | 29 | use function explode; |
30 | 30 | |
31 | 31 | class CompareVersion { |
32 | - private const REGEX_MAJOR = '/^\d+$/'; |
|
33 | - private const REGEX_MAJOR_MINOR = '/^\d+\.\d+$/'; |
|
34 | - private const REGEX_MAJOR_MINOR_PATCH = '/^\d+\.\d+\.\d+(?!\.\d+)/'; |
|
35 | - private const REGEX_ACTUAL = '/^\d+(\.\d+){1,2}/'; |
|
32 | + private const REGEX_MAJOR = '/^\d+$/'; |
|
33 | + private const REGEX_MAJOR_MINOR = '/^\d+\.\d+$/'; |
|
34 | + private const REGEX_MAJOR_MINOR_PATCH = '/^\d+\.\d+\.\d+(?!\.\d+)/'; |
|
35 | + private const REGEX_ACTUAL = '/^\d+(\.\d+){1,2}/'; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Checks if the given server version fulfills the given (app) version requirements. |
|
39 | - * |
|
40 | - * Version requirements can be 'major.minor.patch', 'major.minor' or just 'major', |
|
41 | - * so '13.0.1', '13.0' and '13' are valid. |
|
42 | - * |
|
43 | - * @param string $actual version as major.minor.patch notation |
|
44 | - * @param string $required version where major is required and minor and patch are optional |
|
45 | - * @param string $comparator passed to `version_compare` |
|
46 | - * @return bool whether the requirement is fulfilled |
|
47 | - * @throws InvalidArgumentException if versions specified in an invalid format |
|
48 | - */ |
|
49 | - public function isCompatible(string $actual, string $required, |
|
50 | - string $comparator = '>='): bool { |
|
51 | - if (!preg_match(self::REGEX_ACTUAL, $actual, $matches)) { |
|
52 | - throw new InvalidArgumentException("version specification $actual is invalid"); |
|
53 | - } |
|
54 | - $cleanActual = $matches[0]; |
|
37 | + /** |
|
38 | + * Checks if the given server version fulfills the given (app) version requirements. |
|
39 | + * |
|
40 | + * Version requirements can be 'major.minor.patch', 'major.minor' or just 'major', |
|
41 | + * so '13.0.1', '13.0' and '13' are valid. |
|
42 | + * |
|
43 | + * @param string $actual version as major.minor.patch notation |
|
44 | + * @param string $required version where major is required and minor and patch are optional |
|
45 | + * @param string $comparator passed to `version_compare` |
|
46 | + * @return bool whether the requirement is fulfilled |
|
47 | + * @throws InvalidArgumentException if versions specified in an invalid format |
|
48 | + */ |
|
49 | + public function isCompatible(string $actual, string $required, |
|
50 | + string $comparator = '>='): bool { |
|
51 | + if (!preg_match(self::REGEX_ACTUAL, $actual, $matches)) { |
|
52 | + throw new InvalidArgumentException("version specification $actual is invalid"); |
|
53 | + } |
|
54 | + $cleanActual = $matches[0]; |
|
55 | 55 | |
56 | - if (preg_match(self::REGEX_MAJOR, $required) === 1) { |
|
57 | - return $this->compareMajor($cleanActual, $required, $comparator); |
|
58 | - } elseif (preg_match(self::REGEX_MAJOR_MINOR, $required) === 1) { |
|
59 | - return $this->compareMajorMinor($cleanActual, $required, $comparator); |
|
60 | - } elseif (preg_match(self::REGEX_MAJOR_MINOR_PATCH, $required) === 1) { |
|
61 | - return $this->compareMajorMinorPatch($cleanActual, $required, $comparator); |
|
62 | - } else { |
|
63 | - throw new InvalidArgumentException("required version $required is invalid"); |
|
64 | - } |
|
65 | - } |
|
56 | + if (preg_match(self::REGEX_MAJOR, $required) === 1) { |
|
57 | + return $this->compareMajor($cleanActual, $required, $comparator); |
|
58 | + } elseif (preg_match(self::REGEX_MAJOR_MINOR, $required) === 1) { |
|
59 | + return $this->compareMajorMinor($cleanActual, $required, $comparator); |
|
60 | + } elseif (preg_match(self::REGEX_MAJOR_MINOR_PATCH, $required) === 1) { |
|
61 | + return $this->compareMajorMinorPatch($cleanActual, $required, $comparator); |
|
62 | + } else { |
|
63 | + throw new InvalidArgumentException("required version $required is invalid"); |
|
64 | + } |
|
65 | + } |
|
66 | 66 | |
67 | - private function compareMajor(string $actual, string $required, |
|
68 | - string $comparator) { |
|
69 | - $actualMajor = explode('.', $actual)[0]; |
|
70 | - $requiredMajor = explode('.', $required)[0]; |
|
67 | + private function compareMajor(string $actual, string $required, |
|
68 | + string $comparator) { |
|
69 | + $actualMajor = explode('.', $actual)[0]; |
|
70 | + $requiredMajor = explode('.', $required)[0]; |
|
71 | 71 | |
72 | - return version_compare($actualMajor, $requiredMajor, $comparator); |
|
73 | - } |
|
72 | + return version_compare($actualMajor, $requiredMajor, $comparator); |
|
73 | + } |
|
74 | 74 | |
75 | - private function compareMajorMinor(string $actual, string $required, |
|
76 | - string $comparator) { |
|
77 | - $actualMajor = explode('.', $actual)[0]; |
|
78 | - $actualMinor = explode('.', $actual)[1]; |
|
79 | - $requiredMajor = explode('.', $required)[0]; |
|
80 | - $requiredMinor = explode('.', $required)[1]; |
|
75 | + private function compareMajorMinor(string $actual, string $required, |
|
76 | + string $comparator) { |
|
77 | + $actualMajor = explode('.', $actual)[0]; |
|
78 | + $actualMinor = explode('.', $actual)[1]; |
|
79 | + $requiredMajor = explode('.', $required)[0]; |
|
80 | + $requiredMinor = explode('.', $required)[1]; |
|
81 | 81 | |
82 | - return version_compare("$actualMajor.$actualMinor", |
|
83 | - "$requiredMajor.$requiredMinor", $comparator); |
|
84 | - } |
|
82 | + return version_compare("$actualMajor.$actualMinor", |
|
83 | + "$requiredMajor.$requiredMinor", $comparator); |
|
84 | + } |
|
85 | 85 | |
86 | - private function compareMajorMinorPatch($actual, $required, $comparator) { |
|
87 | - $actualMajor = explode('.', $actual)[0]; |
|
88 | - $actualMinor = explode('.', $actual)[1]; |
|
89 | - $actualPatch = explode('.', $actual)[2]; |
|
90 | - $requiredMajor = explode('.', $required)[0]; |
|
91 | - $requiredMinor = explode('.', $required)[1]; |
|
92 | - $requiredPatch = explode('.', $required)[2]; |
|
86 | + private function compareMajorMinorPatch($actual, $required, $comparator) { |
|
87 | + $actualMajor = explode('.', $actual)[0]; |
|
88 | + $actualMinor = explode('.', $actual)[1]; |
|
89 | + $actualPatch = explode('.', $actual)[2]; |
|
90 | + $requiredMajor = explode('.', $required)[0]; |
|
91 | + $requiredMinor = explode('.', $required)[1]; |
|
92 | + $requiredPatch = explode('.', $required)[2]; |
|
93 | 93 | |
94 | - return version_compare("$actualMajor.$actualMinor.$actualPatch", |
|
95 | - "$requiredMajor.$requiredMinor.$requiredPatch", $comparator); |
|
96 | - } |
|
94 | + return version_compare("$actualMajor.$actualMinor.$actualPatch", |
|
95 | + "$requiredMajor.$requiredMinor.$requiredPatch", $comparator); |
|
96 | + } |
|
97 | 97 | } |
@@ -27,24 +27,24 @@ |
||
27 | 27 | namespace OC\App\AppStore\Bundles; |
28 | 28 | |
29 | 29 | class HubBundle extends Bundle { |
30 | - public function getName() { |
|
31 | - return $this->l10n->t('Hub bundle'); |
|
32 | - } |
|
30 | + public function getName() { |
|
31 | + return $this->l10n->t('Hub bundle'); |
|
32 | + } |
|
33 | 33 | |
34 | - public function getAppIdentifiers() { |
|
35 | - $hubApps = [ |
|
36 | - 'spreed', |
|
37 | - 'contacts', |
|
38 | - 'calendar', |
|
39 | - 'mail', |
|
40 | - ]; |
|
34 | + public function getAppIdentifiers() { |
|
35 | + $hubApps = [ |
|
36 | + 'spreed', |
|
37 | + 'contacts', |
|
38 | + 'calendar', |
|
39 | + 'mail', |
|
40 | + ]; |
|
41 | 41 | |
42 | - $architecture = function_exists('php_uname') ? php_uname('m') : null; |
|
43 | - if (isset($architecture) && PHP_OS_FAMILY === 'Linux' && in_array($architecture, ['x86_64', 'aarch64'])) { |
|
44 | - $hubApps[] = 'richdocuments'; |
|
45 | - $hubApps[] = 'richdocumentscode' . ($architecture === 'aarch64' ? '_arm64' : ''); |
|
46 | - } |
|
42 | + $architecture = function_exists('php_uname') ? php_uname('m') : null; |
|
43 | + if (isset($architecture) && PHP_OS_FAMILY === 'Linux' && in_array($architecture, ['x86_64', 'aarch64'])) { |
|
44 | + $hubApps[] = 'richdocuments'; |
|
45 | + $hubApps[] = 'richdocumentscode' . ($architecture === 'aarch64' ? '_arm64' : ''); |
|
46 | + } |
|
47 | 47 | |
48 | - return $hubApps; |
|
49 | - } |
|
48 | + return $hubApps; |
|
49 | + } |
|
50 | 50 | } |
@@ -35,162 +35,162 @@ |
||
35 | 35 | use OCP\IMemcache; |
36 | 36 | |
37 | 37 | class Memcached extends Cache implements IMemcache { |
38 | - use CASTrait; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var \Memcached $cache |
|
42 | - */ |
|
43 | - private static $cache = null; |
|
44 | - |
|
45 | - use CADTrait; |
|
46 | - |
|
47 | - public function __construct($prefix = '') { |
|
48 | - parent::__construct($prefix); |
|
49 | - if (is_null(self::$cache)) { |
|
50 | - self::$cache = new \Memcached(); |
|
51 | - |
|
52 | - $defaultOptions = [ |
|
53 | - \Memcached::OPT_CONNECT_TIMEOUT => 50, |
|
54 | - \Memcached::OPT_RETRY_TIMEOUT => 50, |
|
55 | - \Memcached::OPT_SEND_TIMEOUT => 50, |
|
56 | - \Memcached::OPT_RECV_TIMEOUT => 50, |
|
57 | - \Memcached::OPT_POLL_TIMEOUT => 50, |
|
58 | - |
|
59 | - // Enable compression |
|
60 | - \Memcached::OPT_COMPRESSION => true, |
|
61 | - |
|
62 | - // Turn on consistent hashing |
|
63 | - \Memcached::OPT_LIBKETAMA_COMPATIBLE => true, |
|
64 | - |
|
65 | - // Enable Binary Protocol |
|
66 | - \Memcached::OPT_BINARY_PROTOCOL => true, |
|
67 | - ]; |
|
68 | - /** |
|
69 | - * By default enable igbinary serializer if available |
|
70 | - * |
|
71 | - * Psalm checks depend on if igbinary is installed or not with memcached |
|
72 | - * @psalm-suppress RedundantCondition |
|
73 | - * @psalm-suppress TypeDoesNotContainType |
|
74 | - */ |
|
75 | - if (\Memcached::HAVE_IGBINARY) { |
|
76 | - $defaultOptions[\Memcached::OPT_SERIALIZER] = |
|
77 | - \Memcached::SERIALIZER_IGBINARY; |
|
78 | - } |
|
79 | - $options = \OC::$server->getConfig()->getSystemValue('memcached_options', []); |
|
80 | - if (is_array($options)) { |
|
81 | - $options = $options + $defaultOptions; |
|
82 | - self::$cache->setOptions($options); |
|
83 | - } else { |
|
84 | - throw new HintException("Expected 'memcached_options' config to be an array, got $options"); |
|
85 | - } |
|
86 | - |
|
87 | - $servers = \OC::$server->getSystemConfig()->getValue('memcached_servers'); |
|
88 | - if (!$servers) { |
|
89 | - $server = \OC::$server->getSystemConfig()->getValue('memcached_server'); |
|
90 | - if ($server) { |
|
91 | - $servers = [$server]; |
|
92 | - } else { |
|
93 | - $servers = [['localhost', 11211]]; |
|
94 | - } |
|
95 | - } |
|
96 | - self::$cache->addServers($servers); |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * entries in XCache gets namespaced to prevent collisions between owncloud instances and users |
|
102 | - */ |
|
103 | - protected function getNameSpace() { |
|
104 | - return $this->prefix; |
|
105 | - } |
|
106 | - |
|
107 | - public function get($key) { |
|
108 | - $result = self::$cache->get($this->getNameSpace() . $key); |
|
109 | - if ($result === false and self::$cache->getResultCode() == \Memcached::RES_NOTFOUND) { |
|
110 | - return null; |
|
111 | - } else { |
|
112 | - return $result; |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - public function set($key, $value, $ttl = 0) { |
|
117 | - if ($ttl > 0) { |
|
118 | - $result = self::$cache->set($this->getNameSpace() . $key, $value, $ttl); |
|
119 | - } else { |
|
120 | - $result = self::$cache->set($this->getNameSpace() . $key, $value); |
|
121 | - } |
|
122 | - return $result || $this->isSuccess(); |
|
123 | - } |
|
124 | - |
|
125 | - public function hasKey($key) { |
|
126 | - self::$cache->get($this->getNameSpace() . $key); |
|
127 | - return self::$cache->getResultCode() === \Memcached::RES_SUCCESS; |
|
128 | - } |
|
129 | - |
|
130 | - public function remove($key) { |
|
131 | - $result = self::$cache->delete($this->getNameSpace() . $key); |
|
132 | - return $result || $this->isSuccess() || self::$cache->getResultCode() === \Memcached::RES_NOTFOUND; |
|
133 | - } |
|
134 | - |
|
135 | - public function clear($prefix = '') { |
|
136 | - // Newer Memcached doesn't like getAllKeys(), flush everything |
|
137 | - self::$cache->flush(); |
|
138 | - return true; |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * Set a value in the cache if it's not already stored |
|
143 | - * |
|
144 | - * @param string $key |
|
145 | - * @param mixed $value |
|
146 | - * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 |
|
147 | - * @return bool |
|
148 | - */ |
|
149 | - public function add($key, $value, $ttl = 0) { |
|
150 | - $result = self::$cache->add($this->getPrefix() . $key, $value, $ttl); |
|
151 | - return $result || $this->isSuccess(); |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Increase a stored number |
|
156 | - * |
|
157 | - * @param string $key |
|
158 | - * @param int $step |
|
159 | - * @return int | bool |
|
160 | - */ |
|
161 | - public function inc($key, $step = 1) { |
|
162 | - $this->add($key, 0); |
|
163 | - $result = self::$cache->increment($this->getPrefix() . $key, $step); |
|
164 | - |
|
165 | - if (self::$cache->getResultCode() !== \Memcached::RES_SUCCESS) { |
|
166 | - return false; |
|
167 | - } |
|
168 | - |
|
169 | - return $result; |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Decrease a stored number |
|
174 | - * |
|
175 | - * @param string $key |
|
176 | - * @param int $step |
|
177 | - * @return int | bool |
|
178 | - */ |
|
179 | - public function dec($key, $step = 1) { |
|
180 | - $result = self::$cache->decrement($this->getPrefix() . $key, $step); |
|
181 | - |
|
182 | - if (self::$cache->getResultCode() !== \Memcached::RES_SUCCESS) { |
|
183 | - return false; |
|
184 | - } |
|
185 | - |
|
186 | - return $result; |
|
187 | - } |
|
188 | - |
|
189 | - public static function isAvailable(): bool { |
|
190 | - return extension_loaded('memcached'); |
|
191 | - } |
|
192 | - |
|
193 | - private function isSuccess(): bool { |
|
194 | - return self::$cache->getResultCode() === \Memcached::RES_SUCCESS; |
|
195 | - } |
|
38 | + use CASTrait; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var \Memcached $cache |
|
42 | + */ |
|
43 | + private static $cache = null; |
|
44 | + |
|
45 | + use CADTrait; |
|
46 | + |
|
47 | + public function __construct($prefix = '') { |
|
48 | + parent::__construct($prefix); |
|
49 | + if (is_null(self::$cache)) { |
|
50 | + self::$cache = new \Memcached(); |
|
51 | + |
|
52 | + $defaultOptions = [ |
|
53 | + \Memcached::OPT_CONNECT_TIMEOUT => 50, |
|
54 | + \Memcached::OPT_RETRY_TIMEOUT => 50, |
|
55 | + \Memcached::OPT_SEND_TIMEOUT => 50, |
|
56 | + \Memcached::OPT_RECV_TIMEOUT => 50, |
|
57 | + \Memcached::OPT_POLL_TIMEOUT => 50, |
|
58 | + |
|
59 | + // Enable compression |
|
60 | + \Memcached::OPT_COMPRESSION => true, |
|
61 | + |
|
62 | + // Turn on consistent hashing |
|
63 | + \Memcached::OPT_LIBKETAMA_COMPATIBLE => true, |
|
64 | + |
|
65 | + // Enable Binary Protocol |
|
66 | + \Memcached::OPT_BINARY_PROTOCOL => true, |
|
67 | + ]; |
|
68 | + /** |
|
69 | + * By default enable igbinary serializer if available |
|
70 | + * |
|
71 | + * Psalm checks depend on if igbinary is installed or not with memcached |
|
72 | + * @psalm-suppress RedundantCondition |
|
73 | + * @psalm-suppress TypeDoesNotContainType |
|
74 | + */ |
|
75 | + if (\Memcached::HAVE_IGBINARY) { |
|
76 | + $defaultOptions[\Memcached::OPT_SERIALIZER] = |
|
77 | + \Memcached::SERIALIZER_IGBINARY; |
|
78 | + } |
|
79 | + $options = \OC::$server->getConfig()->getSystemValue('memcached_options', []); |
|
80 | + if (is_array($options)) { |
|
81 | + $options = $options + $defaultOptions; |
|
82 | + self::$cache->setOptions($options); |
|
83 | + } else { |
|
84 | + throw new HintException("Expected 'memcached_options' config to be an array, got $options"); |
|
85 | + } |
|
86 | + |
|
87 | + $servers = \OC::$server->getSystemConfig()->getValue('memcached_servers'); |
|
88 | + if (!$servers) { |
|
89 | + $server = \OC::$server->getSystemConfig()->getValue('memcached_server'); |
|
90 | + if ($server) { |
|
91 | + $servers = [$server]; |
|
92 | + } else { |
|
93 | + $servers = [['localhost', 11211]]; |
|
94 | + } |
|
95 | + } |
|
96 | + self::$cache->addServers($servers); |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * entries in XCache gets namespaced to prevent collisions between owncloud instances and users |
|
102 | + */ |
|
103 | + protected function getNameSpace() { |
|
104 | + return $this->prefix; |
|
105 | + } |
|
106 | + |
|
107 | + public function get($key) { |
|
108 | + $result = self::$cache->get($this->getNameSpace() . $key); |
|
109 | + if ($result === false and self::$cache->getResultCode() == \Memcached::RES_NOTFOUND) { |
|
110 | + return null; |
|
111 | + } else { |
|
112 | + return $result; |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + public function set($key, $value, $ttl = 0) { |
|
117 | + if ($ttl > 0) { |
|
118 | + $result = self::$cache->set($this->getNameSpace() . $key, $value, $ttl); |
|
119 | + } else { |
|
120 | + $result = self::$cache->set($this->getNameSpace() . $key, $value); |
|
121 | + } |
|
122 | + return $result || $this->isSuccess(); |
|
123 | + } |
|
124 | + |
|
125 | + public function hasKey($key) { |
|
126 | + self::$cache->get($this->getNameSpace() . $key); |
|
127 | + return self::$cache->getResultCode() === \Memcached::RES_SUCCESS; |
|
128 | + } |
|
129 | + |
|
130 | + public function remove($key) { |
|
131 | + $result = self::$cache->delete($this->getNameSpace() . $key); |
|
132 | + return $result || $this->isSuccess() || self::$cache->getResultCode() === \Memcached::RES_NOTFOUND; |
|
133 | + } |
|
134 | + |
|
135 | + public function clear($prefix = '') { |
|
136 | + // Newer Memcached doesn't like getAllKeys(), flush everything |
|
137 | + self::$cache->flush(); |
|
138 | + return true; |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Set a value in the cache if it's not already stored |
|
143 | + * |
|
144 | + * @param string $key |
|
145 | + * @param mixed $value |
|
146 | + * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 |
|
147 | + * @return bool |
|
148 | + */ |
|
149 | + public function add($key, $value, $ttl = 0) { |
|
150 | + $result = self::$cache->add($this->getPrefix() . $key, $value, $ttl); |
|
151 | + return $result || $this->isSuccess(); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Increase a stored number |
|
156 | + * |
|
157 | + * @param string $key |
|
158 | + * @param int $step |
|
159 | + * @return int | bool |
|
160 | + */ |
|
161 | + public function inc($key, $step = 1) { |
|
162 | + $this->add($key, 0); |
|
163 | + $result = self::$cache->increment($this->getPrefix() . $key, $step); |
|
164 | + |
|
165 | + if (self::$cache->getResultCode() !== \Memcached::RES_SUCCESS) { |
|
166 | + return false; |
|
167 | + } |
|
168 | + |
|
169 | + return $result; |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Decrease a stored number |
|
174 | + * |
|
175 | + * @param string $key |
|
176 | + * @param int $step |
|
177 | + * @return int | bool |
|
178 | + */ |
|
179 | + public function dec($key, $step = 1) { |
|
180 | + $result = self::$cache->decrement($this->getPrefix() . $key, $step); |
|
181 | + |
|
182 | + if (self::$cache->getResultCode() !== \Memcached::RES_SUCCESS) { |
|
183 | + return false; |
|
184 | + } |
|
185 | + |
|
186 | + return $result; |
|
187 | + } |
|
188 | + |
|
189 | + public static function isAvailable(): bool { |
|
190 | + return extension_loaded('memcached'); |
|
191 | + } |
|
192 | + |
|
193 | + private function isSuccess(): bool { |
|
194 | + return self::$cache->getResultCode() === \Memcached::RES_SUCCESS; |
|
195 | + } |
|
196 | 196 | } |
@@ -31,9 +31,9 @@ |
||
31 | 31 | <h2><?php p($l->t('Connect to your account')) ?></h2> |
32 | 32 | <p class="info"> |
33 | 33 | <?php print_unescaped($l->t('Please log in before granting %1$s access to your %2$s account.', [ |
34 | - '<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>', |
|
35 | - \OCP\Util::sanitizeHTML($_['instanceName']) |
|
36 | - ])) ?> |
|
34 | + '<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>', |
|
35 | + \OCP\Util::sanitizeHTML($_['instanceName']) |
|
36 | + ])) ?> |
|
37 | 37 | </p> |
38 | 38 | |
39 | 39 | <div class="notecard warning"> |
@@ -31,15 +31,15 @@ |
||
31 | 31 | <h2><?php p($l->t('Account access')) ?></h2> |
32 | 32 | <p class="info"> |
33 | 33 | <?php p($l->t('Currently logged in as %1$s (%2$s).', [ |
34 | - $_['userDisplayName'], |
|
35 | - $_['userId'], |
|
36 | - ])) ?> |
|
34 | + $_['userDisplayName'], |
|
35 | + $_['userId'], |
|
36 | + ])) ?> |
|
37 | 37 | </p> |
38 | 38 | <p class="info"> |
39 | 39 | <?php print_unescaped($l->t('You are about to grant %1$s access to your %2$s account.', [ |
40 | - '<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>', |
|
41 | - \OCP\Util::sanitizeHTML($_['instanceName']) |
|
42 | - ])) ?> |
|
40 | + '<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>', |
|
41 | + \OCP\Util::sanitizeHTML($_['instanceName']) |
|
42 | + ])) ?> |
|
43 | 43 | </p> |
44 | 44 | |
45 | 45 | <br/> |
@@ -31,11 +31,11 @@ |
||
31 | 31 | * @since 25.0.0 |
32 | 32 | */ |
33 | 33 | interface IBinaryFinder { |
34 | - /** |
|
35 | - * Try to find a program |
|
36 | - * |
|
37 | - * @return false|string |
|
38 | - * @since 25.0.0 |
|
39 | - */ |
|
40 | - public function findBinaryPath(string $program); |
|
34 | + /** |
|
35 | + * Try to find a program |
|
36 | + * |
|
37 | + * @return false|string |
|
38 | + * @since 25.0.0 |
|
39 | + */ |
|
40 | + public function findBinaryPath(string $program); |
|
41 | 41 | } |
@@ -34,30 +34,30 @@ |
||
34 | 34 | use OCP\Preview\IProviderV2; |
35 | 35 | |
36 | 36 | class ProviderV1Adapter implements IProviderV2 { |
37 | - private $providerV1; |
|
37 | + private $providerV1; |
|
38 | 38 | |
39 | - public function __construct(IProvider $providerV1) { |
|
40 | - $this->providerV1 = $providerV1; |
|
41 | - } |
|
39 | + public function __construct(IProvider $providerV1) { |
|
40 | + $this->providerV1 = $providerV1; |
|
41 | + } |
|
42 | 42 | |
43 | - public function getMimeType(): string { |
|
44 | - return (string)$this->providerV1->getMimeType(); |
|
45 | - } |
|
43 | + public function getMimeType(): string { |
|
44 | + return (string)$this->providerV1->getMimeType(); |
|
45 | + } |
|
46 | 46 | |
47 | - public function isAvailable(FileInfo $file): bool { |
|
48 | - return (bool)$this->providerV1->isAvailable($file); |
|
49 | - } |
|
47 | + public function isAvailable(FileInfo $file): bool { |
|
48 | + return (bool)$this->providerV1->isAvailable($file); |
|
49 | + } |
|
50 | 50 | |
51 | - public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { |
|
52 | - [$view, $path] = $this->getViewAndPath($file); |
|
53 | - $thumbnail = $this->providerV1->getThumbnail($path, $maxX, $maxY, false, $view); |
|
54 | - return $thumbnail === false ? null: $thumbnail; |
|
55 | - } |
|
51 | + public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { |
|
52 | + [$view, $path] = $this->getViewAndPath($file); |
|
53 | + $thumbnail = $this->providerV1->getThumbnail($path, $maxX, $maxY, false, $view); |
|
54 | + return $thumbnail === false ? null: $thumbnail; |
|
55 | + } |
|
56 | 56 | |
57 | - private function getViewAndPath(File $file) { |
|
58 | - $view = new View(dirname($file->getPath())); |
|
59 | - $path = $file->getName(); |
|
57 | + private function getViewAndPath(File $file) { |
|
58 | + $view = new View(dirname($file->getPath())); |
|
59 | + $path = $file->getName(); |
|
60 | 60 | |
61 | - return [$view, $path]; |
|
62 | - } |
|
61 | + return [$view, $path]; |
|
62 | + } |
|
63 | 63 | } |