Passed
Push — master ( 25ab12...62403d )
by Blizzz
12:17 queued 22s
created
lib/public/BackgroundJob/IJobList.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -32,100 +32,100 @@
 block discarded – undo
32 32
  * @since 7.0.0
33 33
  */
34 34
 interface IJobList {
35
-	/**
36
-	 * Add a job to the list
37
-	 *
38
-	 * @param \OCP\BackgroundJob\IJob|string $job
39
-	 * @param mixed $argument The argument to be passed to $job->run() when the job is exectured
40
-	 * @since 7.0.0
41
-	 */
42
-	public function add($job, $argument = null);
35
+    /**
36
+     * Add a job to the list
37
+     *
38
+     * @param \OCP\BackgroundJob\IJob|string $job
39
+     * @param mixed $argument The argument to be passed to $job->run() when the job is exectured
40
+     * @since 7.0.0
41
+     */
42
+    public function add($job, $argument = null);
43 43
 
44
-	/**
45
-	 * Remove a job from the list
46
-	 *
47
-	 * @param \OCP\BackgroundJob\IJob|string $job
48
-	 * @param mixed $argument
49
-	 * @since 7.0.0
50
-	 */
51
-	public function remove($job, $argument = null);
44
+    /**
45
+     * Remove a job from the list
46
+     *
47
+     * @param \OCP\BackgroundJob\IJob|string $job
48
+     * @param mixed $argument
49
+     * @since 7.0.0
50
+     */
51
+    public function remove($job, $argument = null);
52 52
 
53
-	/**
54
-	 * check if a job is in the list
55
-	 *
56
-	 * @param \OCP\BackgroundJob\IJob|string $job
57
-	 * @param mixed $argument
58
-	 * @return bool
59
-	 * @since 7.0.0
60
-	 */
61
-	public function has($job, $argument);
53
+    /**
54
+     * check if a job is in the list
55
+     *
56
+     * @param \OCP\BackgroundJob\IJob|string $job
57
+     * @param mixed $argument
58
+     * @return bool
59
+     * @since 7.0.0
60
+     */
61
+    public function has($job, $argument);
62 62
 
63
-	/**
64
-	 * get all jobs in the list
65
-	 *
66
-	 * @return \OCP\BackgroundJob\IJob[]
67
-	 * @since 7.0.0
68
-	 * @deprecated 9.0.0 - This method is dangerous since it can cause load and
69
-	 * memory problems when creating too many instances.
70
-	 */
71
-	public function getAll();
63
+    /**
64
+     * get all jobs in the list
65
+     *
66
+     * @return \OCP\BackgroundJob\IJob[]
67
+     * @since 7.0.0
68
+     * @deprecated 9.0.0 - This method is dangerous since it can cause load and
69
+     * memory problems when creating too many instances.
70
+     */
71
+    public function getAll();
72 72
 
73
-	/**
74
-	 * get the next job in the list
75
-	 *
76
-	 * @return \OCP\BackgroundJob\IJob|null
77
-	 * @since 7.0.0
78
-	 */
79
-	public function getNext();
73
+    /**
74
+     * get the next job in the list
75
+     *
76
+     * @return \OCP\BackgroundJob\IJob|null
77
+     * @since 7.0.0
78
+     */
79
+    public function getNext();
80 80
 
81
-	/**
82
-	 * @param int $id
83
-	 * @return \OCP\BackgroundJob\IJob|null
84
-	 * @since 7.0.0
85
-	 */
86
-	public function getById($id);
81
+    /**
82
+     * @param int $id
83
+     * @return \OCP\BackgroundJob\IJob|null
84
+     * @since 7.0.0
85
+     */
86
+    public function getById($id);
87 87
 
88
-	/**
89
-	 * set the job that was last ran to the current time
90
-	 *
91
-	 * @param \OCP\BackgroundJob\IJob $job
92
-	 * @since 7.0.0
93
-	 */
94
-	public function setLastJob(IJob $job);
88
+    /**
89
+     * set the job that was last ran to the current time
90
+     *
91
+     * @param \OCP\BackgroundJob\IJob $job
92
+     * @since 7.0.0
93
+     */
94
+    public function setLastJob(IJob $job);
95 95
 
96
-	/**
97
-	 * Remove the reservation for a job
98
-	 *
99
-	 * @param IJob $job
100
-	 * @since 9.1.0
101
-	 */
102
-	public function unlockJob(IJob $job);
96
+    /**
97
+     * Remove the reservation for a job
98
+     *
99
+     * @param IJob $job
100
+     * @since 9.1.0
101
+     */
102
+    public function unlockJob(IJob $job);
103 103
 
104
-	/**
105
-	 * get the id of the last ran job
106
-	 *
107
-	 * @return int
108
-	 * @since 7.0.0
109
-	 * @deprecated 9.1.0 - The functionality behind the value is deprecated, it
110
-	 *    only tells you which job finished last, but since we now allow multiple
111
-	 *    executors to run in parallel, it's not used to calculate the next job.
112
-	 */
113
-	public function getLastJob();
104
+    /**
105
+     * get the id of the last ran job
106
+     *
107
+     * @return int
108
+     * @since 7.0.0
109
+     * @deprecated 9.1.0 - The functionality behind the value is deprecated, it
110
+     *    only tells you which job finished last, but since we now allow multiple
111
+     *    executors to run in parallel, it's not used to calculate the next job.
112
+     */
113
+    public function getLastJob();
114 114
 
115
-	/**
116
-	 * set the lastRun of $job to now
117
-	 *
118
-	 * @param IJob $job
119
-	 * @since 7.0.0
120
-	 */
121
-	public function setLastRun(IJob $job);
115
+    /**
116
+     * set the lastRun of $job to now
117
+     *
118
+     * @param IJob $job
119
+     * @since 7.0.0
120
+     */
121
+    public function setLastRun(IJob $job);
122 122
 
123
-	/**
124
-	 * set the run duration of $job
125
-	 *
126
-	 * @param IJob $job
127
-	 * @param $timeTaken
128
-	 * @since 12.0.0
129
-	 */
130
-	public function setExecutionTime(IJob $job, $timeTaken);
123
+    /**
124
+     * set the run duration of $job
125
+     *
126
+     * @param IJob $job
127
+     * @param $timeTaken
128
+     * @since 12.0.0
129
+     */
130
+    public function setExecutionTime(IJob $job, $timeTaken);
131 131
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php 2 patches
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -35,133 +35,133 @@
 block discarded – undo
35 35
  */
36 36
 class CalendarSearchReport implements XmlDeserializable {
37 37
 
38
-	/**
39
-	 * An array with requested properties.
40
-	 *
41
-	 * @var array
42
-	 */
43
-	public $properties;
44
-
45
-	/**
46
-	 * List of property/component filters.
47
-	 *
48
-	 * @var array
49
-	 */
50
-	public $filters;
51
-
52
-	/**
53
-	 * @var int
54
-	 */
55
-	public $limit;
56
-
57
-	/**
58
-	 * @var int
59
-	 */
60
-	public $offset;
61
-
62
-	/**
63
-	 * The deserialize method is called during xml parsing.
64
-	 *
65
-	 * This method is called statically, this is because in theory this method
66
-	 * may be used as a type of constructor, or factory method.
67
-	 *
68
-	 * Often you want to return an instance of the current class, but you are
69
-	 * free to return other data as well.
70
-	 *
71
-	 * You are responsible for advancing the reader to the next element. Not
72
-	 * doing anything will result in a never-ending loop.
73
-	 *
74
-	 * If you just want to skip parsing for this element altogether, you can
75
-	 * just call $reader->next();
76
-	 *
77
-	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
78
-	 * the next element.
79
-	 *
80
-	 * @param Reader $reader
81
-	 * @return mixed
82
-	 */
83
-	static function xmlDeserialize(Reader $reader) {
84
-		$elems = $reader->parseInnerTree([
85
-			'{http://nextcloud.com/ns}comp-filter'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter',
86
-			'{http://nextcloud.com/ns}prop-filter'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter',
87
-			'{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter',
88
-			'{http://nextcloud.com/ns}search-term'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter',
89
-			'{http://nextcloud.com/ns}limit'        => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter',
90
-			'{http://nextcloud.com/ns}offset'       => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter',
91
-			'{DAV:}prop'                            => 'Sabre\\Xml\\Element\\KeyValue',
92
-		]);
93
-
94
-		$newProps = [
95
-			'filters'    => [],
96
-			'properties' => [],
97
-			'limit'      => null,
98
-			'offset'     => null
99
-		];
100
-
101
-		if (!is_array($elems)) {
102
-			$elems = [];
103
-		}
104
-
105
-		foreach ($elems as $elem) {
106
-			switch ($elem['name']) {
107
-				case '{DAV:}prop':
108
-					$newProps['properties'] = array_keys($elem['value']);
109
-					break;
110
-				case '{' . SearchPlugin::NS_Nextcloud . '}filter':
111
-					foreach ($elem['value'] as $subElem) {
112
-						if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') {
113
-							if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) {
114
-								$newProps['filters']['comps'] = [];
115
-							}
116
-							$newProps['filters']['comps'][] = $subElem['value'];
117
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') {
118
-							if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) {
119
-								$newProps['filters']['props'] = [];
120
-							}
121
-							$newProps['filters']['props'][] = $subElem['value'];
122
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') {
123
-							if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) {
124
-								$newProps['filters']['params'] = [];
125
-							}
126
-							$newProps['filters']['params'][] = $subElem['value'];
127
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') {
128
-							$newProps['filters']['search-term'] = $subElem['value'];
129
-						}
130
-					}
131
-					break;
132
-				case '{' . SearchPlugin::NS_Nextcloud . '}limit':
133
-					$newProps['limit'] = $elem['value'];
134
-					break;
135
-				case '{' . SearchPlugin::NS_Nextcloud . '}offset':
136
-					$newProps['offset'] = $elem['value'];
137
-					break;
138
-
139
-			}
140
-		}
141
-
142
-		if (empty($newProps['filters'])) {
143
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request');
144
-		}
145
-
146
-		$propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params']));
147
-		$noCompsDefined = empty($newProps['filters']['comps']);
148
-		if ($propsOrParamsDefined && $noCompsDefined) {
149
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter');
150
-		}
151
-
152
-		if (!isset($newProps['filters']['search-term'])) {
153
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');
154
-		}
155
-
156
-		if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) {
157
-			throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request');
158
-		}
159
-
160
-
161
-		$obj = new self();
162
-		foreach ($newProps as $key => $value) {
163
-			$obj->$key = $value;
164
-		}
165
-		return $obj;
166
-	}
38
+    /**
39
+     * An array with requested properties.
40
+     *
41
+     * @var array
42
+     */
43
+    public $properties;
44
+
45
+    /**
46
+     * List of property/component filters.
47
+     *
48
+     * @var array
49
+     */
50
+    public $filters;
51
+
52
+    /**
53
+     * @var int
54
+     */
55
+    public $limit;
56
+
57
+    /**
58
+     * @var int
59
+     */
60
+    public $offset;
61
+
62
+    /**
63
+     * The deserialize method is called during xml parsing.
64
+     *
65
+     * This method is called statically, this is because in theory this method
66
+     * may be used as a type of constructor, or factory method.
67
+     *
68
+     * Often you want to return an instance of the current class, but you are
69
+     * free to return other data as well.
70
+     *
71
+     * You are responsible for advancing the reader to the next element. Not
72
+     * doing anything will result in a never-ending loop.
73
+     *
74
+     * If you just want to skip parsing for this element altogether, you can
75
+     * just call $reader->next();
76
+     *
77
+     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
78
+     * the next element.
79
+     *
80
+     * @param Reader $reader
81
+     * @return mixed
82
+     */
83
+    static function xmlDeserialize(Reader $reader) {
84
+        $elems = $reader->parseInnerTree([
85
+            '{http://nextcloud.com/ns}comp-filter'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter',
86
+            '{http://nextcloud.com/ns}prop-filter'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter',
87
+            '{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter',
88
+            '{http://nextcloud.com/ns}search-term'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter',
89
+            '{http://nextcloud.com/ns}limit'        => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter',
90
+            '{http://nextcloud.com/ns}offset'       => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter',
91
+            '{DAV:}prop'                            => 'Sabre\\Xml\\Element\\KeyValue',
92
+        ]);
93
+
94
+        $newProps = [
95
+            'filters'    => [],
96
+            'properties' => [],
97
+            'limit'      => null,
98
+            'offset'     => null
99
+        ];
100
+
101
+        if (!is_array($elems)) {
102
+            $elems = [];
103
+        }
104
+
105
+        foreach ($elems as $elem) {
106
+            switch ($elem['name']) {
107
+                case '{DAV:}prop':
108
+                    $newProps['properties'] = array_keys($elem['value']);
109
+                    break;
110
+                case '{' . SearchPlugin::NS_Nextcloud . '}filter':
111
+                    foreach ($elem['value'] as $subElem) {
112
+                        if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') {
113
+                            if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) {
114
+                                $newProps['filters']['comps'] = [];
115
+                            }
116
+                            $newProps['filters']['comps'][] = $subElem['value'];
117
+                        } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') {
118
+                            if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) {
119
+                                $newProps['filters']['props'] = [];
120
+                            }
121
+                            $newProps['filters']['props'][] = $subElem['value'];
122
+                        } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') {
123
+                            if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) {
124
+                                $newProps['filters']['params'] = [];
125
+                            }
126
+                            $newProps['filters']['params'][] = $subElem['value'];
127
+                        } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') {
128
+                            $newProps['filters']['search-term'] = $subElem['value'];
129
+                        }
130
+                    }
131
+                    break;
132
+                case '{' . SearchPlugin::NS_Nextcloud . '}limit':
133
+                    $newProps['limit'] = $elem['value'];
134
+                    break;
135
+                case '{' . SearchPlugin::NS_Nextcloud . '}offset':
136
+                    $newProps['offset'] = $elem['value'];
137
+                    break;
138
+
139
+            }
140
+        }
141
+
142
+        if (empty($newProps['filters'])) {
143
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request');
144
+        }
145
+
146
+        $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params']));
147
+        $noCompsDefined = empty($newProps['filters']['comps']);
148
+        if ($propsOrParamsDefined && $noCompsDefined) {
149
+            throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter');
150
+        }
151
+
152
+        if (!isset($newProps['filters']['search-term'])) {
153
+            throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');
154
+        }
155
+
156
+        if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) {
157
+            throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request');
158
+        }
159
+
160
+
161
+        $obj = new self();
162
+        foreach ($newProps as $key => $value) {
163
+            $obj->$key = $value;
164
+        }
165
+        return $obj;
166
+    }
167 167
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -107,32 +107,32 @@  discard block
 block discarded – undo
