Passed
Push — master ( 4e9cd2...bc8d14 )
by Roeland
19:16 queued 09:49
created
lib/private/Memcache/Memcached.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	}
98 98
 
99 99
 	public function get($key) {
100
-		$result = self::$cache->get($this->getNameSpace() . $key);
100
+		$result = self::$cache->get($this->getNameSpace().$key);
101 101
 		if ($result === false and self::$cache->getResultCode() == \Memcached::RES_NOTFOUND) {
102 102
 			return null;
103 103
 		} else {
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 
108 108
 	public function set($key, $value, $ttl = 0) {
109 109
 		if ($ttl > 0) {
110
-			$result =  self::$cache->set($this->getNameSpace() . $key, $value, $ttl);
110
+			$result = self::$cache->set($this->getNameSpace().$key, $value, $ttl);
111 111
 		} else {
112
-			$result = self::$cache->set($this->getNameSpace() . $key, $value);
112
+			$result = self::$cache->set($this->getNameSpace().$key, $value);
113 113
 		}
114 114
 		if ($result !== true) {
115 115
 			$this->verifyReturnCode();
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 	}
119 119
 
120 120
 	public function hasKey($key) {
121
-		self::$cache->get($this->getNameSpace() . $key);
121
+		self::$cache->get($this->getNameSpace().$key);
122 122
 		return self::$cache->getResultCode() === \Memcached::RES_SUCCESS;
123 123
 	}
124 124
 
125 125
 	public function remove($key) {
126
-		$result= self::$cache->delete($this->getNameSpace() . $key);
126
+		$result = self::$cache->delete($this->getNameSpace().$key);
127 127
 		if (self::$cache->getResultCode() !== \Memcached::RES_NOTFOUND) {
128 128
 			$this->verifyReturnCode();
129 129
 		}
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	}
132 132
 
133 133
 	public function clear($prefix = '') {
134
-		$prefix = $this->getNameSpace() . $prefix;
134
+		$prefix = $this->getNameSpace().$prefix;
135 135
 		$allKeys = self::$cache->getAllKeys();
136 136
 		if ($allKeys === false) {
137 137
 			// newer Memcached doesn't like getAllKeys(), flush everything
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @throws \Exception
166 166
 	 */
167 167
 	public function add($key, $value, $ttl = 0) {
168
-		$result = self::$cache->add($this->getPrefix() . $key, $value, $ttl);
168
+		$result = self::$cache->add($this->getPrefix().$key, $value, $ttl);
169 169
 		if (self::$cache->getResultCode() !== \Memcached::RES_NOTSTORED) {
170 170
 			$this->verifyReturnCode();
171 171
 		}
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	public function inc($key, $step = 1) {
183 183
 		$this->add($key, 0);
184
-		$result = self::$cache->increment($this->getPrefix() . $key, $step);
184
+		$result = self::$cache->increment($this->getPrefix().$key, $step);
185 185
 
186 186
 		if (self::$cache->getResultCode() !== \Memcached::RES_SUCCESS) {
187 187
 			return false;
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 * @return int | bool
199 199
 	 */
200 200
 	public function dec($key, $step = 1) {
201
-		$result = self::$cache->decrement($this->getPrefix() . $key, $step);
201
+		$result = self::$cache->decrement($this->getPrefix().$key, $step);
202 202
 
203 203
 		if (self::$cache->getResultCode() !== \Memcached::RES_SUCCESS) {
204 204
 			return false;
Please login to merge, or discard this patch.
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -35,193 +35,193 @@
 block discarded – undo
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
-			// by default enable igbinary serializer if available
69
-			if (\Memcached::HAVE_IGBINARY) {
70
-				$defaultOptions[\Memcached::OPT_SERIALIZER] =
71
-					\Memcached::SERIALIZER_IGBINARY;
72
-			}
73
-			$options = \OC::$server->getConfig()->getSystemValue('memcached_options', []);
74
-			if (is_array($options)) {
75
-				$options = $options + $defaultOptions;
76
-				self::$cache->setOptions($options);
77
-			} else {
78
-				throw new HintException("Expected 'memcached_options' config to be an array, got $options");
79
-			}
80
-
81
-			$servers = \OC::$server->getSystemConfig()->getValue('memcached_servers');
82
-			if (!$servers) {
83
-				$server = \OC::$server->getSystemConfig()->getValue('memcached_server');
84
-				if ($server) {
85
-					$servers = [$server];
86
-				} else {
87
-					$servers = [['localhost', 11211]];
88
-				}
89
-			}
90
-			self::$cache->addServers($servers);
91
-		}
92
-	}
93
-
94
-	/**
95
-	 * entries in XCache gets namespaced to prevent collisions between owncloud instances and users
96
-	 */
97
-	protected function getNameSpace() {
98
-		return $this->prefix;
99
-	}
100
-
101
-	public function get($key) {
102
-		$result = self::$cache->get($this->getNameSpace() . $key);
103
-		if ($result === false and self::$cache->getResultCode() == \Memcached::RES_NOTFOUND) {
104
-			return null;
105
-		} else {
106
-			return $result;
107
-		}
108
-	}
109
-
110
-	public function set($key, $value, $ttl = 0) {
111
-		if ($ttl > 0) {
112
-			$result =  self::$cache->set($this->getNameSpace() . $key, $value, $ttl);
113
-		} else {
114
-			$result = self::$cache->set($this->getNameSpace() . $key, $value);
115
-		}
116
-		if ($result !== true) {
117
-			$this->verifyReturnCode();
118
-		}
119
-		return $result;
120
-	}
121
-
122
-	public function hasKey($key) {
123
-		self::$cache->get($this->getNameSpace() . $key);
124
-		return self::$cache->getResultCode() === \Memcached::RES_SUCCESS;
125
-	}
126
-
127
-	public function remove($key) {
128
-		$result= self::$cache->delete($this->getNameSpace() . $key);
129
-		if (self::$cache->getResultCode() !== \Memcached::RES_NOTFOUND) {
130
-			$this->verifyReturnCode();
131
-		}
132
-		return $result;
133
-	}
134
-
135
-	public function clear($prefix = '') {
136
-		$prefix = $this->getNameSpace() . $prefix;
137
-		$allKeys = self::$cache->getAllKeys();
138
-		if ($allKeys === false) {
139
-			// newer Memcached doesn't like getAllKeys(), flush everything
140
-			self::$cache->flush();
141
-			return true;
142
-		}
143
-		$keys = [];
144
-		$prefixLength = strlen($prefix);
145
-		foreach ($allKeys as $key) {
146
-			if (substr($key, 0, $prefixLength) === $prefix) {
147
-				$keys[] = $key;
148
-			}
149
-		}
150
-		if (method_exists(self::$cache, 'deleteMulti')) {
151
-			self::$cache->deleteMulti($keys);
152
-		} else {
153
-			foreach ($keys as $key) {
154
-				self::$cache->delete($key);
155
-			}
156
-		}
157
-		return true;
158
-	}
159
-
160
-	/**
161
-	 * Set a value in the cache if it's not already stored
162
-	 *
163
-	 * @param string $key
164
-	 * @param mixed $value
165
-	 * @param int $ttl Time To Live in seconds. Defaults to 60*60*24
166
-	 * @return bool
167
-	 * @throws \Exception
168
-	 */
169
-	public function add($key, $value, $ttl = 0) {
170
-		$result = self::$cache->add($this->getPrefix() . $key, $value, $ttl);
171
-		if (self::$cache->getResultCode() !== \Memcached::RES_NOTSTORED) {
172
-			$this->verifyReturnCode();
173
-		}
174
-		return $result;
175
-	}
176
-
177
-	/**
178
-	 * Increase a stored number
179
-	 *
180
-	 * @param string $key
181
-	 * @param int $step
182
-	 * @return int | bool
183
-	 */
184
-	public function inc($key, $step = 1) {
185
-		$this->add($key, 0);
186
-		$result = self::$cache->increment($this->getPrefix() . $key, $step);
187
-
188
-		if (self::$cache->getResultCode() !== \Memcached::RES_SUCCESS) {
189
-			return false;
190
-		}
191
-
192
-		return $result;
193
-	}
194
-
195
-	/**
196
-	 * Decrease a stored number
197
-	 *
198
-	 * @param string $key
199
-	 * @param int $step
200
-	 * @return int | bool
201
-	 */
202
-	public function dec($key, $step = 1) {
203
-		$result = self::$cache->decrement($this->getPrefix() . $key, $step);
204
-
205
-		if (self::$cache->getResultCode() !== \Memcached::RES_SUCCESS) {
206
-			return false;
207
-		}
208
-
209
-		return $result;
210
-	}
211
-
212
-	static public function isAvailable() {
213
-		return extension_loaded('memcached');
214
-	}
215
-
216
-	/**
217
-	 * @throws \Exception
218
-	 */
219
-	private function verifyReturnCode() {
220
-		$code = self::$cache->getResultCode();
221
-		if ($code === \Memcached::RES_SUCCESS) {
222
-			return;
223
-		}
224
-		$message = self::$cache->getResultMessage();
225
-		throw new \Exception("Error $code interacting with memcached : $message");
226
-	}
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
+            // by default enable igbinary serializer if available
69
+            if (\Memcached::HAVE_IGBINARY) {
70
+                $defaultOptions[\Memcached::OPT_SERIALIZER] =
71
+                    \Memcached::SERIALIZER_IGBINARY;
72
+            }
73
+            $options = \OC::$server->getConfig()->getSystemValue('memcached_options', []);
74
+            if (is_array($options)) {
75
+                $options = $options + $defaultOptions;
76
+                self::$cache->setOptions($options);
77
+            } else {
78
+                throw new HintException("Expected 'memcached_options' config to be an array, got $options");
79
+            }
80
+
81
+            $servers = \OC::$server->getSystemConfig()->getValue('memcached_servers');
82
+            if (!$servers) {
83
+                $server = \OC::$server->getSystemConfig()->getValue('memcached_server');
84
+                if ($server) {
85
+                    $servers = [$server];
86
+                } else {
87
+                    $servers = [['localhost', 11211]];
88
+                }
89
+            }
90
+            self::$cache->addServers($servers);
91
+        }
92
+    }
93
+
94
+    /**
95
+     * entries in XCache gets namespaced to prevent collisions between owncloud instances and users
96
+     */
97
+    protected function getNameSpace() {
98
+        return $this->prefix;
99
+    }
100
+
101
+    public function get($key) {
102
+        $result = self::$cache->get($this->getNameSpace() . $key);
103
+        if ($result === false and self::$cache->getResultCode() == \Memcached::RES_NOTFOUND) {
104
+            return null;
105
+        } else {
106
+            return $result;
107
+        }
108
+    }
109
+
110
+    public function set($key, $value, $ttl = 0) {
111
+        if ($ttl > 0) {
112
+            $result =  self::$cache->set($this->getNameSpace() . $key, $value, $ttl);
113
+        } else {
114
+            $result = self::$cache->set($this->getNameSpace() . $key, $value);
115
+        }
116
+        if ($result !== true) {
117
+            $this->verifyReturnCode();
118
+        }
119
+        return $result;
120
+    }
121
+
122
+    public function hasKey($key) {
123
+        self::$cache->get($this->getNameSpace() . $key);
124
+        return self::$cache->getResultCode() === \Memcached::RES_SUCCESS;
125
+    }
126
+
127
+    public function remove($key) {
128
+        $result= self::$cache->delete($this->getNameSpace() . $key);
129
+        if (self::$cache->getResultCode() !== \Memcached::RES_NOTFOUND) {
130
+            $this->verifyReturnCode();
131
+        }
132
+        return $result;
133
+    }
134
+
135
+    public function clear($prefix = '') {
136
+        $prefix = $this->getNameSpace() . $prefix;
137
+        $allKeys = self::$cache->getAllKeys();
138
+        if ($allKeys === false) {
139
+            // newer Memcached doesn't like getAllKeys(), flush everything
140
+            self::$cache->flush();
141
+            return true;
142
+        }
143
+        $keys = [];
144
+        $prefixLength = strlen($prefix);
145
+        foreach ($allKeys as $key) {
146
+            if (substr($key, 0, $prefixLength) === $prefix) {
147
+                $keys[] = $key;
148
+            }
149
+        }
150
+        if (method_exists(self::$cache, 'deleteMulti')) {
151
+            self::$cache->deleteMulti($keys);
152
+        } else {
153
+            foreach ($keys as $key) {
154
+                self::$cache->delete($key);
155
+            }
156
+        }
157
+        return true;
158
+    }
159
+
160
+    /**
161
+     * Set a value in the cache if it's not already stored
162
+     *
163
+     * @param string $key
164
+     * @param mixed $value
165
+     * @param int $ttl Time To Live in seconds. Defaults to 60*60*24
166
+     * @return bool
167
+     * @throws \Exception
168
+     */
169
+    public function add($key, $value, $ttl = 0) {
170
+        $result = self::$cache->add($this->getPrefix() . $key, $value, $ttl);
171
+        if (self::$cache->getResultCode() !== \Memcached::RES_NOTSTORED) {
172
+            $this->verifyReturnCode();
173
+        }
174
+        return $result;
175
+    }
176
+
177
+    /**
178
+     * Increase a stored number
179
+     *
180
+     * @param string $key
181
+     * @param int $step
182
+     * @return int | bool
183
+     */
184
+    public function inc($key, $step = 1) {
185
+        $this->add($key, 0);
186
+        $result = self::$cache->increment($this->getPrefix() . $key, $step);
187
+
188
+        if (self::$cache->getResultCode() !== \Memcached::RES_SUCCESS) {
189
+            return false;
190
+        }
191
+
192
+        return $result;
193
+    }
194
+
195
+    /**
196
+     * Decrease a stored number
197
+     *
198
+     * @param string $key
199
+     * @param int $step
200
+     * @return int | bool
201
+     */
202
+    public function dec($key, $step = 1) {
203
+        $result = self::$cache->decrement($this->getPrefix() . $key, $step);
204
+
205
+        if (self::$cache->getResultCode() !== \Memcached::RES_SUCCESS) {
206
+            return false;
207
+        }
208
+
209
+        return $result;
210
+    }
211
+
212
+    static public function isAvailable() {
213
+        return extension_loaded('memcached');
214
+    }
215
+
216
+    /**
217
+     * @throws \Exception
218
+     */
219
+    private function verifyReturnCode() {
220
+        $code = self::$cache->getResultCode();
221
+        if ($code === \Memcached::RES_SUCCESS) {
222
+            return;
223
+        }
224
+        $message = self::$cache->getResultMessage();
225
+        throw new \Exception("Error $code interacting with memcached : $message");
226
+    }
227 227
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Command/CleanupRemoteStorages.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 
61 61
 		$remoteStorages = $this->getRemoteStorages();
62 62
 
63
-		$output->writeln(count($remoteStorages) . ' remote storage(s) need(s) to be checked');
63
+		$output->writeln(count($remoteStorages).' remote storage(s) need(s) to be checked');
64 64
 
65 65
 		$remoteShareIds = $this->getRemoteShareIds();
66 66
 
67
-		$output->writeln(count($remoteShareIds) . ' remote share(s) exist');
67
+		$output->writeln(count($remoteShareIds).' remote share(s) exist');
68 68
 
69 69
 		foreach ($remoteShareIds as $id => $remoteShareId) {
70 70
 			if (isset($remoteStorages[$remoteShareId])) {
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
 			->where($queryBuilder->expr()->like(
143 143
 				'id',
144 144
 				// match all 'shared::' + 32 characters storages
145
-				$queryBuilder->createNamedParameter($this->connection->escapeLikeParameter('shared::') . str_repeat('_', 32)),
145
+				$queryBuilder->createNamedParameter($this->connection->escapeLikeParameter('shared::').str_repeat('_', 32)),
146 146
 				IQueryBuilder::PARAM_STR)
147 147
 			)
148 148
 			->andWhere($queryBuilder->expr()->notLike(
149 149
 				'id',
150 150
 				// but not the ones starting with a '/', they are for normal shares
151
-				$queryBuilder->createNamedParameter($this->connection->escapeLikeParameter('shared::/') . '%'),
151
+				$queryBuilder->createNamedParameter($this->connection->escapeLikeParameter('shared::/').'%'),
152 152
 				IQueryBuilder::PARAM_STR)
153 153
 			)->orderBy('numeric_id');
154 154
 		$query = $queryBuilder->execute();
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 		$remoteShareIds = [];
173 173
 
174 174
 		while ($row = $query->fetch()) {
175
-			$remoteShareIds[$row['id']] = 'shared::' . md5($row['share_token'] . '@' . $row['remote']);
175
+			$remoteShareIds[$row['id']] = 'shared::'.md5($row['share_token'].'@'.$row['remote']);
176 176
 		}
177 177
 
178 178
 		return $remoteShareIds;
Please login to merge, or discard this patch.
Indentation   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -37,147 +37,147 @@
 block discarded – undo
37 37
  */
38 38
 class CleanupRemoteStorages extends Command {
39 39
 
40
-	/**
41
-	 * @var IDBConnection
42
-	 */
43
-	protected $connection;
44
-
45
-	public function __construct(IDBConnection $connection) {
46
-		$this->connection = $connection;
47
-		parent::__construct();
48
-	}
49
-
50
-	protected function configure() {
51
-		$this
52
-			->setName('sharing:cleanup-remote-storages')
53
-			->setDescription('Cleanup shared storage entries that have no matching entry in the shares_external table')
54
-			->addOption(
55
-				'dry-run',
56
-				null,
57
-				InputOption::VALUE_NONE,
58
-				'only show which storages would be deleted'
59
-			);
60
-	}
61
-
62
-	public function execute(InputInterface $input, OutputInterface $output) {
63
-
64
-		$remoteStorages = $this->getRemoteStorages();
65
-
66
-		$output->writeln(count($remoteStorages) . ' remote storage(s) need(s) to be checked');
67
-
68
-		$remoteShareIds = $this->getRemoteShareIds();
69
-
70
-		$output->writeln(count($remoteShareIds) . ' remote share(s) exist');
71
-
72
-		foreach ($remoteShareIds as $id => $remoteShareId) {
73
-			if (isset($remoteStorages[$remoteShareId])) {
74
-				if ($input->getOption('dry-run') || $output->isVerbose()) {
75
-					$output->writeln("<info>$remoteShareId belongs to remote share $id</info>");
76
-				}
77
-
78
-				unset($remoteStorages[$remoteShareId]);
79
-			} else {
80
-				$output->writeln("<comment>$remoteShareId for share $id has no matching storage, yet</comment>");
81
-			}
82
-		}
83
-
84
-		if (empty($remoteStorages)) {
85
-			$output->writeln('<info>no storages deleted</info>');
86
-		} else {
87
-			$dryRun = $input->getOption('dry-run');
88
-			foreach ($remoteStorages as $id => $numericId) {
89
-				if ($dryRun) {
90
-					$output->writeln("<error>$id [$numericId] can be deleted</error>");
91
-					$this->countFiles($numericId, $output);
92
-				} else {
93
-					$this->deleteStorage($id, $numericId, $output);
94
-				}
95
-			}
96
-		}
97
-	}
98
-
99
-	public function countFiles($numericId, OutputInterface $output) {
100
-		$queryBuilder = $this->connection->getQueryBuilder();
101
-		$queryBuilder->select($queryBuilder->func()->count('fileid'))
102
-			->from('filecache')
103
-			->where($queryBuilder->expr()->eq(
104
-				'storage',
105
-				$queryBuilder->createNamedParameter($numericId, IQueryBuilder::PARAM_STR),
106
-				IQueryBuilder::PARAM_STR)
107
-			);
108
-		$result = $queryBuilder->execute();
109
-		$count = $result->fetchColumn();
110
-		$output->writeln("$count files can be deleted for storage $numericId");
111
-	}
112
-
113
-	public function deleteStorage($id, $numericId, OutputInterface $output) {
114
-		$queryBuilder = $this->connection->getQueryBuilder();
115
-		$queryBuilder->delete('storages')
116
-			->where($queryBuilder->expr()->eq(
117
-				'id',
118
-				$queryBuilder->createNamedParameter($id, IQueryBuilder::PARAM_STR),
119
-				IQueryBuilder::PARAM_STR)
120
-			);
121
-		$output->write("deleting $id [$numericId] ... ");
122
-		$count = $queryBuilder->execute();
123
-		$output->writeln("deleted $count storage");
124
-		$this->deleteFiles($numericId, $output);
125
-	}
126
-
127
-	public function deleteFiles($numericId, OutputInterface $output) {
128
-		$queryBuilder = $this->connection->getQueryBuilder();
129
-		$queryBuilder->delete('filecache')
130
-			->where($queryBuilder->expr()->eq(
131
-				'storage',
132
-				$queryBuilder->createNamedParameter($numericId, IQueryBuilder::PARAM_STR),
133
-				IQueryBuilder::PARAM_STR)
134
-			);
135
-		$output->write("deleting files for storage $numericId ... ");
136
-		$count = $queryBuilder->execute();
137
-		$output->writeln("deleted $count files");
138
-	}
139
-
140
-	public function getRemoteStorages() {
141
-
142
-		$queryBuilder = $this->connection->getQueryBuilder();
143
-		$queryBuilder->select(['id', 'numeric_id'])
144
-			->from('storages')
145
-			->where($queryBuilder->expr()->like(
146
-				'id',
147
-				// match all 'shared::' + 32 characters storages
148
-				$queryBuilder->createNamedParameter($this->connection->escapeLikeParameter('shared::') . str_repeat('_', 32)),
149
-				IQueryBuilder::PARAM_STR)
150
-			)
151
-			->andWhere($queryBuilder->expr()->notLike(
152
-				'id',
153
-				// but not the ones starting with a '/', they are for normal shares
154
-				$queryBuilder->createNamedParameter($this->connection->escapeLikeParameter('shared::/') . '%'),
155
-				IQueryBuilder::PARAM_STR)
156
-			)->orderBy('numeric_id');
157
-		$query = $queryBuilder->execute();
158
-
159
-		$remoteStorages = [];
160
-
161
-		while ($row = $query->fetch()) {
162
-			$remoteStorages[$row['id']] = $row['numeric_id'];
163
-		}
164
-
165
-		return $remoteStorages;
166
-	}
167
-
168
-	public function getRemoteShareIds() {
169
-
170
-		$queryBuilder = $this->connection->getQueryBuilder();
171
-		$queryBuilder->select(['id', 'share_token', 'remote'])
172
-			->from('share_external');
173
-		$query = $queryBuilder->execute();
174
-
175
-		$remoteShareIds = [];
176
-
177
-		while ($row = $query->fetch()) {
178
-			$remoteShareIds[$row['id']] = 'shared::' . md5($row['share_token'] . '@' . $row['remote']);
179
-		}
180
-
181
-		return $remoteShareIds;
182
-	}
40
+    /**
41
+     * @var IDBConnection
42
+     */
43
+    protected $connection;
44
+
45
+    public function __construct(IDBConnection $connection) {
46
+        $this->connection = $connection;
47
+        parent::__construct();
48
+    }
49
+
50
+    protected function configure() {
51
+        $this
52
+            ->setName('sharing:cleanup-remote-storages')
53
+            ->setDescription('Cleanup shared storage entries that have no matching entry in the shares_external table')
54
+            ->addOption(
55
+                'dry-run',
56
+                null,
57
+                InputOption::VALUE_NONE,
58
+                'only show which storages would be deleted'
59
+            );
60
+    }
61
+
62
+    public function execute(InputInterface $input, OutputInterface $output) {
63
+
64
+        $remoteStorages = $this->getRemoteStorages();
65
+
66
+        $output->writeln(count($remoteStorages) . ' remote storage(s) need(s) to be checked');
67
+
68
+        $remoteShareIds = $this->getRemoteShareIds();
69
+
70
+        $output->writeln(count($remoteShareIds) . ' remote share(s) exist');
71
+
72
+        foreach ($remoteShareIds as $id => $remoteShareId) {
73
+            if (isset($remoteStorages[$remoteShareId])) {
74
+                if ($input->getOption('dry-run') || $output->isVerbose()) {
75
+                    $output->writeln("<info>$remoteShareId belongs to remote share $id</info>");
76
+                }
77
+
78
+                unset($remoteStorages[$remoteShareId]);
79
+            } else {
80
+                $output->writeln("<comment>$remoteShareId for share $id has no matching storage, yet</comment>");
81
+            }
82
+        }
83
+
84
+        if (empty($remoteStorages)) {
85
+            $output->writeln('<info>no storages deleted</info>');
86
+        } else {
87
+            $dryRun = $input->getOption('dry-run');
88
+            foreach ($remoteStorages as $id => $numericId) {
89
+                if ($dryRun) {
90
+                    $output->writeln("<error>$id [$numericId] can be deleted</error>");
91
+                    $this->countFiles($numericId, $output);
92
+                } else {
93
+                    $this->deleteStorage($id, $numericId, $output);
94
+                }
95
+            }
96
+        }
97
+    }
98
+
99
+    public function countFiles($numericId, OutputInterface $output) {
100
+        $queryBuilder = $this->connection->getQueryBuilder();
101
+        $queryBuilder->select($queryBuilder->func()->count('fileid'))
102
+            ->from('filecache')
103
+            ->where($queryBuilder->expr()->eq(
104
+                'storage',
105
+                $queryBuilder->createNamedParameter($numericId, IQueryBuilder::PARAM_STR),
106
+                IQueryBuilder::PARAM_STR)
107
+            );
108
+        $result = $queryBuilder->execute();
109
+        $count = $result->fetchColumn();
110
+        $output->writeln("$count files can be deleted for storage $numericId");
111
+    }
112
+
113
+    public function deleteStorage($id, $numericId, OutputInterface $output) {
114
+        $queryBuilder = $this->connection->getQueryBuilder();
115
+        $queryBuilder->delete('storages')
116
+            ->where($queryBuilder->expr()->eq(
117
+                'id',
118
+                $queryBuilder->createNamedParameter($id, IQueryBuilder::PARAM_STR),
119
+                IQueryBuilder::PARAM_STR)
120
+            );
121
+        $output->write("deleting $id [$numericId] ... ");
122
+        $count = $queryBuilder->execute();
123
+        $output->writeln("deleted $count storage");
124
+        $this->deleteFiles($numericId, $output);
125
+    }
126
+
127
+    public function deleteFiles($numericId, OutputInterface $output) {
128
+        $queryBuilder = $this->connection->getQueryBuilder();
129
+        $queryBuilder->delete('filecache')
130
+            ->where($queryBuilder->expr()->eq(
131
+                'storage',
132
+                $queryBuilder->createNamedParameter($numericId, IQueryBuilder::PARAM_STR),
133
+                IQueryBuilder::PARAM_STR)
134
+            );
135
+        $output->write("deleting files for storage $numericId ... ");
136
+        $count = $queryBuilder->execute();
137
+        $output->writeln("deleted $count files");
138
+    }
139
+
140
+    public function getRemoteStorages() {
141
+
142
+        $queryBuilder = $this->connection->getQueryBuilder();
143
+        $queryBuilder->select(['id', 'numeric_id'])
144
+            ->from('storages')
145
+            ->where($queryBuilder->expr()->like(
146
+                'id',
147
+                // match all 'shared::' + 32 characters storages
148
+                $queryBuilder->createNamedParameter($this->connection->escapeLikeParameter('shared::') . str_repeat('_', 32)),
149
+                IQueryBuilder::PARAM_STR)
150
+            )
151
+            ->andWhere($queryBuilder->expr()->notLike(
152
+                'id',
153
+                // but not the ones starting with a '/', they are for normal shares
154
+                $queryBuilder->createNamedParameter($this->connection->escapeLikeParameter('shared::/') . '%'),
155
+                IQueryBuilder::PARAM_STR)
156
+            )->orderBy('numeric_id');
157
+        $query = $queryBuilder->execute();
158
+
159
+        $remoteStorages = [];
160
+
161
+        while ($row = $query->fetch()) {
162
+            $remoteStorages[$row['id']] = $row['numeric_id'];
163
+        }
164
+
165
+        return $remoteStorages;
166
+    }
167
+
168
+    public function getRemoteShareIds() {
169
+
170
+        $queryBuilder = $this->connection->getQueryBuilder();
171
+        $queryBuilder->select(['id', 'share_token', 'remote'])
172
+            ->from('share_external');
173
+        $query = $queryBuilder->execute();
174
+
175
+        $remoteShareIds = [];
176
+
177
+        while ($row = $query->fetch()) {
178
+            $remoteShareIds[$row['id']] = 'shared::' . md5($row['share_token'] . '@' . $row['remote']);
179
+        }
180
+
181
+        return $remoteShareIds;
182
+    }
183 183
 }
Please login to merge, or discard this patch.
lib/private/App/CodeChecker/MigrationSchemaChecker.php 1 patch
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -29,179 +29,179 @@
 block discarded – undo
29 29
 
30 30
 class MigrationSchemaChecker extends NodeVisitorAbstract {
31 31
 
32
-	/** @var string */
33
-	protected $schemaVariableName = null;
34
-	/** @var array */
35
-	protected $tableVariableNames = [];
36
-	/** @var array */
37
-	public $errors = [];
32
+    /** @var string */
33
+    protected $schemaVariableName = null;
34
+    /** @var array */
35
+    protected $tableVariableNames = [];
36
+    /** @var array */
37
+    public $errors = [];
38 38
 
39
-	/**
40
-	 * @param Node $node
41
-	 * @return void
42
-	 *
43
-	 * @suppress PhanUndeclaredProperty
44
-	 */
45
-	public function enterNode(Node $node) {
46
-		/**
47
-		 * Check tables
48
-		 */
49
-		if ($this->schemaVariableName !== null &&
50
-			 $node instanceof Node\Expr\Assign &&
51
-			 $node->var instanceof Node\Expr\Variable &&
52
-			 $node->expr instanceof Node\Expr\MethodCall &&
53
-			 $node->expr->var instanceof Node\Expr\Variable &&
54
-			 $node->expr->var->name === $this->schemaVariableName) {
39
+    /**
40
+     * @param Node $node
41
+     * @return void
42
+     *
43
+     * @suppress PhanUndeclaredProperty
44
+     */
45
+    public function enterNode(Node $node) {
46
+        /**
47
+         * Check tables
48
+         */
49
+        if ($this->schemaVariableName !== null &&
50
+             $node instanceof Node\Expr\Assign &&
51
+             $node->var instanceof Node\Expr\Variable &&
52
+             $node->expr instanceof Node\Expr\MethodCall &&
53
+             $node->expr->var instanceof Node\Expr\Variable &&
54
+             $node->expr->var->name === $this->schemaVariableName) {
55 55
 
56
-			if ($node->expr->name === 'createTable') {
57
-				if (isset($node->expr->args[0]) && $node->expr->args[0]->value instanceof Node\Scalar\String_) {
58
-					if (!$this->checkNameLength($node->expr->args[0]->value->value)) {
59
-						$this->errors[] = [
60
-							'line' => $node->getLine(),
61
-							'disallowedToken' => $node->expr->args[0]->value->value,
62
-							'reason' => 'Table name is too long (max. 27)',
63
-						];
64
-					} else {
65
-						$this->tableVariableNames[$node->var->name] = $node->expr->args[0]->value->value;
66
-					}
67
-				}
68
-			} else if ($node->expr->name === 'getTable') {
69
-				if (isset($node->expr->args[0]) && $node->expr->args[0]->value instanceof Node\Scalar\String_) {
70
-					$this->tableVariableNames[$node->var->name] = $node->expr->args[0]->value->value;
71
-				}
72
-			}
73
-		} else if ($this->schemaVariableName !== null &&
74
-			 $node instanceof Node\Expr\MethodCall &&
75
-			 $node->var instanceof Node\Expr\Variable &&
76
-			 $node->var->name === $this->schemaVariableName) {
56
+            if ($node->expr->name === 'createTable') {
57
+                if (isset($node->expr->args[0]) && $node->expr->args[0]->value instanceof Node\Scalar\String_) {
58
+                    if (!$this->checkNameLength($node->expr->args[0]->value->value)) {
59
+                        $this->errors[] = [
60
+                            'line' => $node->getLine(),
61
+                            'disallowedToken' => $node->expr->args[0]->value->value,
62
+                            'reason' => 'Table name is too long (max. 27)',
63
+                        ];
64
+                    } else {
65
+                        $this->tableVariableNames[$node->var->name] = $node->expr->args[0]->value->value;
66
+                    }
67
+                }
68
+            } else if ($node->expr->name === 'getTable') {
69
+                if (isset($node->expr->args[0]) && $node->expr->args[0]->value instanceof Node\Scalar\String_) {
70
+                    $this->tableVariableNames[$node->var->name] = $node->expr->args[0]->value->value;
71
+                }
72
+            }
73
+        } else if ($this->schemaVariableName !== null &&
74
+             $node instanceof Node\Expr\MethodCall &&
75
+             $node->var instanceof Node\Expr\Variable &&
76
+             $node->var->name === $this->schemaVariableName) {
77 77
 
78
-			if ($node->name === 'renameTable') {
79
-				$this->errors[] = [
80
-					'line' => $node->getLine(),
81
-					'disallowedToken' => 'Deprecated method',
82
-					'reason' => sprintf(
83
-						'`$%s->renameTable()` must not be used',
84
-						$node->var->name
85
-					),
86
-				];
87
-			}
78
+            if ($node->name === 'renameTable') {
79
+                $this->errors[] = [
80
+                    'line' => $node->getLine(),
81
+                    'disallowedToken' => 'Deprecated method',
82
+                    'reason' => sprintf(
83
+                        '`$%s->renameTable()` must not be used',
84
+                        $node->var->name
85
+                    ),
86
+                ];
87
+            }
88 88
 
89
-		/**
90
-		 * Check columns and Indexes
91
-		 */
92
-		} else if (!empty($this->tableVariableNames) &&
93
-			 $node instanceof Node\Expr\MethodCall &&
94
-			 $node->var instanceof Node\Expr\Variable &&
95
-			 isset($this->tableVariableNames[$node->var->name])) {
89
+        /**
90
+         * Check columns and Indexes
91
+         */
92
+        } else if (!empty($this->tableVariableNames) &&
93
+             $node instanceof Node\Expr\MethodCall &&
94
+             $node->var instanceof Node\Expr\Variable &&
95
+             isset($this->tableVariableNames[$node->var->name])) {
96 96
 
97
-			if ($node->name === 'addColumn' || $node->name === 'changeColumn') {
98
-				if (isset($node->args[0]) && $node->args[0]->value instanceof Node\Scalar\String_) {
99
-					if (!$this->checkNameLength($node->args[0]->value->value)) {
100
-						$this->errors[] = [
101
-							'line' => $node->getLine(),
102
-							'disallowedToken' => $node->args[0]->value->value,
103
-							'reason' => sprintf(
104
-								'Column name is too long on table `%s` (max. 27)',
105
-								$this->tableVariableNames[$node->var->name]
106
-							),
107
-						];
108
-					}
97
+            if ($node->name === 'addColumn' || $node->name === 'changeColumn') {
98
+                if (isset($node->args[0]) && $node->args[0]->value instanceof Node\Scalar\String_) {
99
+                    if (!$this->checkNameLength($node->args[0]->value->value)) {
100
+                        $this->errors[] = [
101
+                            'line' => $node->getLine(),
102
+                            'disallowedToken' => $node->args[0]->value->value,
103
+                            'reason' => sprintf(
104
+                                'Column name is too long on table `%s` (max. 27)',
105
+                                $this->tableVariableNames[$node->var->name]
106
+                            ),
107
+                        ];
108
+                    }
109 109
 
110
-					// On autoincrement the max length of the table name is 21 instead of 27
111
-					if (isset($node->args[2]) && $node->args[2]->value instanceof Node\Expr\Array_) {
112
-						/** @var Node\Expr\Array_ $options */
113
-						$options = $node->args[2]->value;
114
-						if ($this->checkColumnForAutoincrement($options)) {
115
-							if (!$this->checkNameLength($this->tableVariableNames[$node->var->name], true)) {
116
-								$this->errors[] = [
117
-									'line' => $node->getLine(),
118
-									'disallowedToken' => $this->tableVariableNames[$node->var->name],
119
-									'reason' => 'Table name is too long because of autoincrement (max. 21)',
120
-								];
121
-							}
122
-						}
123
-					}
124
-				}
125
-			} else if ($node->name === 'addIndex' ||
126
-				 $node->name === 'addUniqueIndex' ||
127
-				 $node->name === 'renameIndex' ||
128
-				 $node->name === 'setPrimaryKey') {
129
-				if (isset($node->args[1]) && $node->args[1]->value instanceof Node\Scalar\String_) {
130
-					if (!$this->checkNameLength($node->args[1]->value->value)) {
131
-						$this->errors[] = [
132
-							'line' => $node->getLine(),
133
-							'disallowedToken' => $node->args[1]->value->value,
134
-							'reason' => sprintf(
135
-								'Index name is too long on table `%s` (max. 27)',
136
-								$this->tableVariableNames[$node->var->name]
137
-							),
138
-						];
139
-					}
140
-				}
141
-			} else if ($node->name === 'addForeignKeyConstraint') {
142
-				if (isset($node->args[4]) && $node->args[4]->value instanceof Node\Scalar\String_) {
143
-					if (!$this->checkNameLength($node->args[4]->value->value)) {
144
-						$this->errors[] = [
145
-							'line' => $node->getLine(),
146
-							'disallowedToken' => $node->args[4]->value->value,
147
-							'reason' => sprintf(
148
-								'Constraint name is too long on table `%s` (max. 27)',
149
-								$this->tableVariableNames[$node->var->name]
150
-							),
151
-						];
152
-					}
153
-				}
154
-			} else if ($node->name === 'renameColumn') {
155
-				$this->errors[] = [
156
-					'line' => $node->getLine(),
157
-					'disallowedToken' => 'Deprecated method',
158
-					'reason' => sprintf(
159
-						'`$%s->renameColumn()` must not be used',
160
-						$node->var->name
161
-					),
162
-				];
163
-			}
110
+                    // On autoincrement the max length of the table name is 21 instead of 27
111
+                    if (isset($node->args[2]) && $node->args[2]->value instanceof Node\Expr\Array_) {
112
+                        /** @var Node\Expr\Array_ $options */
113
+                        $options = $node->args[2]->value;
114
+                        if ($this->checkColumnForAutoincrement($options)) {
115
+                            if (!$this->checkNameLength($this->tableVariableNames[$node->var->name], true)) {
116
+                                $this->errors[] = [
117
+                                    'line' => $node->getLine(),
118
+                                    'disallowedToken' => $this->tableVariableNames[$node->var->name],
119
+                                    'reason' => 'Table name is too long because of autoincrement (max. 21)',
120
+                                ];
121
+                            }
122
+                        }
123
+                    }
124
+                }
125
+            } else if ($node->name === 'addIndex' ||
126
+                 $node->name === 'addUniqueIndex' ||
127
+                 $node->name === 'renameIndex' ||
128
+                 $node->name === 'setPrimaryKey') {
129
+                if (isset($node->args[1]) && $node->args[1]->value instanceof Node\Scalar\String_) {
130
+                    if (!$this->checkNameLength($node->args[1]->value->value)) {
131
+                        $this->errors[] = [
132
+                            'line' => $node->getLine(),
133
+                            'disallowedToken' => $node->args[1]->value->value,
134
+                            'reason' => sprintf(
135
+                                'Index name is too long on table `%s` (max. 27)',
136
+                                $this->tableVariableNames[$node->var->name]
137
+                            ),
138
+                        ];
139
+                    }
140
+                }
141
+            } else if ($node->name === 'addForeignKeyConstraint') {
142
+                if (isset($node->args[4]) && $node->args[4]->value instanceof Node\Scalar\String_) {
143
+                    if (!$this->checkNameLength($node->args[4]->value->value)) {
144
+                        $this->errors[] = [
145
+                            'line' => $node->getLine(),
146
+                            'disallowedToken' => $node->args[4]->value->value,
147
+                            'reason' => sprintf(
148
+                                'Constraint name is too long on table `%s` (max. 27)',
149
+                                $this->tableVariableNames[$node->var->name]
150
+                            ),
151
+                        ];
152
+                    }
153
+                }
154
+            } else if ($node->name === 'renameColumn') {
155
+                $this->errors[] = [
156
+                    'line' => $node->getLine(),
157
+                    'disallowedToken' => 'Deprecated method',
158
+                    'reason' => sprintf(
159
+                        '`$%s->renameColumn()` must not be used',
160
+                        $node->var->name
161
+                    ),
162
+                ];
163
+            }
164 164
 
165
-		/**
166
-		 * Find the schema
167
-		 */
168
-		} else if ($node instanceof Node\Expr\Assign &&
169
-			 $node->expr instanceof Node\Expr\FuncCall &&
170
-			 $node->var instanceof Node\Expr\Variable &&
171
-			 $node->expr->name instanceof Node\Expr\Variable &&
172
-			 $node->expr->name->name === 'schemaClosure') {
173
-			// E.g. $schema = $schemaClosure();
174
-			$this->schemaVariableName = $node->var->name;
175
-		}
176
-	}
165
+        /**
166
+         * Find the schema
167
+         */
168
+        } else if ($node instanceof Node\Expr\Assign &&
169
+             $node->expr instanceof Node\Expr\FuncCall &&
170
+             $node->var instanceof Node\Expr\Variable &&
171
+             $node->expr->name instanceof Node\Expr\Variable &&
172
+             $node->expr->name->name === 'schemaClosure') {
173
+            // E.g. $schema = $schemaClosure();
174
+            $this->schemaVariableName = $node->var->name;
175
+        }
176
+    }
177 177
 
178
-	protected function checkNameLength($tableName, $hasAutoincrement = false) {
179
-		if ($hasAutoincrement) {
180
-			return strlen($tableName) <= 21;
181
-		}
182
-		return strlen($tableName) <= 27;
183
-	}
178
+    protected function checkNameLength($tableName, $hasAutoincrement = false) {
179
+        if ($hasAutoincrement) {
180
+            return strlen($tableName) <= 21;
181
+        }
182
+        return strlen($tableName) <= 27;
183
+    }
184 184
 
185
-	/**
186
-	 * @param Node\Expr\Array_ $optionsArray
187
-	 * @return bool Whether the column is an autoincrement column
188
-	 */
189
-	protected function checkColumnForAutoincrement(Node\Expr\Array_ $optionsArray) {
190
-		foreach ($optionsArray->items as $option) {
191
-			if ($option->key instanceof Node\Scalar\String_) {
192
-				if ($option->key->value === 'autoincrement' &&
193
-					 $option->value instanceof Node\Expr\ConstFetch) {
194
-					/** @var Node\Expr\ConstFetch $const */
195
-					$const = $option->value;
185
+    /**
186
+     * @param Node\Expr\Array_ $optionsArray
187
+     * @return bool Whether the column is an autoincrement column
188
+     */
189
+    protected function checkColumnForAutoincrement(Node\Expr\Array_ $optionsArray) {
190
+        foreach ($optionsArray->items as $option) {
191
+            if ($option->key instanceof Node\Scalar\String_) {
192
+                if ($option->key->value === 'autoincrement' &&
193
+                     $option->value instanceof Node\Expr\ConstFetch) {
194
+                    /** @var Node\Expr\ConstFetch $const */
195
+                    $const = $option->value;
196 196
 
197
-					if ($const->name instanceof Name &&
198
-						 $const->name->parts === ['true']) {
199
-						return true;
200
-					}
201
-				}
202
-			}
203
-		}
197
+                    if ($const->name instanceof Name &&
198
+                         $const->name->parts === ['true']) {
199
+                        return true;
200
+                    }
201
+                }
202
+            }
203
+        }
204 204
 
205
-		return false;
206
-	}
205
+        return false;
206
+    }
207 207
 }
Please login to merge, or discard this patch.
lib/private/OCS/Exception.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@
 block discarded – undo
25 25
 
26 26
 class Exception extends \Exception {
27 27
 
28
-	/** @var Result */
29
-	private $result;
28
+    /** @var Result */
29
+    private $result;
30 30
 
31
-	public function __construct(Result $result) {
32
-		parent::__construct();
33
-		$this->result = $result;
34
-	}
31
+    public function __construct(Result $result) {
32
+        parent::__construct();
33
+        $this->result = $result;
34
+    }
35 35
 
36
-	public function getResult() {
37
-		return $this->result;
38
-	}
36
+    public function getResult() {
37
+        return $this->result;
38
+    }
39 39
 
40 40
 }
Please login to merge, or discard this patch.
lib/private/BackgroundJob/TimedJob.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -32,26 +32,26 @@
 block discarded – undo
32 32
  * @package OC\BackgroundJob
33 33
  */
34 34
 abstract class TimedJob extends Job {
35
-	protected $interval = 0;
35
+    protected $interval = 0;
36 36
 
37
-	/**
38
-	 * set the interval for the job
39
-	 *
40
-	 * @param int $interval
41
-	 */
42
-	public function setInterval($interval) {
43
-		$this->interval = $interval;
44
-	}
37
+    /**
38
+     * set the interval for the job
39
+     *
40
+     * @param int $interval
41
+     */
42
+    public function setInterval($interval) {
43
+        $this->interval = $interval;
44
+    }
45 45
 
46
-	/**
47
-	 * run the job if
48
-	 *
49
-	 * @param JobList $jobList
50
-	 * @param ILogger|null $logger
51
-	 */
52
-	public function execute($jobList, ILogger $logger = null) {
53
-		if ((time() - $this->lastRun) > $this->interval) {
54
-			parent::execute($jobList, $logger);
55
-		}
56
-	}
46
+    /**
47
+     * run the job if
48
+     *
49
+     * @param JobList $jobList
50
+     * @param ILogger|null $logger
51
+     */
52
+    public function execute($jobList, ILogger $logger = null) {
53
+        if ((time() - $this->lastRun) > $this->interval) {
54
+            parent::execute($jobList, $logger);
55
+        }
56
+    }
57 57
 }
Please login to merge, or discard this patch.
lib/private/BackgroundJob/QueuedJob.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@
 block discarded – undo
32 32
  * @package OC\BackgroundJob
33 33
  */
34 34
 abstract class QueuedJob extends Job {
35
-	/**
36
-	 * run the job, then remove it from the joblist
37
-	 *
38
-	 * @param JobList $jobList
39
-	 * @param ILogger|null $logger
40
-	 */
41
-	public function execute($jobList, ILogger $logger = null) {
42
-		$jobList->remove($this, $this->argument);
43
-		parent::execute($jobList, $logger);
44
-	}
35
+    /**
36
+     * run the job, then remove it from the joblist
37
+     *
38
+     * @param JobList $jobList
39
+     * @param ILogger|null $logger
40
+     */
41
+    public function execute($jobList, ILogger $logger = null) {
42
+        $jobList->remove($this, $this->argument);
43
+        parent::execute($jobList, $logger);
44
+    }
45 45
 }
Please login to merge, or discard this patch.
lib/public/IDateTimeFormatter.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -30,114 +30,114 @@
 block discarded – undo
30 30
  * @since 8.0.0
31 31
  */
32 32
 interface IDateTimeFormatter {
33
-	/**
34
-	 * Formats the date of the given timestamp
35
-	 *
36
-	 * @param int|\DateTime		$timestamp
37
-	 * @param string	$format			Either 'full', 'long', 'medium' or 'short'
38
-	 * 				full:	e.g. 'EEEE, MMMM d, y'	=> 'Wednesday, August 20, 2014'
39
-	 * 				long:	e.g. 'MMMM d, y'		=> 'August 20, 2014'
40
-	 * 				medium:	e.g. 'MMM d, y'			=> 'Aug 20, 2014'
41
-	 * 				short:	e.g. 'M/d/yy'			=> '8/20/14'
42
-	 * 				The exact format is dependent on the language
43
-	 * @param \DateTimeZone|null	$timeZone	The timezone to use
44
-	 * @param \OCP\IL10N|null	$l			The locale to use
45
-	 * @return string Formatted date string
46
-	 * @since 8.0.0
47
-	 */
48
-	public function formatDate($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
33
+    /**
34
+     * Formats the date of the given timestamp
35
+     *
36
+     * @param int|\DateTime		$timestamp
37
+     * @param string	$format			Either 'full', 'long', 'medium' or 'short'
38
+     * 				full:	e.g. 'EEEE, MMMM d, y'	=> 'Wednesday, August 20, 2014'
39
+     * 				long:	e.g. 'MMMM d, y'		=> 'August 20, 2014'
40
+     * 				medium:	e.g. 'MMM d, y'			=> 'Aug 20, 2014'
41
+     * 				short:	e.g. 'M/d/yy'			=> '8/20/14'
42
+     * 				The exact format is dependent on the language
43
+     * @param \DateTimeZone|null	$timeZone	The timezone to use
44
+     * @param \OCP\IL10N|null	$l			The locale to use
45
+     * @return string Formatted date string
46
+     * @since 8.0.0
47
+     */
48
+    public function formatDate($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
49 49
 
50
-	/**
51
-	 * Formats the date of the given timestamp
52
-	 *
53
-	 * @param int|\DateTime		$timestamp
54
-	 * @param string	$format			Either 'full', 'long', 'medium' or 'short'
55
-	 * 				full:	e.g. 'EEEE, MMMM d, y'	=> 'Wednesday, August 20, 2014'
56
-	 * 				long:	e.g. 'MMMM d, y'		=> 'August 20, 2014'
57
-	 * 				medium:	e.g. 'MMM d, y'			=> 'Aug 20, 2014'
58
-	 * 				short:	e.g. 'M/d/yy'			=> '8/20/14'
59
-	 * 				The exact format is dependent on the language
60
-	 * 					Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable
61
-	 * @param \DateTimeZone|null	$timeZone	The timezone to use
62
-	 * @param \OCP\IL10N|null	$l			The locale to use
63
-	 * @return string Formatted relative date string
64
-	 * @since 8.0.0
65
-	 */
66
-	public function formatDateRelativeDay($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
50
+    /**
51
+     * Formats the date of the given timestamp
52
+     *
53
+     * @param int|\DateTime		$timestamp
54
+     * @param string	$format			Either 'full', 'long', 'medium' or 'short'
55
+     * 				full:	e.g. 'EEEE, MMMM d, y'	=> 'Wednesday, August 20, 2014'
56
+     * 				long:	e.g. 'MMMM d, y'		=> 'August 20, 2014'
57
+     * 				medium:	e.g. 'MMM d, y'			=> 'Aug 20, 2014'
58
+     * 				short:	e.g. 'M/d/yy'			=> '8/20/14'
59
+     * 				The exact format is dependent on the language
60
+     * 					Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable
61
+     * @param \DateTimeZone|null	$timeZone	The timezone to use
62
+     * @param \OCP\IL10N|null	$l			The locale to use
63
+     * @return string Formatted relative date string
64
+     * @since 8.0.0
65
+     */
66
+    public function formatDateRelativeDay($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
67 67
 
68
-	/**
69
-	 * Gives the relative date of the timestamp
70
-	 * Only works for past dates
71
-	 *
72
-	 * @param int|\DateTime	$timestamp
73
-	 * @param int|\DateTime|null	$baseTimestamp	Timestamp to compare $timestamp against, defaults to current time
74
-	 * @param \OCP\IL10N|null		$l			The locale to use
75
-	 * @return string	Dates returned are:
76
-	 * 				<  1 month	=> Today, Yesterday, n days ago
77
-	 * 				< 13 month	=> last month, n months ago
78
-	 * 				>= 13 month	=> last year, n years ago
79
-	 * @since 8.0.0
80
-	 */
81
-	public function formatDateSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null);
68
+    /**
69
+     * Gives the relative date of the timestamp
70
+     * Only works for past dates
71
+     *
72
+     * @param int|\DateTime	$timestamp
73
+     * @param int|\DateTime|null	$baseTimestamp	Timestamp to compare $timestamp against, defaults to current time
74
+     * @param \OCP\IL10N|null		$l			The locale to use
75
+     * @return string	Dates returned are:
76
+     * 				<  1 month	=> Today, Yesterday, n days ago
77
+     * 				< 13 month	=> last month, n months ago
78
+     * 				>= 13 month	=> last year, n years ago
79
+     * @since 8.0.0
80
+     */
81
+    public function formatDateSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null);
82 82
 
83
-	/**
84
-	 * Formats the time of the given timestamp
85
-	 *
86
-	 * @param int|\DateTime $timestamp
87
-	 * @param string	$format			Either 'full', 'long', 'medium' or 'short'
88
-	 * 				full:	e.g. 'h:mm:ss a zzzz'	=> '11:42:13 AM GMT+0:00'
89
-	 * 				long:	e.g. 'h:mm:ss a z'		=> '11:42:13 AM GMT'
90
-	 * 				medium:	e.g. 'h:mm:ss a'		=> '11:42:13 AM'
91
-	 * 				short:	e.g. 'h:mm a'			=> '11:42 AM'
92
-	 * 				The exact format is dependent on the language
93
-	 * @param \DateTimeZone|null	$timeZone	The timezone to use
94
-	 * @param \OCP\IL10N|null		$l			The locale to use
95
-	 * @return string Formatted time string
96
-	 * @since 8.0.0
97
-	 */
98
-	public function formatTime($timestamp, $format = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
83
+    /**
84
+     * Formats the time of the given timestamp
85
+     *
86
+     * @param int|\DateTime $timestamp
87
+     * @param string	$format			Either 'full', 'long', 'medium' or 'short'
88
+     * 				full:	e.g. 'h:mm:ss a zzzz'	=> '11:42:13 AM GMT+0:00'
89
+     * 				long:	e.g. 'h:mm:ss a z'		=> '11:42:13 AM GMT'
90
+     * 				medium:	e.g. 'h:mm:ss a'		=> '11:42:13 AM'
91
+     * 				short:	e.g. 'h:mm a'			=> '11:42 AM'
92
+     * 				The exact format is dependent on the language
93
+     * @param \DateTimeZone|null	$timeZone	The timezone to use
94
+     * @param \OCP\IL10N|null		$l			The locale to use
95
+     * @return string Formatted time string
96
+     * @since 8.0.0
97
+     */
98
+    public function formatTime($timestamp, $format = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
99 99
 
100
-	/**
101
-	 * Gives the relative past time of the timestamp
102
-	 *
103
-	 * @param int|\DateTime	$timestamp
104
-	 * @param int|\DateTime|null	$baseTimestamp	Timestamp to compare $timestamp against, defaults to current time
105
-	 * @param \OCP\IL10N|null		$l			The locale to use
106
-	 * @return string	Dates returned are:
107
-	 * 				< 60 sec	=> seconds ago
108
-	 * 				<  1 hour	=> n minutes ago
109
-	 * 				<  1 day	=> n hours ago
110
-	 * 				<  1 month	=> Yesterday, n days ago
111
-	 * 				< 13 month	=> last month, n months ago
112
-	 * 				>= 13 month	=> last year, n years ago
113
-	 * @since 8.0.0
114
-	 */
115
-	public function formatTimeSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null);
100
+    /**
101
+     * Gives the relative past time of the timestamp
102
+     *
103
+     * @param int|\DateTime	$timestamp
104
+     * @param int|\DateTime|null	$baseTimestamp	Timestamp to compare $timestamp against, defaults to current time
105
+     * @param \OCP\IL10N|null		$l			The locale to use
106
+     * @return string	Dates returned are:
107
+     * 				< 60 sec	=> seconds ago
108
+     * 				<  1 hour	=> n minutes ago
109
+     * 				<  1 day	=> n hours ago
110
+     * 				<  1 month	=> Yesterday, n days ago
111
+     * 				< 13 month	=> last month, n months ago
112
+     * 				>= 13 month	=> last year, n years ago
113
+     * @since 8.0.0
114
+     */
115
+    public function formatTimeSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null);
116 116
 
117
-	/**
118
-	 * Formats the date and time of the given timestamp
119
-	 *
120
-	 * @param int|\DateTime $timestamp
121
-	 * @param string	$formatDate		See formatDate() for description
122
-	 * @param string	$formatTime		See formatTime() for description
123
-	 * @param \DateTimeZone|null	$timeZone	The timezone to use
124
-	 * @param \OCP\IL10N|null		$l			The locale to use
125
-	 * @return string Formatted date and time string
126
-	 * @since 8.0.0
127
-	 */
128
-	public function formatDateTime($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
117
+    /**
118
+     * Formats the date and time of the given timestamp
119
+     *
120
+     * @param int|\DateTime $timestamp
121
+     * @param string	$formatDate		See formatDate() for description
122
+     * @param string	$formatTime		See formatTime() for description
123
+     * @param \DateTimeZone|null	$timeZone	The timezone to use
124
+     * @param \OCP\IL10N|null		$l			The locale to use
125
+     * @return string Formatted date and time string
126
+     * @since 8.0.0
127
+     */
128
+    public function formatDateTime($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
129 129
 
130
-	/**
131
-	 * Formats the date and time of the given timestamp
132
-	 *
133
-	 * @param int|\DateTime $timestamp
134
-	 * @param string	$formatDate		See formatDate() for description
135
-	 * 					Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable
136
-	 * @param string	$formatTime		See formatTime() for description
137
-	 * @param \DateTimeZone|null	$timeZone	The timezone to use
138
-	 * @param \OCP\IL10N|null		$l			The locale to use
139
-	 * @return string Formatted relative date and time string
140
-	 * @since 8.0.0
141
-	 */
142
-	public function formatDateTimeRelativeDay($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
130
+    /**
131
+     * Formats the date and time of the given timestamp
132
+     *
133
+     * @param int|\DateTime $timestamp
134
+     * @param string	$formatDate		See formatDate() for description
135
+     * 					Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable
136
+     * @param string	$formatTime		See formatTime() for description
137
+     * @param \DateTimeZone|null	$timeZone	The timezone to use
138
+     * @param \OCP\IL10N|null		$l			The locale to use
139
+     * @return string Formatted relative date and time string
140
+     * @since 8.0.0
141
+     */
142
+    public function formatDateTimeRelativeDay($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null);
143 143
 }
Please login to merge, or discard this patch.
lib/public/Search/PagedProvider.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -30,39 +30,39 @@
 block discarded – undo
30 30
  */
31 31
 abstract class PagedProvider extends Provider {
32 32
 
33
-	/**
34
-	 * show all results
35
-	 * @since 8.0.0
36
-	 */
37
-	const SIZE_ALL = 0;
33
+    /**
34
+     * show all results
35
+     * @since 8.0.0
36
+     */
37
+    const SIZE_ALL = 0;
38 38
 
39
-	/**
40
-	 * Constructor
41
-	 * @param array $options
42
-	 * @since 8.0.0
43
-	 */
44
-	public function __construct($options) {
45
-		parent::__construct($options);
46
-	}
39
+    /**
40
+     * Constructor
41
+     * @param array $options
42
+     * @since 8.0.0
43
+     */
44
+    public function __construct($options) {
45
+        parent::__construct($options);
46
+    }
47 47
 
48
-	/**
49
-	 * Search for $query
50
-	 * @param string $query
51
-	 * @return array An array of OCP\Search\Result's
52
-	 * @since 8.0.0
53
-	 */
54
-	public function search($query) {
55
-		// old apps might assume they get all results, so we use SIZE_ALL
56
-		return $this->searchPaged($query, 1, self::SIZE_ALL);
57
-	}
48
+    /**
49
+     * Search for $query
50
+     * @param string $query
51
+     * @return array An array of OCP\Search\Result's
52
+     * @since 8.0.0
53
+     */
54
+    public function search($query) {
55
+        // old apps might assume they get all results, so we use SIZE_ALL
56
+        return $this->searchPaged($query, 1, self::SIZE_ALL);
57
+    }
58 58
 
59
-	/**
60
-	 * Search for $query
61
-	 * @param string $query
62
-	 * @param int $page pages start at page 1
63
-	 * @param int $size 0 = SIZE_ALL
64
-	 * @return array An array of OCP\Search\Result's
65
-	 * @since 8.0.0
66
-	 */
67
-	abstract public function searchPaged($query, $page, $size);
59
+    /**
60
+     * Search for $query
61
+     * @param string $query
62
+     * @param int $page pages start at page 1
63
+     * @param int $size 0 = SIZE_ALL
64
+     * @return array An array of OCP\Search\Result's
65
+     * @since 8.0.0
66
+     */
67
+    abstract public function searchPaged($query, $page, $size);
68 68
 }
Please login to merge, or discard this patch.
lib/public/Share/Exceptions/GenericShareException.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -31,18 +31,18 @@
 block discarded – undo
31 31
  */
32 32
 class GenericShareException extends HintException {
33 33
 
34
-	/**
35
-	 * @param string $message
36
-	 * @param string $hint
37
-	 * @param int $code
38
-	 * @param \Exception|null $previous
39
-	 * @since 9.0.0
40
-	 */
41
-	public function __construct($message = '', $hint = '', $code = 0, \Exception $previous = null) {
42
-		if (empty($message)) {
43
-			$message = 'There was an error retrieving the share. Maybe the link is wrong, it was unshared, or it was deleted.';
44
-		}
45
-		parent::__construct($message, $hint, $code, $previous);
46
-	}
34
+    /**
35
+     * @param string $message
36
+     * @param string $hint
37
+     * @param int $code
38
+     * @param \Exception|null $previous
39
+     * @since 9.0.0
40
+     */
41
+    public function __construct($message = '', $hint = '', $code = 0, \Exception $previous = null) {
42
+        if (empty($message)) {
43
+            $message = 'There was an error retrieving the share. Maybe the link is wrong, it was unshared, or it was deleted.';
44
+        }
45
+        parent::__construct($message, $hint, $code, $previous);
46
+    }
47 47
 
48 48
 }
Please login to merge, or discard this patch.