Passed
Push — master ( 5fb7ea...32bbe3 )
by John
18:30 queued 13s
created
lib/private/DB/QueryBuilder/Literal.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@
 block discarded – undo
25 25
 use OCP\DB\QueryBuilder\ILiteral;
26 26
 
27 27
 class Literal implements ILiteral {
28
-	/** @var mixed */
29
-	protected $literal;
28
+    /** @var mixed */
29
+    protected $literal;
30 30
 
31
-	public function __construct($literal) {
32
-		$this->literal = $literal;
33
-	}
31
+    public function __construct($literal) {
32
+        $this->literal = $literal;
33
+    }
34 34
 
35
-	/**
36
-	 * @return string
37
-	 */
38
-	public function __toString() {
39
-		return (string) $this->literal;
40
-	}
35
+    /**
36
+     * @return string
37
+     */
38
+    public function __toString() {
39
+        return (string) $this->literal;
40
+    }
41 41
 }
Please login to merge, or discard this patch.
lib/private/DB/AdapterSqlite.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,14 +64,14 @@
 block discarded – undo
64 64
 		if (empty($compare)) {
65 65
 			$compare = array_keys($input);
66 66
 		}
67
-		$fieldList = '`' . implode('`,`', array_keys($input)) . '`';
67
+		$fieldList = '`'.implode('`,`', array_keys($input)).'`';
68 68
 		$query = "INSERT INTO `$table` ($fieldList) SELECT "
69 69
 			. str_repeat('?,', count($input) - 1).'? '
70 70
 			. " WHERE NOT EXISTS (SELECT 1 FROM `$table` WHERE ";
71 71
 
72 72
 		$inserts = array_values($input);