107 107
 				case '{DAV:}prop':
108 108
 					$newProps['properties'] = array_keys($elem['value']);
109 109
 					break;
110
-				case '{' . SearchPlugin::NS_Nextcloud . '}filter':
110
+				case '{'.SearchPlugin::NS_Nextcloud.'}filter':
111 111
 					foreach ($elem['value'] as $subElem) {
112
-						if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') {
112
+						if ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}comp-filter') {
113 113
 							if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) {
114 114
 								$newProps['filters']['comps'] = [];
115 115
 							}
116 116
 							$newProps['filters']['comps'][] = $subElem['value'];
117
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') {
117
+						} elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}prop-filter') {
118 118
 							if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) {
119 119
 								$newProps['filters']['props'] = [];
120 120
 							}
121 121
 							$newProps['filters']['props'][] = $subElem['value'];
122
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') {
122
+						} elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}param-filter') {
123 123
 							if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) {
124 124
 								$newProps['filters']['params'] = [];
125 125
 							}
126 126
 							$newProps['filters']['params'][] = $subElem['value'];
127
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') {
127
+						} elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}search-term') {
128 128
 							$newProps['filters']['search-term'] = $subElem['value'];
129 129
 						}
130 130
 					}
131 131
 					break;
132
-				case '{' . SearchPlugin::NS_Nextcloud . '}limit':
132
+				case '{'.SearchPlugin::NS_Nextcloud.'}limit':
133 133
 					$newProps['limit'] = $elem['value'];
134 134
 					break;
135
-				case '{' . SearchPlugin::NS_Nextcloud . '}offset':
135
+				case '{'.SearchPlugin::NS_Nextcloud.'}offset':
136 136
 					$newProps['offset'] = $elem['value'];
