Code Duplication    Length = 34-35 lines in 2 locations

apps/dav/lib/Connector/Sabre/CustomPropertiesBackend.php 1 location

@@ 206-240 (lines=35) @@
203
	 * http://www.example.org/namespace#author If the array is empty, all
204
	 * properties should be returned
205
	 */
206
	private function getProperties(Node $node, array $requestedProperties) {
207
		$path = $node->getPath();
208
		if (isset($this->cache[$path])) {
209
			return $this->cache[$path];
210
		}
211
212
		// TODO: chunking if more than 1000 properties
213
		$sql = 'SELECT * FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ?';
214
215
		$whereValues = array($this->user, $path);
216
		$whereTypes = array(null, null);
217
218
		if (!empty($requestedProperties)) {
219
			// request only a subset
220
			$sql .= ' AND `propertyname` in (?)';
221
			$whereValues[] = $requestedProperties;
222
			$whereTypes[] = \Doctrine\DBAL\Connection::PARAM_STR_ARRAY;
223
		}
224
225
		$result = $this->connection->executeQuery(
226
			$sql,
227
			$whereValues,
228
			$whereTypes
229
		);
230
231
		$props = [];
232
		while ($row = $result->fetch()) {
233
			$props[$row['propertyname']] = $row['propertyvalue'];
234
		}
235
236
		$result->closeCursor();
237
238
		$this->cache[$path] = $props;
239
		return $props;
240
	}
241
242
	/**
243
	 * Update properties

apps/dav/lib/DAV/CustomPropertiesBackend.php 1 location

@@ 193-226 (lines=34) @@
190
	 * http://www.example.org/namespace#author If the array is empty, all
191
	 * properties should be returned
192
	 */
193
	private function getProperties($path, array $requestedProperties) {
194
		if (isset($this->cache[$path])) {
195
			return $this->cache[$path];
196
		}
197
198
		// TODO: chunking if more than 1000 properties
199
		$sql = 'SELECT * FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ?';
200
201
		$whereValues = array($this->user, $path);
202
		$whereTypes = array(null, null);
203
204
		if (!empty($requestedProperties)) {
205
			// request only a subset
206
			$sql .= ' AND `propertyname` in (?)';
207
			$whereValues[] = $requestedProperties;
208
			$whereTypes[] = \Doctrine\DBAL\Connection::PARAM_STR_ARRAY;
209
		}
210
211
		$result = $this->connection->executeQuery(
212
			$sql,
213
			$whereValues,
214
			$whereTypes
215
		);
216
217
		$props = [];
218
		while ($row = $result->fetch()) {
219
			$props[$row['propertyname']] = $row['propertyvalue'];
220
		}
221
222
		$result->closeCursor();
223
224
		$this->cache[$path] = $props;
225
		return $props;
226
	}
227
228
	/**
229
	 * Update properties