73 73
 		foreach ($compare as $key) {
74
-			$query .= '`' . $key . '`';
74
+			$query .= '`'.$key.'`';
75 75
 			if (is_null($input[$key])) {
76 76
 				$query .= ' IS NULL AND ';
77 77
 			} else {
Please login to merge, or discard this patch.
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -29,70 +29,70 @@
 block discarded – undo
29 29
 use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
30 30
 
31 31
 class AdapterSqlite extends Adapter {
32
-	/**
33
-	 * @param string $tableName
34
-	 */
35
-	public function lockTable($tableName) {
36
-		$this->conn->executeUpdate('BEGIN EXCLUSIVE TRANSACTION');
37
-	}
32
+    /**
33
+     * @param string $tableName
34
+     */
35
+    public function lockTable($tableName) {
36
+        $this->conn->executeUpdate('BEGIN EXCLUSIVE TRANSACTION');
37
+    }
38 38
 
39
-	public function unlockTable() {
40
-		$this->conn->executeUpdate('COMMIT TRANSACTION');
41
-	}
39
+    public function unlockTable() {
40
+        $this->conn->executeUpdate('COMMIT TRANSACTION');
41
+    }
42 42
 
43
-	public function fixupStatement($statement) {
44
-		$statement = preg_replace('/`(\w+)` ILIKE \?/', 'LOWER($1) LIKE LOWER(?)', $statement);
45
-		$statement = str_replace('`', '"', $statement);
46
-		$statement = str_ireplace('NOW()', 'datetime(\'now\')', $statement);
47
-		$statement = str_ireplace('GREATEST(', 'MAX(', $statement);
48
-		$statement = str_ireplace('UNIX_TIMESTAMP()', 'strftime(\'%s\',\'now\')', $statement);
49
-		return $statement;
50
-	}
43
+    public function fixupStatement($statement) {
44
+        $statement = preg_replace('/`(\w+)` ILIKE \?/', 'LOWER($1) LIKE LOWER(?)', $statement);
45
+        $statement = str_replace('`', '"', $statement);
46
+        $statement = str_ireplace('NOW()', 'datetime(\'now\')', $statement);
47
+        $statement = str_ireplace('GREATEST(', 'MAX(', $statement);
48
+        $statement = str_ireplace('UNIX_TIMESTAMP()', 'strftime(\'%s\',\'now\')', $statement);
49
+        return $statement;
50
+    }
51 51
 
52
-	/**
53
-	 * Insert a row if the matching row does not exists. To accomplish proper race condition avoidance
54
-	 * it is needed that there is also a unique constraint on the values. Then this method will
55
-	 * catch the exception and return 0.
56
-	 *
57
-	 * @param string $table The table name (will replace *PREFIX* with the actual prefix)
58
-	 * @param array $input data that should be inserted into the table  (column name => value)
59
-	 * @param array|null $compare List of values that should be checked for "if not exists"
60
-	 *				If this is null or an empty array, all keys of $input will be compared
61
-	 *				Please note: text fields (clob) must not be used in the compare array
62
-	 * @return int number of inserted rows
63
-	 * @throws \Doctrine\DBAL\Exception
64
-	 * @deprecated 15.0.0 - use unique index and "try { $db->insert() } catch (UniqueConstraintViolationException $e) {}" instead, because it is more reliable and does not have the risk for deadlocks - see https://github.com/nextcloud/server/pull/12371
65
-	 */
66
-	public function insertIfNotExist($table, $input, array $compare = null) {
67
-		if (empty($compare)) {
68
-			$compare = array_keys($input);
69
-		}
70
-		$fieldList = '`' . implode('`,`', array_keys($input)) . '`';
71
-		$query = "INSERT INTO `$table` ($fieldList) SELECT "
72
-			. str_repeat('?,', count($input) - 1).'? '
73
-			. " WHERE NOT EXISTS (SELECT 1 FROM `$table` WHERE ";
52
+    /**
53
+     * Insert a row if the matching row does not exists. To accomplish proper race condition avoidance
54
+     * it is needed that there is also a unique constraint on the values. Then this method will
55
+     * catch the exception and return 0.
56
+     *
57
+     * @param string $table The table name (will replace *PREFIX* with the actual prefix)
58
+     * @param array $input data that should be inserted into the table  (column name => value)
59
+     * @param array|null $compare List of values that should be checked for "if not exists"
60
+     *				If this is null or an empty array, all keys of $input will be compared
61
+     *				Please note: text fields (clob) must not be used in the compare array
62
+     * @return int number of inserted rows
63
+     * @throws \Doctrine\DBAL\Exception
64
+     * @deprecated 15.0.0 - use unique index and "try { $db->insert() } catch (UniqueConstraintViolationException $e) {}" instead, because it is more reliable and does not have the risk for deadlocks - see https://github.com/nextcloud/server/pull/12371
65
+     */
66
+    public function insertIfNotExist($table, $input, array $compare = null) {
67
+        if (empty($compare)) {
68
+            $compare = array_keys($input);
69
+        }
70
+        $fieldList = '`' . implode('`,`', array_keys($input)) . '`';
71
+        $query = "INSERT INTO `$table` ($fieldList) SELECT "
72
+            . str_repeat('?,', count($input) - 1).'? '
73
+            . " WHERE NOT EXISTS (SELECT 1 FROM `$table` WHERE ";
74 74
 
75
-		$inserts = array_values($input);
76
-		foreach ($compare as $key) {
77
-			$query .= '`' . $key . '`';
78
-			if (is_null($input[$key])) {
79
-				$query .= ' IS NULL AND ';
80
-			} else {
81
-				$inserts[] = $input[$key];
82
-				$query .= ' = ? AND ';
83
-			}
84
-		}
85
-		$query = substr($query, 0, -5);
86
-		$query .= ')';
75
+        $inserts = array_values($input);
76
+        foreach ($compare as $key) {
77
+            $query .= '`' . $key . '`';
78
+            if (is_null($input[$key])) {
79
+                $query .= ' IS NULL AND ';
80
+            } else {
81
+                $inserts[] = $input[$key];
82
+                $query .= ' = ? AND ';
83
+            }
84
+        }
85
+        $query = substr($query, 0, -5);
86
+        $query .= ')';
87 87
 
88
-		try {
89
-			return $this->conn->executeUpdate($query, $inserts);
90
-		} catch (UniqueConstraintViolationException $e) {
91
-			// if this is thrown then a concurrent insert happened between the insert and the sub-select in the insert, that should have avoided it
92
-			// it's fine to ignore this then
93
-			//
94
-			// more discussions about this can be found at https://github.com/nextcloud/server/pull/12315
95
-			return 0;
96
-		}
97
-	}
88
+        try {
89
+            return $this->conn->executeUpdate($query, $inserts);
90
+        } catch (UniqueConstraintViolationException $e) {
91
+            // if this is thrown then a concurrent insert happened between the insert and the sub-select in the insert, that should have avoided it
92
+            // it's fine to ignore this then
93
+            //
94
+            // more discussions about this can be found at https://github.com/nextcloud/server/pull/12315
95
+            return 0;
96
+        }
97
+    }
98 98
 }
Please login to merge, or discard this patch.
lib/private/DB/Adapter.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function lockTable($tableName) {
68 68
 		$this->conn->beginTransaction();
69
-		$this->conn->executeUpdate('LOCK TABLE `' .$tableName . '` IN EXCLUSIVE MODE');
69
+		$this->conn->executeUpdate('LOCK TABLE `'.$tableName.'` IN EXCLUSIVE MODE');
70 70
 	}
71 71
 
72 72
 	/**
@@ -93,14 +93,14 @@  discard block
 block discarded – undo
93 93
 		if (empty($compare)) {
94 94
 			$compare = array_keys($input);
95 95
 		}
96
-		$query = 'INSERT INTO `' .$table . '` (`'
97
-			. implode('`,`', array_keys($input)) . '`) SELECT '
96
+		$query = 'INSERT INTO `'.$table.'` (`'
97
+			. implode('`,`', array_keys($input)).'`) SELECT '
98 98
 			. str_repeat('?,', count($input) - 1).'? ' // Is there a prettier alternative?
99
-			. 'FROM `' . $table . '` WHERE ';
99
+			. 'FROM `'.$table.'` WHERE ';
100 100
 
101 101
 		$inserts = array_values($input);
102 102
 		foreach ($compare as $key) {
103
-			$query .= '`' . $key . '`';
103
+			$query .= '`'.$key.'`';
104 104
 			if (is_null($input[$key])) {
105 105
 				$query .= ' IS NULL AND ';
106 106
 			} else {
Please login to merge, or discard this patch.
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -36,115 +36,115 @@
 block discarded – undo
36 36
  * handled by the database abstraction layer.
37 37
  */
38 38
 class Adapter {
39
-	/**
40
-	 * @var \OC\DB\Connection $conn
41
-	 */
42
-	protected $conn;
39
+    /**
40
+     * @var \OC\DB\Connection $conn
41
+     */
42
+    protected $conn;
43 43
 
44
-	public function __construct($conn) {
45
-		$this->conn = $conn;
46
-	}
44
+    public function __construct($conn) {
45
+        $this->conn = $conn;
46
+    }
47 47
 
48
-	/**
49
-	 * @param string $table name
50
-	 *
51
-	 * @return int id of last insert statement
52
-	 * @throws Exception
53
-	 */
54
-	public function lastInsertId($table) {
55
-		return (int) $this->conn->realLastInsertId($table);
56
-	}
48
+    /**
49
+     * @param string $table name
50
+     *
51
+     * @return int id of last insert statement
52
+     * @throws Exception
53
+     */
54
+    public function lastInsertId($table) {
55
+        return (int) $this->conn->realLastInsertId($table);
56
+    }
57 57
 
58
-	/**
59
-	 * @param string $statement that needs to be changed so the db can handle it
60
-	 * @return string changed statement
61
-	 */
62
-	public function fixupStatement($statement) {
63
-		return $statement;
64
-	}
58
+    /**
59
+     * @param string $statement that needs to be changed so the db can handle it
60
+     * @return string changed statement
61
+     */
62
+    public function fixupStatement($statement) {
63
+        return $statement;
64
+    }
65 65
 
66
-	/**
67
-	 * Create an exclusive read+write lock on a table
68
-	 *
69
-	 * @param string $tableName
70
-	 * @throws Exception
71
-	 * @since 9.1.0
72
-	 */
73
-	public function lockTable($tableName) {
74
-		$this->conn->beginTransaction();
75
-		$this->conn->executeUpdate('LOCK TABLE `' .$tableName . '` IN EXCLUSIVE MODE');
76
-	}
66
+    /**
67
+     * Create an exclusive read+write lock on a table
68
+     *
69
+     * @param string $tableName
70
+     * @throws Exception
71
+     * @since 9.1.0
72
+     */
73
+    public function lockTable($tableName) {
74
+        $this->conn->beginTransaction();
75
+        $this->conn->executeUpdate('LOCK TABLE `' .$tableName . '` IN EXCLUSIVE MODE');
76
+    }
77 77
 
78
-	/**
79
-	 * Release a previous acquired lock again
80
-	 *
81
-	 * @throws Exception
82
-	 * @since 9.1.0
83
-	 */
84
-	public function unlockTable() {
85
-		$this->conn->commit();
86
-	}
78
+    /**
79
+     * Release a previous acquired lock again
80
+     *
81
+     * @throws Exception
82
+     * @since 9.1.0
83
+     */
84
+    public function unlockTable() {
85
+        $this->conn->commit();
86
+    }
87 87
 
88
-	/**
89
-	 * Insert a row if the matching row does not exists. To accomplish proper race condition avoidance
90
-	 * it is needed that there is also a unique constraint on the values. Then this method will
91
-	 * catch the exception and return 0.
92
-	 *
93
-	 * @param string $table The table name (will replace *PREFIX* with the actual prefix)
94
-	 * @param array $input data that should be inserted into the table  (column name => value)
95
-	 * @param array|null $compare List of values that should be checked for "if not exists"
96
-	 *				If this is null or an empty array, all keys of $input will be compared
97
-	 *				Please note: text fields (clob) must not be used in the compare array
98
-	 * @return int number of inserted rows
99
-	 * @throws Exception
100
-	 * @deprecated 15.0.0 - use unique index and "try { $db->insert() } catch (UniqueConstraintViolationException $e) {}" instead, because it is more reliable and does not have the risk for deadlocks - see https://github.com/nextcloud/server/pull/12371
101
-	 */
102
-	public function insertIfNotExist($table, $input, array $compare = null) {
103
-		if (empty($compare)) {
104
-			$compare = array_keys($input);
105
-		}
106
-		$query = 'INSERT INTO `' .$table . '` (`'
107
-			. implode('`,`', array_keys($input)) . '`) SELECT '
108
-			. str_repeat('?,', count($input) - 1).'? ' // Is there a prettier alternative?
109
-			. 'FROM `' . $table . '` WHERE ';
88
+    /**
89
+     * Insert a row if the matching row does not exists. To accomplish proper race condition avoidance
90
+     * it is needed that there is also a unique constraint on the values. Then this method will
91
+     * catch the exception and return 0.
92
+     *
93
+     * @param string $table The table name (will replace *PREFIX* with the actual prefix)
94
+     * @param array $input data that should be inserted into the table  (column name => value)
95
+     * @param array|null $compare List of values that should be checked for "if not exists"
96
+     *				If this is null or an empty array, all keys of $input will be compared
97
+     *				Please note: text fields (clob) must not be used in the compare array
98
+     * @return int number of inserted rows
99
+     * @throws Exception
100
+     * @deprecated 15.0.0 - use unique index and "try { $db->insert() } catch (UniqueConstraintViolationException $e) {}" instead, because it is more reliable and does not have the risk for deadlocks - see https://github.com/nextcloud/server/pull/12371
101
+     */
102
+    public function insertIfNotExist($table, $input, array $compare = null) {
103
+        if (empty($compare)) {
104
+            $compare = array_keys($input);
105
+        }
106
+        $query = 'INSERT INTO `' .$table . '` (`'
107
+            . implode('`,`', array_keys($input)) . '`) SELECT '
108
+            . str_repeat('?,', count($input) - 1).'? ' // Is there a prettier alternative?
109
+            . 'FROM `' . $table . '` WHERE ';
110 110
 
111
-		$inserts = array_values($input);
112
-		foreach ($compare as $key) {
113
-			$query .= '`' . $key . '`';
114
-			if (is_null($input[$key])) {
115
-				$query .= ' IS NULL AND ';
116
-			} else {
117
-				$inserts[] = $input[$key];
118
-				$query .= ' = ? AND ';
119
-			}
120
-		}
121
-		$query = substr($query, 0, -5);
122
-		$query .= ' HAVING COUNT(*) = 0';
111
+        $inserts = array_values($input);
112
+        foreach ($compare as $key) {
113
+            $query .= '`' . $key . '`';
114
+            if (is_null($input[$key])) {
115
+                $query .= ' IS NULL AND ';
116
+            } else {
117
+                $inserts[] = $input[$key];
118
+                $query .= ' = ? AND ';
119
+            }
120
+        }
121
+        $query = substr($query, 0, -5);
122
+        $query .= ' HAVING COUNT(*) = 0';
123 123
 
124
-		try {
125
-			return $this->conn->executeUpdate($query, $inserts);
126
-		} catch (UniqueConstraintViolationException $e) {
127
-			// if this is thrown then a concurrent insert happened between the insert and the sub-select in the insert, that should have avoided it
128
-			// it's fine to ignore this then
129
-			//
130
-			// more discussions about this can be found at https://github.com/nextcloud/server/pull/12315
131
-			return 0;
132
-		}
133
-	}
124
+        try {
125
+            return $this->conn->executeUpdate($query, $inserts);
126
+        } catch (UniqueConstraintViolationException $e) {
127
+            // if this is thrown then a concurrent insert happened between the insert and the sub-select in the insert, that should have avoided it
128
+            // it's fine to ignore this then
129
+            //
130
+            // more discussions about this can be found at https://github.com/nextcloud/server/pull/12315
131
+            return 0;
132
+        }
133
+    }
134 134
 
135
-	/**
136
-	 * @throws \OCP\DB\Exception
137
-	 */
138
-	public function insertIgnoreConflict(string $table, array $values) : int {
139
-		try {
140
-			$builder = $this->conn->getQueryBuilder();
141
-			$builder->insert($table);
142
-			foreach ($values as $key => $value) {
143
-				$builder->setValue($key, $builder->createNamedParameter($value));
144
-			}
145
-			return $builder->execute();
146
-		} catch (UniqueConstraintViolationException $e) {
147
-			return 0;
148
-		}
149
-	}
135
+    /**
136
+     * @throws \OCP\DB\Exception
137
+     */
138
+    public function insertIgnoreConflict(string $table, array $values) : int {
139
+        try {
140
+            $builder = $this->conn->getQueryBuilder();
141
+            $builder->insert($table);
142
+            foreach ($values as $key => $value) {
143
+                $builder->setValue($key, $builder->createNamedParameter($value));
144
+            }
145
+            return $builder->execute();
146
+        } catch (UniqueConstraintViolationException $e) {
147
+            return 0;
148
+        }
149
+    }
150 150
 }
Please login to merge, or discard this patch.
lib/private/DB/OracleConnection.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 * @param string $table table name without the prefix
83 83
 	 */
84 84
 	public function dropTable($table) {
85
-		$table = $this->tablePrefix . trim($table);
85
+		$table = $this->tablePrefix.trim($table);
86 86
 		$table = $this->quoteIdentifier($table);
87 87
 		$schema = $this->getSchemaManager();
88 88
 		if ($schema->tablesExist([$table])) {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @return bool
98 98
 	 */
99 99
 	public function tableExists($table) {
100
-		$table = $this->tablePrefix . trim($table);
100
+		$table = $this->tablePrefix.trim($table);
101 101
 		$table = $this->quoteIdentifier($table);
102 102
 		$schema = $this->getSchemaManager();
103 103
 		return $schema->tablesExist([$table]);
Please login to merge, or discard this patch.
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -28,80 +28,80 @@
 block discarded – undo
28 28
 namespace OC\DB;
29 29
 
30 30
 class OracleConnection extends Connection {
31
-	/**
32
-	 * Quote the keys of the array
33
-	 */
34
-	private function quoteKeys(array $data) {
35
-		$return = [];
36
-		$c = $this->getDatabasePlatform()->getIdentifierQuoteCharacter();
37
-		foreach ($data as $key => $value) {
38
-			if ($key[0] !== $c) {
39
-				$return[$this->quoteIdentifier($key)] = $value;
40
-			} else {
41
-				$return[$key] = $value;
42
-			}
43
-		}
44
-		return $return;
45
-	}
31
+    /**
32
+     * Quote the keys of the array
33
+     */
34
+    private function quoteKeys(array $data) {
35
+        $return = [];
36
+        $c = $this->getDatabasePlatform()->getIdentifierQuoteCharacter();
37
+        foreach ($data as $key => $value) {
38
+            if ($key[0] !== $c) {
39
+                $return[$this->quoteIdentifier($key)] = $value;
40
+            } else {
41
+                $return[$key] = $value;
42
+            }
43
+        }
44
+        return $return;
45
+    }
46 46
 
47
-	/**
48
-	 * {@inheritDoc}
49
-	 */
50
-	public function insert($table, array $data, array $types = []) {
51
-		if ($table[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) {
52
-			$table = $this->quoteIdentifier($table);
53
-		}
54
-		$data = $this->quoteKeys($data);
55
-		return parent::insert($table, $data, $types);
56
-	}
47
+    /**
48
+     * {@inheritDoc}
49
+     */
50
+    public function insert($table, array $data, array $types = []) {
51
+        if ($table[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) {
52
+            $table = $this->quoteIdentifier($table);
53
+        }
54
+        $data = $this->quoteKeys($data);
55
+        return parent::insert($table, $data, $types);
56
+    }
57 57
 
58
-	/**
59
-	 * {@inheritDoc}
60
-	 */
61
-	public function update($table, array $data, array $criteria, array $types = []) {
62
-		if ($table[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) {
63
-			$table = $this->quoteIdentifier($table);
64
-		}
65
-		$data = $this->quoteKeys($data);
66
-		$criteria = $this->quoteKeys($criteria);
67
-		return parent::update($table, $data, $criteria, $types);
68
-	}
58
+    /**
59
+     * {@inheritDoc}
60
+     */
61
+    public function update($table, array $data, array $criteria, array $types = []) {
62
+        if ($table[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) {
63
+            $table = $this->quoteIdentifier($table);
64
+        }
65
+        $data = $this->quoteKeys($data);
66
+        $criteria = $this->quoteKeys($criteria);
67
+        return parent::update($table, $data, $criteria, $types);
68
+    }
69 69
 
70
-	/**
71
-	 * {@inheritDoc}
72
-	 */
73
-	public function delete($table, array $criteria, array $types = []) {
74
-		if ($table[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) {
75
-			$table = $this->quoteIdentifier($table);
76
-		}
77
-		$criteria = $this->quoteKeys($criteria);
78
-		return parent::delete($table, $criteria);
79
-	}
70
+    /**
71
+     * {@inheritDoc}
72
+     */
73
+    public function delete($table, array $criteria, array $types = []) {
74
+        if ($table[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) {
75
+            $table = $this->quoteIdentifier($table);
76
+        }
77
+        $criteria = $this->quoteKeys($criteria);
78
+        return parent::delete($table, $criteria);
79
+    }
80 80
 
81
-	/**
82
-	 * Drop a table from the database if it exists
83
-	 *
84
-	 * @param string $table table name without the prefix
85
-	 */
86
-	public function dropTable($table) {
87
-		$table = $this->tablePrefix . trim($table);
88
-		$table = $this->quoteIdentifier($table);
89
-		$schema = $this->getSchemaManager();
90
-		if ($schema->tablesExist([$table])) {
91
-			$schema->dropTable($table);
92
-		}
93
-	}
81
+    /**
82
+     * Drop a table from the database if it exists
83
+     *
84
+     * @param string $table table name without the prefix
85
+     */
86
+    public function dropTable($table) {
87
+        $table = $this->tablePrefix . trim($table);
88
+        $table = $this->quoteIdentifier($table);
89
+        $schema = $this->getSchemaManager();
90
+        if ($schema->tablesExist([$table])) {
91
+            $schema->dropTable($table);
92
+        }
93
+    }
94 94
 
95
-	/**
96
-	 * Check if a table exists
97
-	 *
98
-	 * @param string $table table name without the prefix
99
-	 * @return bool
100
-	 */
101
-	public function tableExists($table) {
102
-		$table = $this->tablePrefix . trim($table);
103
-		$table = $this->quoteIdentifier($table);
104
-		$schema = $this->getSchemaManager();
105
-		return $schema->tablesExist([$table]);
106
-	}
95
+    /**
96
+     * Check if a table exists
97
+     *
98
+     * @param string $table table name without the prefix
99
+     * @return bool
100
+     */
101
+    public function tableExists($table) {
102
+        $table = $this->tablePrefix . trim($table);
103
+        $table = $this->quoteIdentifier($table);
104
+        $schema = $this->getSchemaManager();
105
+        return $schema->tablesExist([$table]);
106
+    }
107 107
 }
Please login to merge, or discard this patch.
lib/private/Command/FileAccess.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@
 block discarded – undo
25 25
 use OCP\IUser;
26 26
 
27 27
 trait FileAccess {
28
-	protected function setupFS(IUser $user) {
29
-		\OC_Util::setupFS($user->getUID());
30
-	}
28
+    protected function setupFS(IUser $user) {
29
+        \OC_Util::setupFS($user->getUID());
30
+    }
31 31
 
32
-	protected function getUserFolder(IUser $user) {
33
-		$this->setupFS($user);
34
-		return \OC::$server->getUserFolder($user->getUID());
35
-	}
32
+    protected function getUserFolder(IUser $user) {
33
+        $this->setupFS($user);
34
+        return \OC::$server->getUserFolder($user->getUID());
35
+    }
36 36
 }
Please login to merge, or discard this patch.
lib/private/Memcache/APCu.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	use CADTrait;
38 38
 
39 39
 	public function get($key) {
40
-		$result = apcu_fetch($this->getPrefix() . $key, $success);
40
+		$result = apcu_fetch($this->getPrefix().$key, $success);
41 41
 		if (!$success) {
42 42
 			return null;
43 43
 		}
@@ -45,24 +45,24 @@  discard block
 block discarded – undo
45 45
 	}
46 46
 
47 47
 	public function set($key, $value, $ttl = 0) {
48
-		return apcu_store($this->getPrefix() . $key, $value, $ttl);
48
+		return apcu_store($this->getPrefix().$key, $value, $ttl);
49 49
 	}
50 50
 
51 51
 	public function hasKey($key) {
52
-		return apcu_exists($this->getPrefix() . $key);
52
+		return apcu_exists($this->getPrefix().$key);
53 53
 	}
54 54
 
55 55
 	public function remove($key) {
56
-		return apcu_delete($this->getPrefix() . $key);
56
+		return apcu_delete($this->getPrefix().$key);
57 57
 	}
58 58
 
59 59
 	public function clear($prefix = '') {
60
-		$ns = $this->getPrefix() . $prefix;
60
+		$ns = $this->getPrefix().$prefix;
61 61
 		$ns = preg_quote($ns, '/');
62 62
 		if (class_exists('\APCIterator')) {
63
-			$iter = new \APCIterator('user', '/^' . $ns . '/', APC_ITER_KEY);
63
+			$iter = new \APCIterator('user', '/^'.$ns.'/', APC_ITER_KEY);
64 64
 		} else {
65
-			$iter = new \APCUIterator('/^' . $ns . '/', APC_ITER_KEY);
65
+			$iter = new \APCUIterator('/^'.$ns.'/', APC_ITER_KEY);
66 66
 		}
67 67
 		return apcu_delete($iter);
68 68
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @return bool
77 77
 	 */
78 78
 	public function add($key, $value, $ttl = 0) {
79
-		return apcu_add($this->getPrefix() . $key, $value, $ttl);
79
+		return apcu_add($this->getPrefix().$key, $value, $ttl);
80 80
 	}
81 81
 
82 82
 	/**
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 		 * see https://github.com/krakjoe/apcu/issues/183#issuecomment-244038221
101 101
 		 * for details
102 102
 		 */
103
-		return apcu_exists($this->getPrefix() . $key)
104
-			? apcu_inc($this->getPrefix() . $key, $step)
103
+		return apcu_exists($this->getPrefix().$key)
104
+			? apcu_inc($this->getPrefix().$key, $step)
105 105
 			: false;
106 106
 	}
107 107
 
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
 		 * see https://github.com/krakjoe/apcu/issues/183#issuecomment-244038221
126 126
 		 * for details
127 127
 		 */
128
-		return apcu_exists($this->getPrefix() . $key)
129
-			? apcu_dec($this->getPrefix() . $key, $step)
128
+		return apcu_exists($this->getPrefix().$key)
129
+			? apcu_dec($this->getPrefix().$key, $step)
130 130
 			: false;
131 131
 	}
132 132
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	public function cas($key, $old, $new) {
142 142
 		// apc only does cas for ints
143 143
 		if (is_int($old) and is_int($new)) {
144
-			return apcu_cas($this->getPrefix() . $key, $old, $new);
144
+			return apcu_cas($this->getPrefix().$key, $old, $new);
145 145
 		} else {
146 146
 			return $this->casEmulated($key, $old, $new);
147 147
 		}
Please login to merge, or discard this patch.
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -31,137 +31,137 @@
 block discarded – undo
31 31
 use OCP\IMemcache;
32 32
 
33 33
 class APCu extends Cache implements IMemcache {
34
-	use CASTrait {
35
-		cas as casEmulated;
36
-	}
34
+    use CASTrait {
35
+        cas as casEmulated;
36
+    }
37 37
 
38
-	use CADTrait;
38
+    use CADTrait;
39 39
 
40
-	public function get($key) {
41
-		$result = apcu_fetch($this->getPrefix() . $key, $success);
42
-		if (!$success) {
43
-			return null;
44
-		}
45
-		return $result;
46
-	}
40
+    public function get($key) {
41
+        $result = apcu_fetch($this->getPrefix() . $key, $success);
42
+        if (!$success) {
43
+            return null;
44
+        }
45
+        return $result;
46
+    }
47 47
 
48
-	public function set($key, $value, $ttl = 0) {
49
-		return apcu_store($this->getPrefix() . $key, $value, $ttl);
50
-	}
48
+    public function set($key, $value, $ttl = 0) {
49
+        return apcu_store($this->getPrefix() . $key, $value, $ttl);
50
+    }
51 51
 
52
-	public function hasKey($key) {
53
-		return apcu_exists($this->getPrefix() . $key);
54
-	}
52
+    public function hasKey($key) {
53
+        return apcu_exists($this->getPrefix() . $key);
54
+    }
55 55
 
56
-	public function remove($key) {
57
-		return apcu_delete($this->getPrefix() . $key);
58
-	}
56
+    public function remove($key) {
57
+        return apcu_delete($this->getPrefix() . $key);
58
+    }
59 59
 
60
-	public function clear($prefix = '') {
61
-		$ns = $this->getPrefix() . $prefix;
62
-		$ns = preg_quote($ns, '/');
63
-		if (class_exists('\APCIterator')) {
64
-			$iter = new \APCIterator('user', '/^' . $ns . '/', APC_ITER_KEY);
65
-		} else {
66
-			$iter = new \APCUIterator('/^' . $ns . '/', APC_ITER_KEY);
67
-		}
68
-		return apcu_delete($iter);
69
-	}
60
+    public function clear($prefix = '') {
61
+        $ns = $this->getPrefix() . $prefix;
62
+        $ns = preg_quote($ns, '/');
63
+        if (class_exists('\APCIterator')) {
64
+            $iter = new \APCIterator('user', '/^' . $ns . '/', APC_ITER_KEY);
65
+        } else {
66
+            $iter = new \APCUIterator('/^' . $ns . '/', APC_ITER_KEY);
67
+        }
68
+        return apcu_delete($iter);
69
+    }
70 70
 
71
-	/**
72
-	 * Set a value in the cache if it's not already stored
73
-	 *
74
-	 * @param string $key
75
-	 * @param mixed $value
76
-	 * @param int $ttl Time To Live in seconds. Defaults to 60*60*24
77
-	 * @return bool
78
-	 */
79
-	public function add($key, $value, $ttl = 0) {
80
-		return apcu_add($this->getPrefix() . $key, $value, $ttl);
81
-	}
71
+    /**
72
+     * Set a value in the cache if it's not already stored
73
+     *
74
+     * @param string $key
75
+     * @param mixed $value
76
+     * @param int $ttl Time To Live in seconds. Defaults to 60*60*24
77
+     * @return bool
78
+     */
79
+    public function add($key, $value, $ttl = 0) {
80
+        return apcu_add($this->getPrefix() . $key, $value, $ttl);
81
+    }
82 82
 
83
-	/**
84
-	 * Increase a stored number
85
-	 *
86
-	 * @param string $key
87
-	 * @param int $step
88
-	 * @return int | bool
89
-	 */
90
-	public function inc($key, $step = 1) {
91
-		$this->add($key, 0);
92
-		/**
93
-		 * TODO - hack around a PHP 7 specific issue in APCu
94
-		 *
95
-		 * on PHP 7 the apcu_inc method on a non-existing object will increment
96
-		 * "0" and result in "1" as value - therefore we check for existence
97
-		 * first
98
-		 *
99
-		 * on PHP 5.6 this is not the case
100
-		 *
101
-		 * see https://github.com/krakjoe/apcu/issues/183#issuecomment-244038221
102
-		 * for details
103
-		 */
104
-		return apcu_exists($this->getPrefix() . $key)
105
-			? apcu_inc($this->getPrefix() . $key, $step)
106
-			: false;
107
-	}
83
+    /**
84
+     * Increase a stored number
85
+     *
86
+     * @param string $key
87
+     * @param int $step
88
+     * @return int | bool
89
+     */
90
+    public function inc($key, $step = 1) {
91
+        $this->add($key, 0);
92
+        /**
93
+         * TODO - hack around a PHP 7 specific issue in APCu
94
+         *
95
+         * on PHP 7 the apcu_inc method on a non-existing object will increment
96
+         * "0" and result in "1" as value - therefore we check for existence
97
+         * first
98
+         *
99
+         * on PHP 5.6 this is not the case
100
+         *
101
+         * see https://github.com/krakjoe/apcu/issues/183#issuecomment-244038221
102
+         * for details
103
+         */
104
+        return apcu_exists($this->getPrefix() . $key)
105
+            ? apcu_inc($this->getPrefix() . $key, $step)
106
+            : false;
107
+    }
108 108
 
109
-	/**
110
-	 * Decrease a stored number
111
-	 *
112
-	 * @param string $key
113
-	 * @param int $step
114
-	 * @return int | bool
115
-	 */
116
-	public function dec($key, $step = 1) {
117
-		/**
118
-		 * TODO - hack around a PHP 7 specific issue in APCu
119
-		 *
120
-		 * on PHP 7 the apcu_dec method on a non-existing object will decrement
121
-		 * "0" and result in "-1" as value - therefore we check for existence
122
-		 * first
123
-		 *
124
-		 * on PHP 5.6 this is not the case
125
-		 *
126
-		 * see https://github.com/krakjoe/apcu/issues/183#issuecomment-244038221
127
-		 * for details
128
-		 */
129
-		return apcu_exists($this->getPrefix() . $key)
130
-			? apcu_dec($this->getPrefix() . $key, $step)
131
-			: false;
132
-	}
109
+    /**
110
+     * Decrease a stored number
111
+     *
112
+     * @param string $key
113
+     * @param int $step
114
+     * @return int | bool
115
+     */
116
+    public function dec($key, $step = 1) {
117
+        /**
118
+         * TODO - hack around a PHP 7 specific issue in APCu
119
+         *
120
+         * on PHP 7 the apcu_dec method on a non-existing object will decrement
121
+         * "0" and result in "-1" as value - therefore we check for existence
122
+         * first
123
+         *
124
+         * on PHP 5.6 this is not the case
125
+         *
126
+         * see https://github.com/krakjoe/apcu/issues/183#issuecomment-244038221
127
+         * for details
128
+         */
129
+        return apcu_exists($this->getPrefix() . $key)
130
+            ? apcu_dec($this->getPrefix() . $key, $step)
131
+            : false;
132
+    }
133 133
 
134
-	/**
135
-	 * Compare and set
136
-	 *
137
-	 * @param string $key
138
-	 * @param mixed $old
139
-	 * @param mixed $new
140
-	 * @return bool
141
-	 */
142
-	public function cas($key, $old, $new) {
143
-		// apc only does cas for ints
144
-		if (is_int($old) and is_int($new)) {
145
-			return apcu_cas($this->getPrefix() . $key, $old, $new);
146
-		} else {
147
-			return $this->casEmulated($key, $old, $new);
148
-		}
149
-	}
134
+    /**
135
+     * Compare and set
136
+     *
137
+     * @param string $key
138
+     * @param mixed $old
139
+     * @param mixed $new
140
+     * @return bool
141
+     */
142
+    public function cas($key, $old, $new) {
143
+        // apc only does cas for ints
144
+        if (is_int($old) and is_int($new)) {
145
+            return apcu_cas($this->getPrefix() . $key, $old, $new);
146
+        } else {
147
+            return $this->casEmulated($key, $old, $new);
148
+        }
149
+    }
150 150
 
151
-	public static function isAvailable(): bool {
152
-		if (!extension_loaded('apcu')) {
153
-			return false;
154
-		} elseif (!\OC::$server->get(IniGetWrapper::class)->getBool('apc.enabled')) {
155
-			return false;
156
-		} elseif (!\OC::$server->get(IniGetWrapper::class)->getBool('apc.enable_cli') && \OC::$CLI) {
157
-			return false;
158
-		} elseif (
159
-			version_compare(phpversion('apc') ?: '0.0.0', '4.0.6') === -1 &&
160
-			version_compare(phpversion('apcu') ?: '0.0.0', '5.1.0') === -1
161
-		) {
162
-			return false;
163
-		} else {
164
-			return true;
165
-		}
166
-	}
151
+    public static function isAvailable(): bool {
152
+        if (!extension_loaded('apcu')) {
153
+            return false;
154
+        } elseif (!\OC::$server->get(IniGetWrapper::class)->getBool('apc.enabled')) {
155
+            return false;
156
+        } elseif (!\OC::$server->get(IniGetWrapper::class)->getBool('apc.enable_cli') && \OC::$CLI) {
157
+            return false;
158
+        } elseif (
159
+            version_compare(phpversion('apc') ?: '0.0.0', '4.0.6') === -1 &&
160
+            version_compare(phpversion('apcu') ?: '0.0.0', '5.1.0') === -1
161
+        ) {
162
+            return false;
163
+        } else {
164
+            return true;
165
+        }
166
+    }
167 167
 }
Please login to merge, or discard this patch.
lib/private/Group/Backend.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
 	 * compared with \OC\Group\Backend::CREATE_GROUP etc.
68 68
 	 */
69 69
 	public function implementsActions($actions) {
70
-		return (bool)($this->getSupportedActions() & $actions);
70
+		return (bool) ($this->getSupportedActions() & $actions);
71 71
 	}
72 72
 
73 73
 	/**
Please login to merge, or discard this patch.
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -28,107 +28,107 @@
 block discarded – undo
28 28
  * Abstract base class for user management
29 29
  */
30 30
 abstract class Backend implements \OCP\GroupInterface {
31
-	/**
32
-	 * error code for functions not provided by the group backend
33
-	 */
34
-	public const NOT_IMPLEMENTED = -501;
31
+    /**
32
+     * error code for functions not provided by the group backend
33
+     */
34
+    public const NOT_IMPLEMENTED = -501;
35 35
 
36
-	protected $possibleActions = [
37
-		self::CREATE_GROUP => 'createGroup',
38
-		self::DELETE_GROUP => 'deleteGroup',
39
-		self::ADD_TO_GROUP => 'addToGroup',
40
-		self::REMOVE_FROM_GOUP => 'removeFromGroup',
41
-		self::COUNT_USERS => 'countUsersInGroup',
42
-		self::GROUP_DETAILS => 'getGroupDetails',
43
-		self::IS_ADMIN => 'isAdmin',
44
-	];
36
+    protected $possibleActions = [
37
+        self::CREATE_GROUP => 'createGroup',
38
+        self::DELETE_GROUP => 'deleteGroup',
39
+        self::ADD_TO_GROUP => 'addToGroup',
40
+        self::REMOVE_FROM_GOUP => 'removeFromGroup',
41
+        self::COUNT_USERS => 'countUsersInGroup',
42
+        self::GROUP_DETAILS => 'getGroupDetails',
43
+        self::IS_ADMIN => 'isAdmin',
44
+    ];
45 45
 
46
-	/**
47
-	 * Get all supported actions
48
-	 * @return int bitwise-or'ed actions
49
-	 *
50
-	 * Returns the supported actions as int to be
51
-	 * compared with \OC\Group\Backend::CREATE_GROUP etc.
52
-	 */
53
-	public function getSupportedActions() {
54
-		$actions = 0;
55
-		foreach ($this->possibleActions as $action => $methodName) {
56
-			if (method_exists($this, $methodName)) {
57
-				$actions |= $action;
58
-			}
59
-		}
46
+    /**
47
+     * Get all supported actions
48
+     * @return int bitwise-or'ed actions
49
+     *
50
+     * Returns the supported actions as int to be
51
+     * compared with \OC\Group\Backend::CREATE_GROUP etc.
52
+     */
53
+    public function getSupportedActions() {
54
+        $actions = 0;
55
+        foreach ($this->possibleActions as $action => $methodName) {
56
+            if (method_exists($this, $methodName)) {
57
+                $actions |= $action;
58
+            }
59
+        }
60 60
 
61
-		return $actions;
62
-	}
61
+        return $actions;
62
+    }
63 63
 
64
-	/**
65
-	 * Check if backend implements actions
66
-	 * @param int $actions bitwise-or'ed actions
67
-	 * @return bool
68
-	 *
69
-	 * Returns the supported actions as int to be
70
-	 * compared with \OC\Group\Backend::CREATE_GROUP etc.
71
-	 */
72
-	public function implementsActions($actions) {
73
-		return (bool)($this->getSupportedActions() & $actions);
74
-	}
64
+    /**
65
+     * Check if backend implements actions
66
+     * @param int $actions bitwise-or'ed actions
67
+     * @return bool
68
+     *
69
+     * Returns the supported actions as int to be
70
+     * compared with \OC\Group\Backend::CREATE_GROUP etc.
71
+     */
72
+    public function implementsActions($actions) {
73
+        return (bool)($this->getSupportedActions() & $actions);
74
+    }
75 75
 
76
-	/**
77
-	 * is user in group?
78
-	 * @param string $uid uid of the user
79
-	 * @param string $gid gid of the group
80
-	 * @return bool
81
-	 *
82
-	 * Checks whether the user is member of a group or not.
83
-	 */
84
-	public function inGroup($uid, $gid) {
85
-		return in_array($gid, $this->getUserGroups($uid));
86
-	}
76
+    /**
77
+     * is user in group?
78
+     * @param string $uid uid of the user
79
+     * @param string $gid gid of the group
80
+     * @return bool
81
+     *
82
+     * Checks whether the user is member of a group or not.
83
+     */
84
+    public function inGroup($uid, $gid) {
85
+        return in_array($gid, $this->getUserGroups($uid));
86
+    }
87 87
 
88
-	/**
89
-	 * Get all groups a user belongs to
90
-	 * @param string $uid Name of the user
91
-	 * @return array an array of group names
92
-	 *
93
-	 * This function fetches all groups a user belongs to. It does not check
94
-	 * if the user exists at all.
95
-	 */
96
-	public function getUserGroups($uid) {
97
-		return [];
98
-	}
88
+    /**
89
+     * Get all groups a user belongs to
90
+     * @param string $uid Name of the user
91
+     * @return array an array of group names
92
+     *
93
+     * This function fetches all groups a user belongs to. It does not check
94
+     * if the user exists at all.
95
+     */
96
+    public function getUserGroups($uid) {
97
+        return [];
98
+    }
99 99
 
100
-	/**
101
-	 * get a list of all groups
102
-	 * @param string $search
103
-	 * @param int $limit
104
-	 * @param int $offset
105
-	 * @return array an array of group names
106
-	 *
107
-	 * Returns a list with all groups
108
-	 */
100
+    /**
101
+     * get a list of all groups
102
+     * @param string $search
103
+     * @param int $limit
104
+     * @param int $offset
105
+     * @return array an array of group names
106
+     *
107
+     * Returns a list with all groups
108
+     */
109 109
 
110
-	public function getGroups($search = '', $limit = -1, $offset = 0) {
111
-		return [];
112
-	}
110
+    public function getGroups($search = '', $limit = -1, $offset = 0) {
111
+        return [];
112
+    }
113 113
 
114
-	/**
115
-	 * check if a group exists
116
-	 * @param string $gid
117
-	 * @return bool
118
-	 */
119
-	public function groupExists($gid) {
120
-		return in_array($gid, $this->getGroups($gid, 1));
121
-	}
114
+    /**
115
+     * check if a group exists
116
+     * @param string $gid
117
+     * @return bool
118
+     */
119
+    public function groupExists($gid) {
120
+        return in_array($gid, $this->getGroups($gid, 1));
121
+    }
122 122
 
123
-	/**
124
-	 * get a list of all users in a group
125
-	 * @param string $gid
126
-	 * @param string $search
127
-	 * @param int $limit
128
-	 * @param int $offset
129
-	 * @return array<int,string> an array of user ids
130
-	 */
131
-	public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
132
-		return [];
133
-	}
123
+    /**
124
+     * get a list of all users in a group
125
+     * @param string $gid
126
+     * @param string $search
127
+     * @param int $limit
128
+     * @param int $offset
129
+     * @return array<int,string> an array of user ids
130
+     */
131
+    public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
132
+        return [];
133
+    }
134 134
 }
Please login to merge, or discard this patch.
lib/private/Activity/EventMerger.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
 
134 134
 		// Check that all parameters from $event exist in $previousEvent
135 135
 		foreach ($params1 as $key => $parameter) {
136
-			if (preg_match('/^' . $mergeParameter . '(\d+)?$/', $key)) {
136
+			if (preg_match('/^'.$mergeParameter.'(\d+)?$/', $key)) {
137 137
 				if (!$this->checkParameterAlreadyExits($params, $mergeParameter, $parameter)) {
138 138
 					$combined++;
139
-					$params[$mergeParameter . $combined] = $parameter;
139
+					$params[$mergeParameter.$combined] = $parameter;
140 140
 				}
141 141
 				continue;
142 142
 			}
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 
152 152
 		// Check that all parameters from $previousEvent exist in $event
153 153
 		foreach ($params2 as $key => $parameter) {
154
-			if (preg_match('/^' . $mergeParameter . '(\d+)?$/', $key)) {
154
+			if (preg_match('/^'.$mergeParameter.'(\d+)?$/', $key)) {
155 155
 				if (!$this->checkParameterAlreadyExits($params, $mergeParameter, $parameter)) {
156 156
 					$combined++;
157
-					$params[$mergeParameter . $combined] = $parameter;
157
+					$params[$mergeParameter.$combined] = $parameter;
158 158
 				}
159 159
 				continue;
160 160
 			}
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 */
179 179
 	protected function checkParameterAlreadyExits($parameters, $mergeParameter, $parameter) {
180 180
 		foreach ($parameters as $key => $param) {
181
-			if (preg_match('/^' . $mergeParameter . '(\d+)?$/', $key)) {
181
+			if (preg_match('/^'.$mergeParameter.'(\d+)?$/', $key)) {
182 182
 				if ($param === $parameter) {
183 183
 					return true;
184 184
 				}
@@ -196,30 +196,30 @@  discard block
 block discarded – undo
196 196
 	protected function getExtendedSubject($subject, $parameter, $counter) {
197 197
 		switch ($counter) {
198 198
 			case 1:
199
-				$replacement = '{' . $parameter . '1}';
199
+				$replacement = '{'.$parameter.'1}';
200 200
 				break;
201 201
 			case 2:
202 202
 				$replacement = $this->l10n->t(
203 203
 					'%1$s and %2$s',
204
-					['{' . $parameter . '2}', '{' . $parameter . '1}']
204
+					['{'.$parameter.'2}', '{'.$parameter.'1}']
205 205
 				);
206 206
 				break;
207 207
 			case 3:
208 208
 				$replacement = $this->l10n->t(
209 209
 					'%1$s, %2$s and %3$s',
210
-					['{' . $parameter . '3}', '{' . $parameter . '2}', '{' . $parameter . '1}']
210
+					['{'.$parameter.'3}', '{'.$parameter.'2}', '{'.$parameter.'1}']
211 211
 				);
212 212
 				break;
213 213
 			case 4:
214 214
 				$replacement = $this->l10n->t(
215 215
 					'%1$s, %2$s, %3$s and %4$s',
216
-					['{' . $parameter . '4}', '{' . $parameter . '3}', '{' . $parameter . '2}', '{' . $parameter . '1}']
216
+					['{'.$parameter.'4}', '{'.$parameter.'3}', '{'.$parameter.'2}', '{'.$parameter.'1}']
217 217
 				);
218 218
 				break;
219 219
 			case 5:
220 220
 				$replacement = $this->l10n->t(
221 221
 					'%1$s, %2$s, %3$s, %4$s and %5$s',
222
-					['{' . $parameter . '5}', '{' . $parameter . '4}', '{' . $parameter . '3}', '{' . $parameter . '2}', '{' . $parameter . '1}']
222
+					['{'.$parameter.'5}', '{'.$parameter.'4}', '{'.$parameter.'3}', '{'.$parameter.'2}', '{'.$parameter.'1}']
223 223
 				);
224 224
 				break;
225 225
 			default:
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 		}
228 228
 
229 229
 		return str_replace(
230
-			'{' . $parameter . '}',
230
+			'{'.$parameter.'}',
231 231
 			$replacement,
232 232
 			$subject
233 233
 		);
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	protected function generateParsedSubject($subject, $parameters) {
242 242
 		$placeholders = $replacements = [];
243 243
 		foreach ($parameters as $placeholder => $parameter) {
244
-			$placeholders[] = '{' . $placeholder . '}';
244
+			$placeholders[] = '{'.$placeholder.'}';
245 245
 			if ($parameter['type'] === 'file') {
246 246
 				$replacements[] = trim($parameter['path'], '/');
247 247
 			} elseif (isset($parameter['name'])) {
Please login to merge, or discard this patch.
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -29,231 +29,231 @@
 block discarded – undo
29 29
 use OCP\IL10N;
30 30
 
31 31
 class EventMerger implements IEventMerger {
32
-	/** @var IL10N */
33
-	protected $l10n;
32
+    /** @var IL10N */
33
+    protected $l10n;
34 34
 
35
-	/**
36
-	 * @param IL10N $l10n
37
-	 */
38
-	public function __construct(IL10N $l10n) {
39
-		$this->l10n = $l10n;
40
-	}
35
+    /**
36
+     * @param IL10N $l10n
37
+     */
38
+    public function __construct(IL10N $l10n) {
39
+        $this->l10n = $l10n;
40
+    }
41 41
 
42
-	/**
43
-	 * Combines two events when possible to have grouping:
44
-	 *
45
-	 * Example1: Two events with subject '{user} created {file}' and
46
-	 * $mergeParameter file with different file and same user will be merged
47
-	 * to '{user} created {file1} and {file2}' and the childEvent on the return
48
-	 * will be set, if the events have been merged.
49
-	 *
50
-	 * Example2: Two events with subject '{user} created {file}' and
51
-	 * $mergeParameter file with same file and same user will be merged to
52
-	 * '{user} created {file1}' and the childEvent on the return will be set, if
53
-	 * the events have been merged.
54
-	 *
55
-	 * The following requirements have to be met, in order to be merged:
56
-	 * - Both events need to have the same `getApp()`
57
-	 * - Both events must not have a message `getMessage()`
58
-	 * - Both events need to have the same subject `getSubject()`
59
-	 * - Both events need to have the same object type `getObjectType()`
60
-	 * - The time difference between both events must not be bigger then 3 hours
61
-	 * - Only up to 5 events can be merged.
62
-	 * - All parameters apart from such starting with $mergeParameter must be
63
-	 *   the same for both events.
64
-	 *
65
-	 * @param string $mergeParameter
66
-	 * @param IEvent $event
67
-	 * @param IEvent|null $previousEvent
68
-	 * @return IEvent
69
-	 */
70
-	public function mergeEvents($mergeParameter, IEvent $event, IEvent $previousEvent = null) {
71
-		// No second event => can not combine
72
-		if (!$previousEvent instanceof IEvent) {
73
-			return $event;
74
-		}
42
+    /**
43
+     * Combines two events when possible to have grouping:
44
+     *
45
+     * Example1: Two events with subject '{user} created {file}' and
46
+     * $mergeParameter file with different file and same user will be merged
47
+     * to '{user} created {file1} and {file2}' and the childEvent on the return
48
+     * will be set, if the events have been merged.
49
+     *
50
+     * Example2: Two events with subject '{user} created {file}' and
51
+     * $mergeParameter file with same file and same user will be merged to
52
+     * '{user} created {file1}' and the childEvent on the return will be set, if
53
+     * the events have been merged.
54
+     *
55
+     * The following requirements have to be met, in order to be merged:
56
+     * - Both events need to have the same `getApp()`
57
+     * - Both events must not have a message `getMessage()`
58
+     * - Both events need to have the same subject `getSubject()`
59
+     * - Both events need to have the same object type `getObjectType()`
60
+     * - The time difference between both events must not be bigger then 3 hours
61
+     * - Only up to 5 events can be merged.
62
+     * - All parameters apart from such starting with $mergeParameter must be
63
+     *   the same for both events.
64
+     *
65
+     * @param string $mergeParameter
66
+     * @param IEvent $event
67
+     * @param IEvent|null $previousEvent
68
+     * @return IEvent
69
+     */
70
+    public function mergeEvents($mergeParameter, IEvent $event, IEvent $previousEvent = null) {
71
+        // No second event => can not combine
72
+        if (!$previousEvent instanceof IEvent) {
73
+            return $event;
74
+        }
75 75
 
76
-		// Different app => can not combine
77
-		if ($event->getApp() !== $previousEvent->getApp()) {
78
-			return $event;
79
-		}
76
+        // Different app => can not combine
77
+        if ($event->getApp() !== $previousEvent->getApp()) {
78
+            return $event;
79
+        }
80 80
 
81
-		// Message is set => can not combine
82
-		if ($event->getMessage() !== '' || $previousEvent->getMessage() !== '') {
83
-			return $event;
84
-		}
81
+        // Message is set => can not combine
82
+        if ($event->getMessage() !== '' || $previousEvent->getMessage() !== '') {
83
+            return $event;
84
+        }
85 85
 
86
-		// Different subject => can not combine
87
-		if ($event->getSubject() !== $previousEvent->getSubject()) {
88
-			return $event;
89
-		}
86
+        // Different subject => can not combine
87
+        if ($event->getSubject() !== $previousEvent->getSubject()) {
88
+            return $event;
89
+        }
90 90
 
91
-		// Different object type => can not combine
92
-		if ($event->getObjectType() !== $previousEvent->getObjectType()) {
93
-			return $event;
94
-		}
91
+        // Different object type => can not combine
92
+        if ($event->getObjectType() !== $previousEvent->getObjectType()) {
93
+            return $event;
94
+        }
95 95
 
96
-		// More than 3 hours difference => can not combine
97
-		if (abs($event->getTimestamp() - $previousEvent->getTimestamp()) > 3 * 60 * 60) {
98
-			return $event;
99
-		}
96
+        // More than 3 hours difference => can not combine
97
+        if (abs($event->getTimestamp() - $previousEvent->getTimestamp()) > 3 * 60 * 60) {
98
+            return $event;
99
+        }
100 100
 
101
-		// Other parameters are not the same => can not combine
102
-		try {
103
-			[$combined, $parameters] = $this->combineParameters($mergeParameter, $event, $previousEvent);
104
-		} catch (\UnexpectedValueException $e) {
105
-			return $event;
106
-		}
101
+        // Other parameters are not the same => can not combine
102
+        try {
103
+            [$combined, $parameters] = $this->combineParameters($mergeParameter, $event, $previousEvent);
104
+        } catch (\UnexpectedValueException $e) {
105
+            return $event;
106
+        }
107 107
 
108
-		try {
109
-			$newSubject = $this->getExtendedSubject($event->getRichSubject(), $mergeParameter, $combined);
110
-			$parsedSubject = $this->generateParsedSubject($newSubject, $parameters);
108
+        try {
109
+            $newSubject = $this->getExtendedSubject($event->getRichSubject(), $mergeParameter, $combined);
110
+            $parsedSubject = $this->generateParsedSubject($newSubject, $parameters);
111 111
 
112
-			$event->setRichSubject($newSubject, $parameters)
113
-				->setParsedSubject($parsedSubject)
114
-				->setChildEvent($previousEvent)
115
-				->setTimestamp(max($event->getTimestamp(), $previousEvent->getTimestamp()));
116
-		} catch (\UnexpectedValueException $e) {
117
-			return $event;
118
-		}
112
+            $event->setRichSubject($newSubject, $parameters)
113
+                ->setParsedSubject($parsedSubject)
114
+                ->setChildEvent($previousEvent)
115
+                ->setTimestamp(max($event->getTimestamp(), $previousEvent->getTimestamp()));
116
+        } catch (\UnexpectedValueException $e) {
117
+            return $event;
118
+        }
119 119
 
120
-		return $event;
121
-	}
120
+        return $event;
121
+    }
122 122
 
123
-	/**
124
-	 * @param string $mergeParameter
125
-	 * @param IEvent $event
126
-	 * @param IEvent $previousEvent
127
-	 * @return array
128
-	 * @throws \UnexpectedValueException
129
-	 */
130
-	protected function combineParameters($mergeParameter, IEvent $event, IEvent $previousEvent) {
131
-		$params1 = $event->getRichSubjectParameters();
132
-		$params2 = $previousEvent->getRichSubjectParameters();
133
-		$params = [];
123
+    /**
124
+     * @param string $mergeParameter
125
+     * @param IEvent $event
126
+     * @param IEvent $previousEvent
127
+     * @return array
128
+     * @throws \UnexpectedValueException
129
+     */
130
+    protected function combineParameters($mergeParameter, IEvent $event, IEvent $previousEvent) {
131
+        $params1 = $event->getRichSubjectParameters();
132
+        $params2 = $previousEvent->getRichSubjectParameters();
133
+        $params = [];
134 134
 
135
-		$combined = 0;
135
+        $combined = 0;
136 136
 
137
-		// Check that all parameters from $event exist in $previousEvent
138
-		foreach ($params1 as $key => $parameter) {
139
-			if (preg_match('/^' . $mergeParameter . '(\d+)?$/', $key)) {
140
-				if (!$this->checkParameterAlreadyExits($params, $mergeParameter, $parameter)) {
141
-					$combined++;
142
-					$params[$mergeParameter . $combined] = $parameter;
143
-				}
144
-				continue;
145
-			}
137
+        // Check that all parameters from $event exist in $previousEvent
138
+        foreach ($params1 as $key => $parameter) {
139
+            if (preg_match('/^' . $mergeParameter . '(\d+)?$/', $key)) {
140
+                if (!$this->checkParameterAlreadyExits($params, $mergeParameter, $parameter)) {
141
+                    $combined++;
142
+                    $params[$mergeParameter . $combined] = $parameter;
143
+                }
144
+                continue;
145
+            }
146 146
 
147
-			if (!isset($params2[$key]) || $params2[$key] !== $parameter) {
148
-				// Parameter missing on $previousEvent or different => can not combine
149
-				throw new \UnexpectedValueException();
150
-			}
147
+            if (!isset($params2[$key]) || $params2[$key] !== $parameter) {
148
+                // Parameter missing on $previousEvent or different => can not combine
149
+                throw new \UnexpectedValueException();
150
+            }
151 151
 
152
-			$params[$key] = $parameter;
153
-		}
152
+            $params[$key] = $parameter;
153
+        }
154 154
 
155
-		// Check that all parameters from $previousEvent exist in $event
156
-		foreach ($params2 as $key => $parameter) {
157
-			if (preg_match('/^' . $mergeParameter . '(\d+)?$/', $key)) {
158
-				if (!$this->checkParameterAlreadyExits($params, $mergeParameter, $parameter)) {
159
-					$combined++;
160
-					$params[$mergeParameter . $combined] = $parameter;
161
-				}
162
-				continue;
163
-			}
155
+        // Check that all parameters from $previousEvent exist in $event
156
+        foreach ($params2 as $key => $parameter) {
157
+            if (preg_match('/^' . $mergeParameter . '(\d+)?$/', $key)) {
158
+                if (!$this->checkParameterAlreadyExits($params, $mergeParameter, $parameter)) {
159
+                    $combined++;
160
+                    $params[$mergeParameter . $combined] = $parameter;
161
+                }
162
+                continue;
163
+            }
164 164
 
165
-			if (!isset($params1[$key]) || $params1[$key] !== $parameter) {
166
-				// Parameter missing on $event or different => can not combine
167
-				throw new \UnexpectedValueException();
168
-			}
165
+            if (!isset($params1[$key]) || $params1[$key] !== $parameter) {
166
+                // Parameter missing on $event or different => can not combine
167
+                throw new \UnexpectedValueException();
168
+            }
169 169
 
170
-			$params[$key] = $parameter;
171
-		}
170
+            $params[$key] = $parameter;
171
+        }
172 172
 
173
-		return [$combined, $params];
174
-	}
173
+        return [$combined, $params];
174
+    }
175 175
 
176
-	/**
177
-	 * @param array[] $parameters
178
-	 * @param string $mergeParameter
179
-	 * @param array $parameter
180
-	 * @return bool
181
-	 */
182
-	protected function checkParameterAlreadyExits($parameters, $mergeParameter, $parameter) {
183
-		foreach ($parameters as $key => $param) {
184
-			if (preg_match('/^' . $mergeParameter . '(\d+)?$/', $key)) {
185
-				if ($param === $parameter) {
186
-					return true;
187
-				}
188
-			}
189
-		}
190
-		return false;
191
-	}
176
+    /**
177
+     * @param array[] $parameters
178
+     * @param string $mergeParameter
179
+     * @param array $parameter
180
+     * @return bool
181
+     */
182
+    protected function checkParameterAlreadyExits($parameters, $mergeParameter, $parameter) {
183
+        foreach ($parameters as $key => $param) {
184
+            if (preg_match('/^' . $mergeParameter . '(\d+)?$/', $key)) {
185
+                if ($param === $parameter) {
186
+                    return true;
187
+                }
188
+            }
189
+        }
190
+        return false;
191
+    }
192 192
 
193
-	/**
194
-	 * @param string $subject
195
-	 * @param string $parameter
196
-	 * @param int $counter
197
-	 * @return mixed
198
-	 */
199
-	protected function getExtendedSubject($subject, $parameter, $counter) {
200
-		switch ($counter) {
201
-			case 1:
202
-				$replacement = '{' . $parameter . '1}';
203
-				break;
204
-			case 2:
205
-				$replacement = $this->l10n->t(
206
-					'%1$s and %2$s',
207
-					['{' . $parameter . '2}', '{' . $parameter . '1}']
208
-				);
209
-				break;
210
-			case 3:
211
-				$replacement = $this->l10n->t(
212
-					'%1$s, %2$s and %3$s',
213
-					['{' . $parameter . '3}', '{' . $parameter . '2}', '{' . $parameter . '1}']
214
-				);
215
-				break;
216
-			case 4:
217
-				$replacement = $this->l10n->t(
218
-					'%1$s, %2$s, %3$s and %4$s',
219
-					['{' . $parameter . '4}', '{' . $parameter . '3}', '{' . $parameter . '2}', '{' . $parameter . '1}']
220
-				);
221
-				break;
222
-			case 5:
223
-				$replacement = $this->l10n->t(
224
-					'%1$s, %2$s, %3$s, %4$s and %5$s',
225
-					['{' . $parameter . '5}', '{' . $parameter . '4}', '{' . $parameter . '3}', '{' . $parameter . '2}', '{' . $parameter . '1}']
226
-				);
227
-				break;
228
-			default:
229
-				throw new \UnexpectedValueException();
230
-		}
193
+    /**
194
+     * @param string $subject
195
+     * @param string $parameter
196
+     * @param int $counter
197
+     * @return mixed
198
+     */
199
+    protected function getExtendedSubject($subject, $parameter, $counter) {
200
+        switch ($counter) {
201
+            case 1:
202
+                $replacement = '{' . $parameter . '1}';
203
+                break;
204
+            case 2:
205
+                $replacement = $this->l10n->t(
206
+                    '%1$s and %2$s',
207
+                    ['{' . $parameter . '2}', '{' . $parameter . '1}']
208
+                );
209
+                break;
210
+            case 3:
211
+                $replacement = $this->l10n->t(
212
+                    '%1$s, %2$s and %3$s',
213
+                    ['{' . $parameter . '3}', '{' . $parameter . '2}', '{' . $parameter . '1}']
214
+                );
215
+                break;
216
+            case 4:
217
+                $replacement = $this->l10n->t(
218
+                    '%1$s, %2$s, %3$s and %4$s',
219
+                    ['{' . $parameter . '4}', '{' . $parameter . '3}', '{' . $parameter . '2}', '{' . $parameter . '1}']
220
+                );
221
+                break;
222
+            case 5:
223
+                $replacement = $this->l10n->t(
224
+                    '%1$s, %2$s, %3$s, %4$s and %5$s',
225
+                    ['{' . $parameter . '5}', '{' . $parameter . '4}', '{' . $parameter . '3}', '{' . $parameter . '2}', '{' . $parameter . '1}']
226
+                );
227
+                break;
228
+            default:
229
+                throw new \UnexpectedValueException();
230
+        }
231 231
 
232
-		return str_replace(
233
-			'{' . $parameter . '}',
234
-			$replacement,
235
-			$subject
236
-		);
237
-	}
232
+        return str_replace(
233
+            '{' . $parameter . '}',
234
+            $replacement,
235
+            $subject
236
+        );
237
+    }
238 238
 
239
-	/**
240
-	 * @param string $subject
241
-	 * @param array[] $parameters
242
-	 * @return string
243
-	 */
244
-	protected function generateParsedSubject($subject, $parameters) {
245
-		$placeholders = $replacements = [];
246
-		foreach ($parameters as $placeholder => $parameter) {
247
-			$placeholders[] = '{' . $placeholder . '}';
248
-			if ($parameter['type'] === 'file') {
249
-				$replacements[] = trim($parameter['path'], '/');
250
-			} elseif (isset($parameter['name'])) {
251
-				$replacements[] = $parameter['name'];
252
-			} else {
253
-				$replacements[] = $parameter['id'];
254
-			}
255
-		}
239
+    /**
240
+     * @param string $subject
241
+     * @param array[] $parameters
242
+     * @return string
243
+     */
244
+    protected function generateParsedSubject($subject, $parameters) {
245
+        $placeholders = $replacements = [];
246
+        foreach ($parameters as $placeholder => $parameter) {
247
+            $placeholders[] = '{' . $placeholder . '}';
248
+            if ($parameter['type'] === 'file') {
249
+                $replacements[] = trim($parameter['path'], '/');
250
+            } elseif (isset($parameter['name'])) {
251
+                $replacements[] = $parameter['name'];
252
+            } else {
253
+                $replacements[] = $parameter['id'];
254
+            }
255
+        }
256 256
 
257
-		return str_replace($placeholders, $replacements, $subject);
258
-	}
257
+        return str_replace($placeholders, $replacements, $subject);
258
+    }
259 259
 }
Please login to merge, or discard this patch.
lib/private/Template/TemplateFileLocator.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -26,37 +26,37 @@
 block discarded – undo
26 26
 namespace OC\Template;
27 27
 
28 28
 class TemplateFileLocator {
29
-	protected $dirs;
30
-	private $path;
29
+    protected $dirs;
30
+    private $path;
31 31
 
32
-	/**
33
-	 * @param string[] $dirs
34
-	 */
35
-	public function __construct($dirs) {
36
-		$this->dirs = $dirs;
37
-	}
32
+    /**
33
+     * @param string[] $dirs
34
+     */
35
+    public function __construct($dirs) {
36
+        $this->dirs = $dirs;
37
+    }
38 38
 
39
-	/**
40
-	 * @param string $template
41
-	 * @return string
42
-	 * @throws \Exception
43
-	 */
44
-	public function find($template) {
45
-		if ($template === '') {
46
-			throw new \InvalidArgumentException('Empty template name');
47
-		}
39
+    /**
40
+     * @param string $template
41
+     * @return string
42
+     * @throws \Exception
43
+     */
44
+    public function find($template) {
45
+        if ($template === '') {
46
+            throw new \InvalidArgumentException('Empty template name');
47
+        }
48 48
 
49
-		foreach ($this->dirs as $dir) {
50
-			$file = $dir.$template.'.php';
51
-			if (is_file($file)) {
52
-				$this->path = $dir;
53
-				return $file;
54
-			}
55
-		}
56
-		throw new \Exception('template file not found: template:'.$template);
57
-	}
49
+        foreach ($this->dirs as $dir) {
50
+            $file = $dir.$template.'.php';
51
+            if (is_file($file)) {
52
+                $this->path = $dir;
53
+                return $file;
54
+            }
55
+        }
56
+        throw new \Exception('template file not found: template:'.$template);
57
+    }
58 58
 
59
-	public function getPath() {
60
-		return $this->path;
61
-	}
59
+    public function getPath() {
60
+        return $this->path;
61
+    }
62 62
 }
Please login to merge, or discard this patch.