137 137
 					break;
138 138
 
@@ -140,21 +140,21 @@  discard block
 block discarded – undo
140 140
 		}
141 141
 
142 142
 		if (empty($newProps['filters'])) {
143
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request');
143
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}filter element is required for this request');
144 144
 		}
145 145
 
146 146
 		$propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params']));
147 147
 		$noCompsDefined = empty($newProps['filters']['comps']);
148 148
 		if ($propsOrParamsDefined && $noCompsDefined) {
149
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter');
149
+			throw new BadRequest('{'.SearchPlugin::NS_Nextcloud.'}prop-filter or {'.SearchPlugin::NS_Nextcloud.'}param-filter given without any {'.SearchPlugin::NS_Nextcloud.'}comp-filter');
150 150
 		}
151 151
 
152 152
 		if (!isset($newProps['filters']['search-term'])) {
153
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');
153
+			throw new BadRequest('{'.SearchPlugin::NS_Nextcloud.'}search-term is required for this request');
154 154
 		}
155 155
 
156 156
 		if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) {
157
-			throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request');
157
+			throw new BadRequest('At least one{'.SearchPlugin::NS_Nextcloud.'}prop-filter or {'.SearchPlugin::NS_Nextcloud.'}param-filter is required for this request');
158 158
 		}
159 159
 
160 160
 
Please login to merge, or discard this patch.
lib/private/App/AppStore/Bundles/CoreBundle.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,20 +23,20 @@
 block discarded – undo
23 23
 
24 24
 class CoreBundle extends Bundle {
25 25
 
26
-	/**
27
-	 * {@inheritDoc}
28
-	 */
29
-	public function getName() {
30
-		return 'Core bundle';
31
-	}
26
+    /**
27
+     * {@inheritDoc}
28
+     */
29
+    public function getName() {
30
+        return 'Core bundle';
31
+    }
32 32
 
33
-	/**
34
-	 * {@inheritDoc}
35
-	 */
36
-	public function getAppIdentifiers() {
37
-		return [
38
-			'bruteforcesettings',
39
-		];
40
-	}
33
+    /**
34
+     * {@inheritDoc}
35
+     */
36
+    public function getAppIdentifiers() {
37
+        return [
38
+            'bruteforcesettings',
39
+        ];
40
+    }
41 41
 
42 42
 }
Please login to merge, or discard this patch.
lib/private/App/AppStore/Bundles/GroupwareBundle.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 	 * {@inheritDoc}
28 28
 	 */
29 29
 	public function getName() {
30
-		return (string)$this->l10n->t('Groupware bundle');
30
+		return (string) $this->l10n->t('Groupware bundle');
31 31
 	}
32 32
 
33 33
 	/**
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -25,23 +25,23 @@
 block discarded – undo
25 25
 
26 26
 class GroupwareBundle extends Bundle {
27 27
 
28
-	/**
29
-	 * {@inheritDoc}
30
-	 */
31
-	public function getName() {
32
-		return (string)$this->l10n->t('Groupware bundle');
33
-	}
28
+    /**
29
+     * {@inheritDoc}
30
+     */
31
+    public function getName() {
32
+        return (string)$this->l10n->t('Groupware bundle');
33
+    }
34 34
 
35
-	/**
36
-	 * {@inheritDoc}
37
-	 */
38
-	public function getAppIdentifiers() {
39
-		return [
40
-			'calendar',
41
-			'contacts',
42
-			'deck',
43
-			'mail'
44
-		];
45
-	}
35
+    /**
36
+     * {@inheritDoc}
37
+     */
38
+    public function getAppIdentifiers() {
39
+        return [
40
+            'calendar',
41
+            'contacts',
42
+            'deck',
43
+            'mail'
44
+        ];
45
+    }
46 46
 
47 47
 }
Please login to merge, or discard this patch.
lib/private/App/AppStore/Bundles/Bundle.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -24,36 +24,36 @@
 block discarded – undo
24 24
 use OCP\IL10N;
25 25
 
26 26
 abstract class Bundle {
27
-	/** @var IL10N */
28
-	protected $l10n;
27
+    /** @var IL10N */
28
+    protected $l10n;
29 29
 
30
-	/**
31
-	 * @param IL10N $l10n
32
-	 */
33
-	public function __construct(IL10N $l10n) {
34
-		$this->l10n = $l10n;
35
-	}
30
+    /**
31
+     * @param IL10N $l10n
32
+     */
33
+    public function __construct(IL10N $l10n) {
34
+        $this->l10n = $l10n;
35
+    }
36 36
 
37
-	/**
38
-	 * Get the identifier of the bundle
39
-	 *
40
-	 * @return string
41
-	 */
42
-	public final function getIdentifier() {
43
-		return substr(strrchr(get_class($this), '\\'), 1);
44
-	}
37
+    /**
38
+     * Get the identifier of the bundle
39
+     *
40
+     * @return string
41
+     */
42
+    public final function getIdentifier() {
43
+        return substr(strrchr(get_class($this), '\\'), 1);
44
+    }
45 45
 
46
-	/**
47
-	 * Get the name of the bundle
48
-	 *
49
-	 * @return string
50
-	 */
51
-	public abstract function getName();
46
+    /**
47
+     * Get the name of the bundle
48
+     *
49
+     * @return string
50
+     */
51
+    public abstract function getName();
52 52
 
53
-	/**
54
-	 * Get the list of app identifiers in the bundle
55
-	 *
56
-	 * @return array
57
-	 */
58
-	public abstract function getAppIdentifiers();
53
+    /**
54
+     * Get the list of app identifiers in the bundle
55
+     *
56
+     * @return array
57
+     */
58
+    public abstract function getAppIdentifiers();
59 59
 }
Please login to merge, or discard this patch.
core/Command/Db/ConvertMysqlToMB4.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -34,59 +34,59 @@
 block discarded – undo
34 34
 use Symfony\Component\Console\Output\OutputInterface;
35 35
 
36 36
 class ConvertMysqlToMB4 extends Command {
37
-	/** @var IConfig */
38
-	private $config;
37
+    /** @var IConfig */
38
+    private $config;
39 39
 
40
-	/** @var IDBConnection */
41
-	private $connection;
40
+    /** @var IDBConnection */
41
+    private $connection;
42 42
 
43
-	/** @var IURLGenerator */
44
-	private $urlGenerator;
43
+    /** @var IURLGenerator */
44
+    private $urlGenerator;
45 45
 
46
-	/** @var ILogger */
47
-	private $logger;
46
+    /** @var ILogger */
47
+    private $logger;
48 48
 
49
-	/**
50
-	 * @param IConfig $config
51
-	 * @param IDBConnection $connection
52
-	 * @param IURLGenerator $urlGenerator
53
-	 * @param ILogger $logger
54
-	 */
55
-	public function __construct(IConfig $config, IDBConnection $connection, IURLGenerator $urlGenerator, ILogger $logger) {
56
-		$this->config = $config;
57
-		$this->connection = $connection;
58
-		$this->urlGenerator = $urlGenerator;
59
-		$this->logger = $logger;
60
-		parent::__construct();
61
-	}
49
+    /**
50
+     * @param IConfig $config
51
+     * @param IDBConnection $connection
52
+     * @param IURLGenerator $urlGenerator
53
+     * @param ILogger $logger
54
+     */
55
+    public function __construct(IConfig $config, IDBConnection $connection, IURLGenerator $urlGenerator, ILogger $logger) {
56
+        $this->config = $config;
57
+        $this->connection = $connection;
58
+        $this->urlGenerator = $urlGenerator;
59
+        $this->logger = $logger;
60
+        parent::__construct();
61
+    }
62 62
 
63
-	protected function configure() {
64
-		$this
65
-			->setName('db:convert-mysql-charset')
66
-			->setDescription('Convert charset of MySQL/MariaDB to use utf8mb4');
67
-	}
63
+    protected function configure() {
64
+        $this
65
+            ->setName('db:convert-mysql-charset')
66
+            ->setDescription('Convert charset of MySQL/MariaDB to use utf8mb4');
67
+    }
68 68
 
69
-	protected function execute(InputInterface $input, OutputInterface $output) {
70
-		if (!$this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
71
-			$output->writeln("This command is only valid for MySQL/MariaDB databases.");
72
-			return 1;
73
-		}
69
+    protected function execute(InputInterface $input, OutputInterface $output) {
70
+        if (!$this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
71
+            $output->writeln("This command is only valid for MySQL/MariaDB databases.");
72
+            return 1;
73
+        }
74 74
 
75
-		$tools = new MySqlTools();
76
-		if (!$tools->supports4ByteCharset($this->connection)) {
77
-			$url = $this->urlGenerator->linkToDocs('admin-mysql-utf8mb4');
78
-			$output->writeln("The database is not properly setup to use the charset utf8mb4.");
79
-			$output->writeln("For more information please read the documentation at $url");
80
-			return 1;
81
-		}
75
+        $tools = new MySqlTools();
76
+        if (!$tools->supports4ByteCharset($this->connection)) {
77
+            $url = $this->urlGenerator->linkToDocs('admin-mysql-utf8mb4');
78
+            $output->writeln("The database is not properly setup to use the charset utf8mb4.");
79
+            $output->writeln("For more information please read the documentation at $url");
80
+            return 1;
81
+        }
82 82
 
83
-		// enable charset
84
-		$this->config->setSystemValue('mysql.utf8mb4', true);
83
+        // enable charset
84
+        $this->config->setSystemValue('mysql.utf8mb4', true);
85 85
 
86
-		// run conversion
87
-		$coll = new Collation($this->config, $this->logger, $this->connection, false);
88
-		$coll->run(new ConsoleOutput($output));
86
+        // run conversion
87
+        $coll = new Collation($this->config, $this->logger, $this->connection, false);
88
+        $coll->run(new ConsoleOutput($output));
89 89
 
90
-		return 0;
91
-	}
90
+        return 0;
91
+    }
92 92
 }
Please login to merge, or discard this patch.
lib/public/Diagnostics/IEventLogger.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -35,55 +35,55 @@
 block discarded – undo
35 35
  * @since 8.0.0
36 36
  */
37 37
 interface IEventLogger {
38
-	/**
39
-	 * Mark the start of an event setting its ID $id and providing event description $description.
40
-	 *
41
-	 * @param string $id
42
-	 * @param string $description
43
-	 * @since 8.0.0
44
-	 */
45
-	public function start($id, $description);
38
+    /**
39
+     * Mark the start of an event setting its ID $id and providing event description $description.
40
+     *
41
+     * @param string $id
42
+     * @param string $description
43
+     * @since 8.0.0
44
+     */
45
+    public function start($id, $description);
46 46
 
47
-	/**
48
-	 * Mark the end of an event with specific ID $id, marked by start() method.
49
-	 * Ending event should store \OCP\Diagnostics\IEvent to
50
-	 * be returned with getEvents() method.
51
-	 *
52
-	 * @param string $id
53
-	 * @since 8.0.0
54
-	 */
55
-	public function end($id);
47
+    /**
48
+     * Mark the end of an event with specific ID $id, marked by start() method.
49
+     * Ending event should store \OCP\Diagnostics\IEvent to
50
+     * be returned with getEvents() method.
51
+     *
52
+     * @param string $id
53
+     * @since 8.0.0
54
+     */
55
+    public function end($id);
56 56
 
57
-	/**
58
-	 * Mark the start and the end of an event with specific ID $id and description $description,
59
-	 * explicitly marking start and end of the event, represented by $start and $end timestamps.
60
-	 * Logging event should store \OCP\Diagnostics\IEvent to
61
-	 * be returned with getEvents() method.
62
-	 *
63
-	 * @param string $id
64
-	 * @param string $description
65
-	 * @param float $start
66
-	 * @param float $end
67
-	 * @since 8.0.0
68
-	 */
69
-	public function log($id, $description, $start, $end);
57
+    /**
58
+     * Mark the start and the end of an event with specific ID $id and description $description,
59
+     * explicitly marking start and end of the event, represented by $start and $end timestamps.
60
+     * Logging event should store \OCP\Diagnostics\IEvent to
61
+     * be returned with getEvents() method.
62
+     *
63
+     * @param string $id
64
+     * @param string $description
65
+     * @param float $start
66
+     * @param float $end
67
+     * @since 8.0.0
68
+     */
69
+    public function log($id, $description, $start, $end);
70 70
 
71
-	/**
72
-	 * This method should return all \OCP\Diagnostics\IEvent objects stored using
73
-	 * start()/end() or log() methods
74
-	 *
75
-	 * @return \OCP\Diagnostics\IEvent[]
76
-	 * @since 8.0.0
77
-	 */
78
-	public function getEvents();
71
+    /**
72
+     * This method should return all \OCP\Diagnostics\IEvent objects stored using
73
+     * start()/end() or log() methods
74
+     *
75
+     * @return \OCP\Diagnostics\IEvent[]
76
+     * @since 8.0.0
77
+     */
78
+    public function getEvents();
79 79
 
80
-	/**
81
-	 * Activate the module for the duration of the request. Deactivated module
82
-	 * does not create and store \OCP\Diagnostics\IEvent objects.
83
-	 * Only activated module should create and store objects to be
84
-	 * returned with getEvents() call.
85
-	 *
86
-	 * @since 12.0.0
87
-	 */
88
-	public function activate();
80
+    /**
81
+     * Activate the module for the duration of the request. Deactivated module
82
+     * does not create and store \OCP\Diagnostics\IEvent objects.
83
+     * Only activated module should create and store objects to be
84
+     * returned with getEvents() call.
85
+     *
86
+     * @since 12.0.0
87
+     */
88
+    public function activate();
89 89
 }
Please login to merge, or discard this patch.
lib/public/Diagnostics/IQuery.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -30,38 +30,38 @@
 block discarded – undo
30 30
  * @since 8.0.0
31 31
  */
32 32
 interface IQuery {
33
-	/**
34
-	 * @return string
35
-	 * @since 8.0.0
36
-	 */
37
-	public function getSql();
33
+    /**
34
+     * @return string
35
+     * @since 8.0.0
36
+     */
37
+    public function getSql();
38 38
 
39
-	/**
40
-	 * @return array
41
-	 * @since 8.0.0
42
-	 */
43
-	public function getParams();
39
+    /**
40
+     * @return array
41
+     * @since 8.0.0
42
+     */
43
+    public function getParams();
44 44
 
45
-	/**
46
-	 * @return float
47
-	 * @since 8.0.0
48
-	 */
49
-	public function getDuration();
45
+    /**
46
+     * @return float
47
+     * @since 8.0.0
48
+     */
49
+    public function getDuration();
50 50
 
51
-	/**
52
-	 * @return float
53
-	 * @since 11.0.0
54
-	 */
55
-	public function getStartTime();
51
+    /**
52
+     * @return float
53
+     * @since 11.0.0
54
+     */
55
+    public function getStartTime();
56 56
 
57
-	/**
58
-	 * @return array
59
-	 * @since 11.0.0
60
-	 */
61
-	public function getStacktrace();
62
-	/**
63
-	 * @return array
64
-	 * @since 12.0.0
65
-	 */
66
-	public function getStart();
57
+    /**
58
+     * @return array
59
+     * @since 11.0.0
60
+     */
61
+    public function getStacktrace();
62
+    /**
63
+     * @return array
64
+     * @since 12.0.0
65
+     */
66
+    public function getStart();
67 67
 }
Please login to merge, or discard this patch.
lib/private/DB/Connection.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 			return parent::connect();
59 59
 		} catch (DBALException $e) {
60 60
 			// throw a new exception to prevent leaking info from the stacktrace
61
-			throw new DBALException('Failed to connect to the database: ' . $e->getMessage(), $e->getCode());
61
+			throw new DBALException('Failed to connect to the database: '.$e->getMessage(), $e->getCode());
62 62
 		}
63 63
 	}
64 64
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 		// 0 is the method where we use `getCallerBacktrace`
111 111
 		// 1 is the target method which uses the method we want to log
112 112
 		if (isset($traces[1])) {
113
-			return $traces[1]['file'] . ':' . $traces[1]['line'];
113
+			return $traces[1]['file'].':'.$traces[1]['line'];
114 114
 		}
115 115
 
116 116
 		return '';
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * @param int $offset
157 157
 	 * @return \Doctrine\DBAL\Driver\Statement The prepared statement.
158 158
 	 */
159
-	public function prepare( $statement, $limit=null, $offset=null ) {
159
+	public function prepare($statement, $limit = null, $offset = null) {
160 160
 		if ($limit === -1) {
161 161
 			$limit = null;
162 162
 		}
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 			throw new \BadMethodCallException('Can not lock a new table until the previous lock is released.');
322 322
 		}
323 323
 
324
-		$tableName = $this->tablePrefix . $tableName;
324
+		$tableName = $this->tablePrefix.$tableName;
325 325
 		$this->lockedTable = $tableName;
326 326
 		$this->adapter->lockTable($tableName);
327 327
 	}
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
 	 * @return string
343 343
 	 */
344 344
 	public function getError() {
345
-		$msg = $this->errorCode() . ': ';
345
+		$msg = $this->errorCode().': ';
346 346
 		$errorInfo = $this->errorInfo();
347 347
 		if (is_array($errorInfo)) {
348
-			$msg .= 'SQLSTATE = '.$errorInfo[0] . ', ';
349
-			$msg .= 'Driver Code = '.$errorInfo[1] . ', ';
348
+			$msg .= 'SQLSTATE = '.$errorInfo[0].', ';
349
+			$msg .= 'Driver Code = '.$errorInfo[1].', ';
350 350
 			$msg .= 'Driver Message = '.$errorInfo[2];
351 351
 		}
352 352
 		return $msg;
@@ -358,9 +358,9 @@  discard block
 block discarded – undo
358 358
 	 * @param string $table table name without the prefix
359 359
 	 */
360 360
 	public function dropTable($table) {
361
-		$table = $this->tablePrefix . trim($table);
361
+		$table = $this->tablePrefix.trim($table);
362 362
 		$schema = $this->getSchemaManager();
363
-		if($schema->tablesExist(array($table))) {
363
+		if ($schema->tablesExist(array($table))) {
364 364
 			$schema->dropTable($table);
365 365
 		}
366 366
 	}
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 	 * @param string $table table name without the prefix
372 372
 	 * @return bool
373 373
 	 */
374
-	public function tableExists($table){
375
-		$table = $this->tablePrefix . trim($table);
374
+	public function tableExists($table) {
375
+		$table = $this->tablePrefix.trim($table);
376 376
 		$schema = $this->getSchemaManager();
377 377
 		return $schema->tablesExist(array($table));
378 378
 	}
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 * @return string
384 384
 	 */
385 385
 	protected function replaceTablePrefix($statement) {
386
-		return str_replace( '*PREFIX*', $this->tablePrefix, $statement );
386
+		return str_replace('*PREFIX*', $this->tablePrefix, $statement);
387 387
 	}
388 388
 
389 389
 	/**
Please login to merge, or discard this patch.
Indentation   +406 added lines, -406 removed lines patch added patch discarded remove patch
@@ -48,410 +48,410 @@
 block discarded – undo
48 48
 use OCP\PreConditionNotMetException;
49 49
 
50 50
 class Connection extends ReconnectWrapper implements IDBConnection {
51
-	/**
52
-	 * @var string $tablePrefix
53
-	 */
54
-	protected $tablePrefix;
55
-
56
-	/**
57
-	 * @var \OC\DB\Adapter $adapter
58
-	 */
59
-	protected $adapter;
60
-
61
-	protected $lockedTable = null;
62
-
63
-	public function connect() {
64
-		try {
65
-			return parent::connect();
66
-		} catch (DBALException $e) {
67
-			// throw a new exception to prevent leaking info from the stacktrace
68
-			throw new DBALException('Failed to connect to the database: ' . $e->getMessage(), $e->getCode());
69
-		}
70
-	}
71
-
72
-	/**
73
-	 * Returns a QueryBuilder for the connection.
74
-	 *
75
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder
76
-	 */
77
-	public function getQueryBuilder() {
78
-		return new QueryBuilder(
79
-			$this,
80
-			\OC::$server->getSystemConfig(),
81
-			\OC::$server->getLogger()
82
-		);
83
-	}
84
-
85
-	/**
86
-	 * Gets the QueryBuilder for the connection.
87
-	 *
88
-	 * @return \Doctrine\DBAL\Query\QueryBuilder
89
-	 * @deprecated please use $this->getQueryBuilder() instead
90
-	 */
91
-	public function createQueryBuilder() {
92
-		$backtrace = $this->getCallerBacktrace();
93
-		\OC::$server->getLogger()->debug('Doctrine QueryBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]);
94
-		return parent::createQueryBuilder();
95
-	}
96
-
97
-	/**
98
-	 * Gets the ExpressionBuilder for the connection.
99
-	 *
100
-	 * @return \Doctrine\DBAL\Query\Expression\ExpressionBuilder
101
-	 * @deprecated please use $this->getQueryBuilder()->expr() instead
102
-	 */
103
-	public function getExpressionBuilder() {
104
-		$backtrace = $this->getCallerBacktrace();
105
-		\OC::$server->getLogger()->debug('Doctrine ExpressionBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]);
106
-		return parent::getExpressionBuilder();
107
-	}
108
-
109
-	/**
110
-	 * Get the file and line that called the method where `getCallerBacktrace()` was used
111
-	 *
112
-	 * @return string
113
-	 */
114
-	protected function getCallerBacktrace() {
115
-		$traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
116
-
117
-		// 0 is the method where we use `getCallerBacktrace`
118
-		// 1 is the target method which uses the method we want to log
119
-		if (isset($traces[1])) {
120
-			return $traces[1]['file'] . ':' . $traces[1]['line'];
121
-		}
122
-
123
-		return '';
124
-	}
125
-
126
-	/**
127
-	 * @return string
128
-	 */
129
-	public function getPrefix() {
130
-		return $this->tablePrefix;
131
-	}
132
-
133
-	/**
134
-	 * Initializes a new instance of the Connection class.
135
-	 *
136
-	 * @param array $params  The connection parameters.
137
-	 * @param \Doctrine\DBAL\Driver $driver
138
-	 * @param \Doctrine\DBAL\Configuration $config
139
-	 * @param \Doctrine\Common\EventManager $eventManager
140
-	 * @throws \Exception
141
-	 */
142
-	public function __construct(array $params, Driver $driver, Configuration $config = null,
143
-		EventManager $eventManager = null)
144
-	{
145
-		if (!isset($params['adapter'])) {
146
-			throw new \Exception('adapter not set');
147
-		}
148
-		if (!isset($params['tablePrefix'])) {
149
-			throw new \Exception('tablePrefix not set');
150
-		}
151
-		parent::__construct($params, $driver, $config, $eventManager);
152
-		$this->adapter = new $params['adapter']($this);
153
-		$this->tablePrefix = $params['tablePrefix'];
154
-	}
155
-
156
-	/**
157
-	 * Prepares an SQL statement.
158
-	 *
159
-	 * @param string $statement The SQL statement to prepare.
160
-	 * @param int $limit
161
-	 * @param int $offset
162
-	 * @return \Doctrine\DBAL\Driver\Statement The prepared statement.
163
-	 */
164
-	public function prepare( $statement, $limit=null, $offset=null ) {
165
-		if ($limit === -1) {
166
-			$limit = null;
167
-		}
168
-		if (!is_null($limit)) {
169
-			$platform = $this->getDatabasePlatform();
170
-			$statement = $platform->modifyLimitQuery($statement, $limit, $offset);
171
-		}
172
-		$statement = $this->replaceTablePrefix($statement);
173
-		$statement = $this->adapter->fixupStatement($statement);
174
-
175
-		return parent::prepare($statement);
176
-	}
177
-
178
-	/**
179
-	 * Executes an, optionally parametrized, SQL query.
180
-	 *
181
-	 * If the query is parametrized, a prepared statement is used.
182
-	 * If an SQLLogger is configured, the execution is logged.
183
-	 *
184
-	 * @param string                                      $query  The SQL query to execute.
185
-	 * @param array                                       $params The parameters to bind to the query, if any.
186
-	 * @param array                                       $types  The types the previous parameters are in.
187
-	 * @param \Doctrine\DBAL\Cache\QueryCacheProfile|null $qcp    The query cache profile, optional.
188
-	 *
189
-	 * @return \Doctrine\DBAL\Driver\Statement The executed statement.
190
-	 *
191
-	 * @throws \Doctrine\DBAL\DBALException
192
-	 */
193
-	public function executeQuery($query, array $params = array(), $types = array(), QueryCacheProfile $qcp = null)
194
-	{
195
-		$query = $this->replaceTablePrefix($query);
196
-		$query = $this->adapter->fixupStatement($query);
197
-		return parent::executeQuery($query, $params, $types, $qcp);
198
-	}
199
-
200
-	/**
201
-	 * Executes an SQL INSERT/UPDATE/DELETE query with the given parameters
202
-	 * and returns the number of affected rows.
203
-	 *
204
-	 * This method supports PDO binding types as well as DBAL mapping types.
205
-	 *
206
-	 * @param string $query  The SQL query.
207
-	 * @param array  $params The query parameters.
208
-	 * @param array  $types  The parameter types.
209
-	 *
210
-	 * @return integer The number of affected rows.
211
-	 *
212
-	 * @throws \Doctrine\DBAL\DBALException
213
-	 */
214
-	public function executeUpdate($query, array $params = array(), array $types = array())
215
-	{
216
-		$query = $this->replaceTablePrefix($query);
217
-		$query = $this->adapter->fixupStatement($query);
218
-		return parent::executeUpdate($query, $params, $types);
219
-	}
220
-
221
-	/**
222
-	 * Returns the ID of the last inserted row, or the last value from a sequence object,
223
-	 * depending on the underlying driver.
224
-	 *
225
-	 * Note: This method may not return a meaningful or consistent result across different drivers,
226
-	 * because the underlying database may not even support the notion of AUTO_INCREMENT/IDENTITY
227
-	 * columns or sequences.
228
-	 *
229
-	 * @param string $seqName Name of the sequence object from which the ID should be returned.
230
-	 * @return string A string representation of the last inserted ID.
231
-	 */
232
-	public function lastInsertId($seqName = null) {
233
-		if ($seqName) {
234
-			$seqName = $this->replaceTablePrefix($seqName);
235
-		}
236
-		return $this->adapter->lastInsertId($seqName);
237
-	}
238
-
239
-	// internal use
240
-	public function realLastInsertId($seqName = null) {
241
-		return parent::lastInsertId($seqName);
242
-	}
243
-
244
-	/**
245
-	 * Insert a row if the matching row does not exists. To accomplish proper race condition avoidance
246
-	 * it is needed that there is also a unique constraint on the values. Then this method will
247
-	 * catch the exception and return 0.
248
-	 *
249
-	 * @param string $table The table name (will replace *PREFIX* with the actual prefix)
250
-	 * @param array $input data that should be inserted into the table  (column name => value)
251
-	 * @param array|null $compare List of values that should be checked for "if not exists"
252
-	 *				If this is null or an empty array, all keys of $input will be compared
253
-	 *				Please note: text fields (clob) must not be used in the compare array
254
-	 * @return int number of inserted rows
255
-	 * @throws \Doctrine\DBAL\DBALException
256
-	 * @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
257
-	 */
258
-	public function insertIfNotExist($table, $input, array $compare = null) {
259
-		return $this->adapter->insertIfNotExist($table, $input, $compare);
260
-	}
261
-
262
-	public function insertIgnoreConflict(string $table, array $values) : int {
263
-		return $this->adapter->insertIgnoreConflict($table, $values);
264
-	}
265
-
266
-	private function getType($value) {
267
-		if (is_bool($value)) {
268
-			return IQueryBuilder::PARAM_BOOL;
269
-		} else if (is_int($value)) {
270
-			return IQueryBuilder::PARAM_INT;
271
-		} else {
272
-			return IQueryBuilder::PARAM_STR;
273
-		}
274
-	}
275
-
276
-	/**
277
-	 * Insert or update a row value
278
-	 *
279
-	 * @param string $table
280
-	 * @param array $keys (column name => value)
281
-	 * @param array $values (column name => value)
282
-	 * @param array $updatePreconditionValues ensure values match preconditions (column name => value)
283
-	 * @return int number of new rows
284
-	 * @throws \Doctrine\DBAL\DBALException
285
-	 * @throws PreConditionNotMetException
286
-	 * @suppress SqlInjectionChecker
287
-	 */
288
-	public function setValues($table, array $keys, array $values, array $updatePreconditionValues = []) {
289
-		try {
290
-			$insertQb = $this->getQueryBuilder();
291
-			$insertQb->insert($table)
292
-				->values(
293
-					array_map(function($value) use ($insertQb) {
294
-						return $insertQb->createNamedParameter($value, $this->getType($value));
295
-					}, array_merge($keys, $values))
296
-				);
297
-			return $insertQb->execute();
298
-		} catch (ConstraintViolationException $e) {
299
-			// value already exists, try update
300
-			$updateQb = $this->getQueryBuilder();
301
-			$updateQb->update($table);
302
-			foreach ($values as $name => $value) {
303
-				$updateQb->set($name, $updateQb->createNamedParameter($value, $this->getType($value)));
304
-			}
305
-			$where = $updateQb->expr()->andX();
306
-			$whereValues = array_merge($keys, $updatePreconditionValues);
307
-			foreach ($whereValues as $name => $value) {
308
-				$where->add($updateQb->expr()->eq(
309
-					$name,
310
-					$updateQb->createNamedParameter($value, $this->getType($value)),
311
-					$this->getType($value)
312
-				));
313
-			}
314
-			$updateQb->where($where);
315
-			$affected = $updateQb->execute();
316
-
317
-			if ($affected === 0 && !empty($updatePreconditionValues)) {
318
-				throw new PreConditionNotMetException();
319
-			}
320
-
321
-			return 0;
322
-		}
323
-	}
324
-
325
-	/**
326
-	 * Create an exclusive read+write lock on a table
327
-	 *
328
-	 * @param string $tableName
329
-	 * @throws \BadMethodCallException When trying to acquire a second lock
330
-	 * @since 9.1.0
331
-	 */
332
-	public function lockTable($tableName) {
333
-		if ($this->lockedTable !== null) {
334
-			throw new \BadMethodCallException('Can not lock a new table until the previous lock is released.');
335
-		}
336
-
337
-		$tableName = $this->tablePrefix . $tableName;
338
-		$this->lockedTable = $tableName;
339
-		$this->adapter->lockTable($tableName);
340
-	}
341
-
342
-	/**
343
-	 * Release a previous acquired lock again
344
-	 *
345
-	 * @since 9.1.0
346
-	 */
347
-	public function unlockTable() {
348
-		$this->adapter->unlockTable();
349
-		$this->lockedTable = null;
350
-	}
351
-
352
-	/**
353
-	 * returns the error code and message as a string for logging
354
-	 * works with DoctrineException
355
-	 * @return string
356
-	 */
357
-	public function getError() {
358
-		$msg = $this->errorCode() . ': ';
359
-		$errorInfo = $this->errorInfo();
360
-		if (is_array($errorInfo)) {
361
-			$msg .= 'SQLSTATE = '.$errorInfo[0] . ', ';
362
-			$msg .= 'Driver Code = '.$errorInfo[1] . ', ';
363
-			$msg .= 'Driver Message = '.$errorInfo[2];
364
-		}
365
-		return $msg;
366
-	}
367
-
368
-	/**
369
-	 * Drop a table from the database if it exists
370
-	 *
371
-	 * @param string $table table name without the prefix
372
-	 */
373
-	public function dropTable($table) {
374
-		$table = $this->tablePrefix . trim($table);
375
-		$schema = $this->getSchemaManager();
376
-		if($schema->tablesExist(array($table))) {
377
-			$schema->dropTable($table);
378
-		}
379
-	}
380
-
381
-	/**
382
-	 * Check if a table exists
383
-	 *
384
-	 * @param string $table table name without the prefix
385
-	 * @return bool
386
-	 */
387
-	public function tableExists($table){
388
-		$table = $this->tablePrefix . trim($table);
389
-		$schema = $this->getSchemaManager();
390
-		return $schema->tablesExist(array($table));
391
-	}
392
-
393
-	// internal use
394
-	/**
395
-	 * @param string $statement
396
-	 * @return string
397
-	 */
398
-	protected function replaceTablePrefix($statement) {
399
-		return str_replace( '*PREFIX*', $this->tablePrefix, $statement );
400
-	}
401
-
402
-	/**
403
-	 * Check if a transaction is active
404
-	 *
405
-	 * @return bool
406
-	 * @since 8.2.0
407
-	 */
408
-	public function inTransaction() {
409
-		return $this->getTransactionNestingLevel() > 0;
410
-	}
411
-
412
-	/**
413
-	 * Escape a parameter to be used in a LIKE query
414
-	 *
415
-	 * @param string $param
416
-	 * @return string
417
-	 */
418
-	public function escapeLikeParameter($param) {
419
-		return addcslashes($param, '\\_%');
420
-	}
421
-
422
-	/**
423
-	 * Check whether or not the current database support 4byte wide unicode
424
-	 *
425
-	 * @return bool
426
-	 * @since 11.0.0
427
-	 */
428
-	public function supports4ByteText() {
429
-		if (!$this->getDatabasePlatform() instanceof MySqlPlatform) {
430
-			return true;
431
-		}
432
-		return $this->getParams()['charset'] === 'utf8mb4';
433
-	}
434
-
435
-
436
-	/**
437
-	 * Create the schema of the connected database
438
-	 *
439
-	 * @return Schema
440
-	 */
441
-	public function createSchema() {
442
-		$schemaManager = new MDB2SchemaManager($this);
443
-		$migrator = $schemaManager->getMigrator();
444
-		return $migrator->createSchema();
445
-	}
446
-
447
-	/**
448
-	 * Migrate the database to the given schema
449
-	 *
450
-	 * @param Schema $toSchema
451
-	 */
452
-	public function migrateToSchema(Schema $toSchema) {
453
-		$schemaManager = new MDB2SchemaManager($this);
454
-		$migrator = $schemaManager->getMigrator();
455
-		$migrator->migrate($toSchema);
456
-	}
51
+    /**
52
+     * @var string $tablePrefix
53
+     */
54
+    protected $tablePrefix;
55
+
56
+    /**
57
+     * @var \OC\DB\Adapter $adapter
58
+     */
59
+    protected $adapter;
60
+
61
+    protected $lockedTable = null;
62
+
63
+    public function connect() {
64
+        try {
65
+            return parent::connect();
66
+        } catch (DBALException $e) {
67
+            // throw a new exception to prevent leaking info from the stacktrace
68
+            throw new DBALException('Failed to connect to the database: ' . $e->getMessage(), $e->getCode());
69
+        }
70
+    }
71
+
72
+    /**
73
+     * Returns a QueryBuilder for the connection.
74
+     *
75
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder
76
+     */
77
+    public function getQueryBuilder() {
78
+        return new QueryBuilder(
79
+            $this,
80
+            \OC::$server->getSystemConfig(),
81
+            \OC::$server->getLogger()
82
+        );
83
+    }
84
+
85
+    /**
86
+     * Gets the QueryBuilder for the connection.
87
+     *
88
+     * @return \Doctrine\DBAL\Query\QueryBuilder
89
+     * @deprecated please use $this->getQueryBuilder() instead
90
+     */
91
+    public function createQueryBuilder() {
92
+        $backtrace = $this->getCallerBacktrace();
93
+        \OC::$server->getLogger()->debug('Doctrine QueryBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]);
94
+        return parent::createQueryBuilder();
95
+    }
96
+
97
+    /**
98
+     * Gets the ExpressionBuilder for the connection.
99
+     *
100
+     * @return \Doctrine\DBAL\Query\Expression\ExpressionBuilder
101
+     * @deprecated please use $this->getQueryBuilder()->expr() instead
102
+     */
103
+    public function getExpressionBuilder() {
104
+        $backtrace = $this->getCallerBacktrace();
105
+        \OC::$server->getLogger()->debug('Doctrine ExpressionBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]);
106
+        return parent::getExpressionBuilder();
107
+    }
108
+
109
+    /**
110
+     * Get the file and line that called the method where `getCallerBacktrace()` was used
111
+     *
112
+     * @return string
113
+     */
114
+    protected function getCallerBacktrace() {
115
+        $traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
116
+
117
+        // 0 is the method where we use `getCallerBacktrace`
118
+        // 1 is the target method which uses the method we want to log
119
+        if (isset($traces[1])) {
120
+            return $traces[1]['file'] . ':' . $traces[1]['line'];
121
+        }
122
+
123
+        return '';
124
+    }
125
+
126
+    /**
127
+     * @return string
128
+     */
129
+    public function getPrefix() {
130
+        return $this->tablePrefix;
131
+    }
132
+
133
+    /**
134
+     * Initializes a new instance of the Connection class.
135
+     *
136
+     * @param array $params  The connection parameters.
137
+     * @param \Doctrine\DBAL\Driver $driver
138
+     * @param \Doctrine\DBAL\Configuration $config
139
+     * @param \Doctrine\Common\EventManager $eventManager
140
+     * @throws \Exception
141
+     */
142
+    public function __construct(array $params, Driver $driver, Configuration $config = null,
143
+        EventManager $eventManager = null)
144
+    {
145
+        if (!isset($params['adapter'])) {
146
+            throw new \Exception('adapter not set');
147
+        }
148
+        if (!isset($params['tablePrefix'])) {
149
+            throw new \Exception('tablePrefix not set');
150
+        }
151
+        parent::__construct($params, $driver, $config, $eventManager);
152
+        $this->adapter = new $params['adapter']($this);
153
+        $this->tablePrefix = $params['tablePrefix'];
154
+    }
155
+
156
+    /**
157
+     * Prepares an SQL statement.
158
+     *
159
+     * @param string $statement The SQL statement to prepare.
160
+     * @param int $limit
161
+     * @param int $offset
162
+     * @return \Doctrine\DBAL\Driver\Statement The prepared statement.
163
+     */
164
+    public function prepare( $statement, $limit=null, $offset=null ) {
165
+        if ($limit === -1) {
166
+            $limit = null;
167
+        }
168
+        if (!is_null($limit)) {
169
+            $platform = $this->getDatabasePlatform();
170
+            $statement = $platform->modifyLimitQuery($statement, $limit, $offset);
171
+        }
172
+        $statement = $this->replaceTablePrefix($statement);
173
+        $statement = $this->adapter->fixupStatement($statement);
174
+
175
+        return parent::prepare($statement);
176
+    }
177
+
178
+    /**
179
+     * Executes an, optionally parametrized, SQL query.
180
+     *
181
+     * If the query is parametrized, a prepared statement is used.
182
+     * If an SQLLogger is configured, the execution is logged.
183
+     *
184
+     * @param string                                      $query  The SQL query to execute.
185
+     * @param array                                       $params The parameters to bind to the query, if any.
186
+     * @param array                                       $types  The types the previous parameters are in.
187
+     * @param \Doctrine\DBAL\Cache\QueryCacheProfile|null $qcp    The query cache profile, optional.
188
+     *
189
+     * @return \Doctrine\DBAL\Driver\Statement The executed statement.
190
+     *
191
+     * @throws \Doctrine\DBAL\DBALException
192
+     */
193
+    public function executeQuery($query, array $params = array(), $types = array(), QueryCacheProfile $qcp = null)
194
+    {
195
+        $query = $this->replaceTablePrefix($query);
196
+        $query = $this->adapter->fixupStatement($query);
197
+        return parent::executeQuery($query, $params, $types, $qcp);
198
+    }
199
+
200
+    /**
201
+     * Executes an SQL INSERT/UPDATE/DELETE query with the given parameters
202
+     * and returns the number of affected rows.
203
+     *
204
+     * This method supports PDO binding types as well as DBAL mapping types.
205
+     *
206
+     * @param string $query  The SQL query.
207
+     * @param array  $params The query parameters.
208
+     * @param array  $types  The parameter types.
209
+     *
210
+     * @return integer The number of affected rows.
211
+     *
212
+     * @throws \Doctrine\DBAL\DBALException
213
+     */
214
+    public function executeUpdate($query, array $params = array(), array $types = array())
215
+    {
216
+        $query = $this->replaceTablePrefix($query);
217
+        $query = $this->adapter->fixupStatement($query);
218
+        return parent::executeUpdate($query, $params, $types);
219
+    }
220
+
221
+    /**
222
+     * Returns the ID of the last inserted row, or the last value from a sequence object,
223
+     * depending on the underlying driver.
224
+     *
225
+     * Note: This method may not return a meaningful or consistent result across different drivers,
226
+     * because the underlying database may not even support the notion of AUTO_INCREMENT/IDENTITY
227
+     * columns or sequences.
228
+     *
229
+     * @param string $seqName Name of the sequence object from which the ID should be returned.
230
+     * @return string A string representation of the last inserted ID.
231
+     */
232
+    public function lastInsertId($seqName = null) {
233
+        if ($seqName) {
234
+            $seqName = $this->replaceTablePrefix($seqName);
235
+        }
236
+        return $this->adapter->lastInsertId($seqName);
237
+    }
238
+
239
+    // internal use
240
+    public function realLastInsertId($seqName = null) {
241
+        return parent::lastInsertId($seqName);
242
+    }
243
+
244
+    /**
245
+     * Insert a row if the matching row does not exists. To accomplish proper race condition avoidance
246
+     * it is needed that there is also a unique constraint on the values. Then this method will
247
+     * catch the exception and return 0.
248
+     *
249
+     * @param string $table The table name (will replace *PREFIX* with the actual prefix)
250
+     * @param array $input data that should be inserted into the table  (column name => value)
251
+     * @param array|null $compare List of values that should be checked for "if not exists"
252
+     *				If this is null or an empty array, all keys of $input will be compared
253
+     *				Please note: text fields (clob) must not be used in the compare array
254
+     * @return int number of inserted rows
255
+     * @throws \Doctrine\DBAL\DBALException
256
+     * @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
257
+     */
258
+    public function insertIfNotExist($table, $input, array $compare = null) {
259
+        return $this->adapter->insertIfNotExist($table, $input, $compare);
260
+    }
261
+
262
+    public function insertIgnoreConflict(string $table, array $values) : int {
263
+        return $this->adapter->insertIgnoreConflict($table, $values);
264
+    }
265
+
266
+    private function getType($value) {
267
+        if (is_bool($value)) {
268
+            return IQueryBuilder::PARAM_BOOL;
269
+        } else if (is_int($value)) {
270
+            return IQueryBuilder::PARAM_INT;
271
+        } else {
272
+            return IQueryBuilder::PARAM_STR;
273
+        }
274
+    }
275
+
276
+    /**
277
+     * Insert or update a row value
278
+     *
279
+     * @param string $table
280
+     * @param array $keys (column name => value)
281
+     * @param array $values (column name => value)
282
+     * @param array $updatePreconditionValues ensure values match preconditions (column name => value)
283
+     * @return int number of new rows
284
+     * @throws \Doctrine\DBAL\DBALException
285
+     * @throws PreConditionNotMetException
286
+     * @suppress SqlInjectionChecker
287
+     */
288
+    public function setValues($table, array $keys, array $values, array $updatePreconditionValues = []) {
289
+        try {
290
+            $insertQb = $this->getQueryBuilder();
291
+            $insertQb->insert($table)
292
+                ->values(
293
+                    array_map(function($value) use ($insertQb) {
294
+                        return $insertQb->createNamedParameter($value, $this->getType($value));
295
+                    }, array_merge($keys, $values))
296
+                );
297
+            return $insertQb->execute();
298
+        } catch (ConstraintViolationException $e) {
299
+            // value already exists, try update
300
+            $updateQb = $this->getQueryBuilder();
301
+            $updateQb->update($table);
302
+            foreach ($values as $name => $value) {
303
+                $updateQb->set($name, $updateQb->createNamedParameter($value, $this->getType($value)));
304
+            }
305
+            $where = $updateQb->expr()->andX();
306
+            $whereValues = array_merge($keys, $updatePreconditionValues);
307
+            foreach ($whereValues as $name => $value) {
308
+                $where->add($updateQb->expr()->eq(
309
+                    $name,
310
+                    $updateQb->createNamedParameter($value, $this->getType($value)),
311
+                    $this->getType($value)
312
+                ));
313
+            }
314
+            $updateQb->where($where);
315
+            $affected = $updateQb->execute();
316
+
317
+            if ($affected === 0 && !empty($updatePreconditionValues)) {
318
+                throw new PreConditionNotMetException();
319
+            }
320
+
321
+            return 0;
322
+        }
323
+    }
324
+
325
+    /**
326
+     * Create an exclusive read+write lock on a table
327
+     *
328
+     * @param string $tableName
329
+     * @throws \BadMethodCallException When trying to acquire a second lock
330
+     * @since 9.1.0
331
+     */
332
+    public function lockTable($tableName) {
333
+        if ($this->lockedTable !== null) {
334
+            throw new \BadMethodCallException('Can not lock a new table until the previous lock is released.');
335
+        }
336
+
337
+        $tableName = $this->tablePrefix . $tableName;
338
+        $this->lockedTable = $tableName;
339
+        $this->adapter->lockTable($tableName);
340
+    }
341
+
342
+    /**
343
+     * Release a previous acquired lock again
344
+     *
345
+     * @since 9.1.0
346
+     */
347
+    public function unlockTable() {
348
+        $this->adapter->unlockTable();
349
+        $this->lockedTable = null;
350
+    }
351
+
352
+    /**
353
+     * returns the error code and message as a string for logging
354
+     * works with DoctrineException
355
+     * @return string
356
+     */
357
+    public function getError() {
358
+        $msg = $this->errorCode() . ': ';
359
+        $errorInfo = $this->errorInfo();
360
+        if (is_array($errorInfo)) {
361
+            $msg .= 'SQLSTATE = '.$errorInfo[0] . ', ';
362
+            $msg .= 'Driver Code = '.$errorInfo[1] . ', ';
363
+            $msg .= 'Driver Message = '.$errorInfo[2];
364
+        }
365
+        return $msg;
366
+    }
367
+
368
+    /**
369
+     * Drop a table from the database if it exists
370
+     *
371
+     * @param string $table table name without the prefix
372
+     */
373
+    public function dropTable($table) {
374
+        $table = $this->tablePrefix . trim($table);
375
+        $schema = $this->getSchemaManager();
376
+        if($schema->tablesExist(array($table))) {
377
+            $schema->dropTable($table);
378
+        }
379
+    }
380
+
381
+    /**
382
+     * Check if a table exists
383
+     *
384
+     * @param string $table table name without the prefix
385
+     * @return bool
386
+     */
387
+    public function tableExists($table){
388
+        $table = $this->tablePrefix . trim($table);
389
+        $schema = $this->getSchemaManager();
390
+        return $schema->tablesExist(array($table));
391
+    }
392
+
393
+    // internal use
394
+    /**
395
+     * @param string $statement
396
+     * @return string
397
+     */
398
+    protected function replaceTablePrefix($statement) {
399
+        return str_replace( '*PREFIX*', $this->tablePrefix, $statement );
400
+    }
401
+
402
+    /**
403
+     * Check if a transaction is active
404
+     *
405
+     * @return bool
406
+     * @since 8.2.0
407
+     */
408
+    public function inTransaction() {
409
+        return $this->getTransactionNestingLevel() > 0;
410
+    }
411
+
412
+    /**
413
+     * Escape a parameter to be used in a LIKE query
414
+     *
415
+     * @param string $param
416
+     * @return string
417
+     */
418
+    public function escapeLikeParameter($param) {
419
+        return addcslashes($param, '\\_%');
420
+    }
421
+
422
+    /**
423
+     * Check whether or not the current database support 4byte wide unicode
424
+     *
425
+     * @return bool
426
+     * @since 11.0.0
427
+     */
428
+    public function supports4ByteText() {
429
+        if (!$this->getDatabasePlatform() instanceof MySqlPlatform) {
430
+            return true;
431
+        }
432
+        return $this->getParams()['charset'] === 'utf8mb4';
433
+    }
434
+
435
+
436
+    /**
437
+     * Create the schema of the connected database
438
+     *
439
+     * @return Schema
440
+     */
441
+    public function createSchema() {
442
+        $schemaManager = new MDB2SchemaManager($this);
443
+        $migrator = $schemaManager->getMigrator();
444
+        return $migrator->createSchema();
445
+    }
446
+
447
+    /**
448
+     * Migrate the database to the given schema
449
+     *
450
+     * @param Schema $toSchema
451
+     */
452
+    public function migrateToSchema(Schema $toSchema) {
453
+        $schemaManager = new MDB2SchemaManager($this);
454
+        $migrator = $schemaManager->getMigrator();
455
+        $migrator->migrate($toSchema);
456
+    }
457 457
 }
Please login to merge, or discard this patch.