Passed
Push — master ( 1199e5...c7b7ee )
by Blizzz
11:21 queued 12s
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   +408 added lines, -408 removed lines patch added patch discarded remove patch
@@ -45,412 +45,412 @@
 block discarded – undo
45 45
 use OCP\PreConditionNotMetException;
46 46
 
47 47
 class Connection extends ReconnectWrapper implements IDBConnection {
48
-	/**
49
-	 * @var string $tablePrefix
50
-	 */
51
-	protected $tablePrefix;
52
-
53
-	/**
54
-	 * @var \OC\DB\Adapter $adapter
55
-	 */
56
-	protected $adapter;
57
-
58
-	protected $lockedTable = null;
59
-
60
-	public function connect() {
61
-		try {
62
-			return parent::connect();
63
-		} catch (DBALException $e) {
64
-			// throw a new exception to prevent leaking info from the stacktrace
65
-			throw new DBALException('Failed to connect to the database: ' . $e->getMessage(), $e->getCode());
66
-		}
67
-	}
68
-
69
-	/**
70
-	 * Returns a QueryBuilder for the connection.
71
-	 *
72
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder
73
-	 */
74
-	public function getQueryBuilder() {
75
-		return new QueryBuilder(
76
-			$this,
77
-			\OC::$server->getSystemConfig(),
78
-			\OC::$server->getLogger()
79
-		);
80
-	}
81
-
82
-	/**
83
-	 * Gets the QueryBuilder for the connection.
84
-	 *
85
-	 * @return \Doctrine\DBAL\Query\QueryBuilder
86
-	 * @deprecated please use $this->getQueryBuilder() instead
87
-	 */
88
-	public function createQueryBuilder() {
89
-		$backtrace = $this->getCallerBacktrace();
90
-		\OC::$server->getLogger()->debug('Doctrine QueryBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]);
91
-		return parent::createQueryBuilder();
92
-	}
93
-
94
-	/**
95
-	 * Gets the ExpressionBuilder for the connection.
96
-	 *
97
-	 * @return \Doctrine\DBAL\Query\Expression\ExpressionBuilder
98
-	 * @deprecated please use $this->getQueryBuilder()->expr() instead
99
-	 */
100
-	public function getExpressionBuilder() {
101
-		$backtrace = $this->getCallerBacktrace();
102
-		\OC::$server->getLogger()->debug('Doctrine ExpressionBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]);
103
-		return parent::getExpressionBuilder();
104
-	}
105
-
106
-	/**
107
-	 * Get the file and line that called the method where `getCallerBacktrace()` was used
108
-	 *
109
-	 * @return string
110
-	 */
111
-	protected function getCallerBacktrace() {
112
-		$traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
113
-
114
-		// 0 is the method where we use `getCallerBacktrace`
115
-		// 1 is the target method which uses the method we want to log
116
-		if (isset($traces[1])) {
117
-			return $traces[1]['file'] . ':' . $traces[1]['line'];
118
-		}
119
-
120
-		return '';
121
-	}
122
-
123
-	/**
124
-	 * @return string
125
-	 */
126
-	public function getPrefix() {
127
-		return $this->tablePrefix;
128
-	}
129
-
130
-	/**
131
-	 * Initializes a new instance of the Connection class.
132
-	 *
133
-	 * @param array $params  The connection parameters.
134
-	 * @param \Doctrine\DBAL\Driver $driver
135
-	 * @param \Doctrine\DBAL\Configuration $config
136
-	 * @param \Doctrine\Common\EventManager $eventManager
137
-	 * @throws \Exception
138
-	 */
139
-	public function __construct(array $params, Driver $driver, Configuration $config = null,
140
-		EventManager $eventManager = null)
141
-	{
142
-		if (!isset($params['adapter'])) {
143
-			throw new \Exception('adapter not set');
144
-		}
145
-		if (!isset($params['tablePrefix'])) {
146
-			throw new \Exception('tablePrefix not set');
147
-		}
148
-		parent::__construct($params, $driver, $config, $eventManager);
149
-		$this->adapter = new $params['adapter']($this);
150
-		$this->tablePrefix = $params['tablePrefix'];
151
-
152
-		$this->setTransactionIsolation(TransactionIsolationLevel::READ_COMMITTED);
153
-	}
154
-
155
-	/**
156
-	 * Prepares an SQL statement.
157
-	 *
158
-	 * @param string $statement The SQL statement to prepare.
159
-	 * @param int $limit
160
-	 * @param int $offset
161
-	 * @return \Doctrine\DBAL\Driver\Statement The prepared statement.
162
-	 */
163
-	public function prepare( $statement, $limit=null, $offset=null ) {
164
-		if ($limit === -1) {
165
-			$limit = null;
166
-		}
167
-		if (!is_null($limit)) {
168
-			$platform = $this->getDatabasePlatform();
169
-			$statement = $platform->modifyLimitQuery($statement, $limit, $offset);
170
-		}
171
-		$statement = $this->replaceTablePrefix($statement);
172
-		$statement = $this->adapter->fixupStatement($statement);
173
-
174
-		return parent::prepare($statement);
175
-	}
176
-
177
-	/**
178
-	 * Executes an, optionally parametrized, SQL query.
179
-	 *
180
-	 * If the query is parametrized, a prepared statement is used.
181
-	 * If an SQLLogger is configured, the execution is logged.
182
-	 *
183
-	 * @param string                                      $query  The SQL query to execute.
184
-	 * @param array                                       $params The parameters to bind to the query, if any.
185
-	 * @param array                                       $types  The types the previous parameters are in.
186
-	 * @param \Doctrine\DBAL\Cache\QueryCacheProfile|null $qcp    The query cache profile, optional.
187
-	 *
188
-	 * @return \Doctrine\DBAL\Driver\Statement The executed statement.
189
-	 *
190
-	 * @throws \Doctrine\DBAL\DBALException
191
-	 */
192
-	public function executeQuery($query, array $params = array(), $types = array(), QueryCacheProfile $qcp = null)
193
-	{
194
-		$query = $this->replaceTablePrefix($query);
195
-		$query = $this->adapter->fixupStatement($query);
196
-		return parent::executeQuery($query, $params, $types, $qcp);
197
-	}
198
-
199
-	/**
200
-	 * Executes an SQL INSERT/UPDATE/DELETE query with the given parameters
201
-	 * and returns the number of affected rows.
202
-	 *
203
-	 * This method supports PDO binding types as well as DBAL mapping types.
204
-	 *
205
-	 * @param string $query  The SQL query.
206
-	 * @param array  $params The query parameters.
207
-	 * @param array  $types  The parameter types.
208
-	 *
209
-	 * @return integer The number of affected rows.
210
-	 *
211
-	 * @throws \Doctrine\DBAL\DBALException
212
-	 */
213
-	public function executeUpdate($query, array $params = array(), array $types = array())
214
-	{
215
-		$query = $this->replaceTablePrefix($query);
216
-		$query = $this->adapter->fixupStatement($query);
217
-		return parent::executeUpdate($query, $params, $types);
218
-	}
219
-
220
-	/**
221
-	 * Returns the ID of the last inserted row, or the last value from a sequence object,
222
-	 * depending on the underlying driver.
223
-	 *
224
-	 * Note: This method may not return a meaningful or consistent result across different drivers,
225
-	 * because the underlying database may not even support the notion of AUTO_INCREMENT/IDENTITY
226
-	 * columns or sequences.
227
-	 *
228
-	 * @param string $seqName Name of the sequence object from which the ID should be returned.
229
-	 * @return string A string representation of the last inserted ID.
230
-	 */
231
-	public function lastInsertId($seqName = null) {
232
-		if ($seqName) {
233
-			$seqName = $this->replaceTablePrefix($seqName);
234
-		}
235
-		return $this->adapter->lastInsertId($seqName);
236
-	}
237
-
238
-	// internal use
239
-	public function realLastInsertId($seqName = null) {
240
-		return parent::lastInsertId($seqName);
241
-	}
242
-
243
-	/**
244
-	 * Insert a row if the matching row does not exists. To accomplish proper race condition avoidance
245
-	 * it is needed that there is also a unique constraint on the values. Then this method will
246
-	 * catch the exception and return 0.
247
-	 *
248
-	 * @param string $table The table name (will replace *PREFIX* with the actual prefix)
249
-	 * @param array $input data that should be inserted into the table  (column name => value)
250
-	 * @param array|null $compare List of values that should be checked for "if not exists"
251
-	 *				If this is null or an empty array, all keys of $input will be compared
252
-	 *				Please note: text fields (clob) must not be used in the compare array
253
-	 * @return int number of inserted rows
254
-	 * @throws \Doctrine\DBAL\DBALException
255
-	 * @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
256
-	 */
257
-	public function insertIfNotExist($table, $input, array $compare = null) {
258
-		return $this->adapter->insertIfNotExist($table, $input, $compare);
259
-	}
260
-
261
-	public function insertIgnoreConflict(string $table, array $values) : int {
262
-		return $this->adapter->insertIgnoreConflict($table, $values);
263
-	}
264
-
265
-	private function getType($value) {
266
-		if (is_bool($value)) {
267
-			return IQueryBuilder::PARAM_BOOL;
268
-		} else if (is_int($value)) {
269
-			return IQueryBuilder::PARAM_INT;
270
-		} else {
271
-			return IQueryBuilder::PARAM_STR;
272
-		}
273
-	}
274
-
275
-	/**
276
-	 * Insert or update a row value
277
-	 *
278
-	 * @param string $table
279
-	 * @param array $keys (column name => value)
280
-	 * @param array $values (column name => value)
281
-	 * @param array $updatePreconditionValues ensure values match preconditions (column name => value)
282
-	 * @return int number of new rows
283
-	 * @throws \Doctrine\DBAL\DBALException
284
-	 * @throws PreConditionNotMetException
285
-	 * @suppress SqlInjectionChecker
286
-	 */
287
-	public function setValues($table, array $keys, array $values, array $updatePreconditionValues = []) {
288
-		try {
289
-			$insertQb = $this->getQueryBuilder();
290
-			$insertQb->insert($table)
291
-				->values(
292
-					array_map(function($value) use ($insertQb) {
293
-						return $insertQb->createNamedParameter($value, $this->getType($value));
294
-					}, array_merge($keys, $values))
295
-				);
296
-			return $insertQb->execute();
297
-		} catch (ConstraintViolationException $e) {
298
-			// value already exists, try update
299
-			$updateQb = $this->getQueryBuilder();
300
-			$updateQb->update($table);
301
-			foreach ($values as $name => $value) {
302
-				$updateQb->set($name, $updateQb->createNamedParameter($value, $this->getType($value)));
303
-			}
304
-			$where = $updateQb->expr()->andX();
305
-			$whereValues = array_merge($keys, $updatePreconditionValues);
306
-			foreach ($whereValues as $name => $value) {
307
-				$where->add($updateQb->expr()->eq(
308
-					$name,
309
-					$updateQb->createNamedParameter($value, $this->getType($value)),
310
-					$this->getType($value)
311
-				));
312
-			}
313
-			$updateQb->where($where);
314
-			$affected = $updateQb->execute();
315
-
316
-			if ($affected === 0 && !empty($updatePreconditionValues)) {
317
-				throw new PreConditionNotMetException();
318
-			}
319
-
320
-			return 0;
321
-		}
322
-	}
323
-
324
-	/**
325
-	 * Create an exclusive read+write lock on a table
326
-	 *
327
-	 * @param string $tableName
328
-	 * @throws \BadMethodCallException When trying to acquire a second lock
329
-	 * @since 9.1.0
330
-	 */
331
-	public function lockTable($tableName) {
332
-		if ($this->lockedTable !== null) {
333
-			throw new \BadMethodCallException('Can not lock a new table until the previous lock is released.');
334
-		}
335
-
336
-		$tableName = $this->tablePrefix . $tableName;
337
-		$this->lockedTable = $tableName;
338
-		$this->adapter->lockTable($tableName);
339
-	}
340
-
341
-	/**
342
-	 * Release a previous acquired lock again
343
-	 *
344
-	 * @since 9.1.0
345
-	 */
346
-	public function unlockTable() {
347
-		$this->adapter->unlockTable();
348
-		$this->lockedTable = null;
349
-	}
350
-
351
-	/**
352
-	 * returns the error code and message as a string for logging
353
-	 * works with DoctrineException
354
-	 * @return string
355
-	 */
356
-	public function getError() {
357
-		$msg = $this->errorCode() . ': ';
358
-		$errorInfo = $this->errorInfo();
359
-		if (is_array($errorInfo)) {
360
-			$msg .= 'SQLSTATE = '.$errorInfo[0] . ', ';
361
-			$msg .= 'Driver Code = '.$errorInfo[1] . ', ';
362
-			$msg .= 'Driver Message = '.$errorInfo[2];
363
-		}
364
-		return $msg;
365
-	}
366
-
367
-	/**
368
-	 * Drop a table from the database if it exists
369
-	 *
370
-	 * @param string $table table name without the prefix
371
-	 */
372
-	public function dropTable($table) {
373
-		$table = $this->tablePrefix . trim($table);
374
-		$schema = $this->getSchemaManager();
375
-		if($schema->tablesExist(array($table))) {
376
-			$schema->dropTable($table);
377
-		}
378
-	}
379
-
380
-	/**
381
-	 * Check if a table exists
382
-	 *
383
-	 * @param string $table table name without the prefix
384
-	 * @return bool
385
-	 */
386
-	public function tableExists($table){
387
-		$table = $this->tablePrefix . trim($table);
388
-		$schema = $this->getSchemaManager();
389
-		return $schema->tablesExist(array($table));
390
-	}
391
-
392
-	// internal use
393
-	/**
394
-	 * @param string $statement
395
-	 * @return string
396
-	 */
397
-	protected function replaceTablePrefix($statement) {
398
-		return str_replace( '*PREFIX*', $this->tablePrefix, $statement );
399
-	}
400
-
401
-	/**
402
-	 * Check if a transaction is active
403
-	 *
404
-	 * @return bool
405
-	 * @since 8.2.0
406
-	 */
407
-	public function inTransaction() {
408
-		return $this->getTransactionNestingLevel() > 0;
409
-	}
410
-
411
-	/**
412
-	 * Escape a parameter to be used in a LIKE query
413
-	 *
414
-	 * @param string $param
415
-	 * @return string
416
-	 */
417
-	public function escapeLikeParameter($param) {
418
-		return addcslashes($param, '\\_%');
419
-	}
420
-
421
-	/**
422
-	 * Check whether or not the current database support 4byte wide unicode
423
-	 *
424
-	 * @return bool
425
-	 * @since 11.0.0
426
-	 */
427
-	public function supports4ByteText() {
428
-		if (!$this->getDatabasePlatform() instanceof MySqlPlatform) {
429
-			return true;
430
-		}
431
-		return $this->getParams()['charset'] === 'utf8mb4';
432
-	}
433
-
434
-
435
-	/**
436
-	 * Create the schema of the connected database
437
-	 *
438
-	 * @return Schema
439
-	 */
440
-	public function createSchema() {
441
-		$schemaManager = new MDB2SchemaManager($this);
442
-		$migrator = $schemaManager->getMigrator();
443
-		return $migrator->createSchema();
444
-	}
445
-
446
-	/**
447
-	 * Migrate the database to the given schema
448
-	 *
449
-	 * @param Schema $toSchema
450
-	 */
451
-	public function migrateToSchema(Schema $toSchema) {
452
-		$schemaManager = new MDB2SchemaManager($this);
453
-		$migrator = $schemaManager->getMigrator();
454
-		$migrator->migrate($toSchema);
455
-	}
48
+    /**
49
+     * @var string $tablePrefix
50
+     */
51
+    protected $tablePrefix;
52
+
53
+    /**
54
+     * @var \OC\DB\Adapter $adapter
55
+     */
56
+    protected $adapter;
57
+
58
+    protected $lockedTable = null;
59
+
60
+    public function connect() {
61
+        try {
62
+            return parent::connect();
63
+        } catch (DBALException $e) {
64
+            // throw a new exception to prevent leaking info from the stacktrace
65
+            throw new DBALException('Failed to connect to the database: ' . $e->getMessage(), $e->getCode());
66
+        }
67
+    }
68
+
69
+    /**
70
+     * Returns a QueryBuilder for the connection.
71
+     *
72
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder
73
+     */
74
+    public function getQueryBuilder() {
75
+        return new QueryBuilder(
76
+            $this,
77
+            \OC::$server->getSystemConfig(),
78
+            \OC::$server->getLogger()
79
+        );
80
+    }
81
+
82
+    /**
83
+     * Gets the QueryBuilder for the connection.
84
+     *
85
+     * @return \Doctrine\DBAL\Query\QueryBuilder
86
+     * @deprecated please use $this->getQueryBuilder() instead
87
+     */
88
+    public function createQueryBuilder() {
89
+        $backtrace = $this->getCallerBacktrace();
90
+        \OC::$server->getLogger()->debug('Doctrine QueryBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]);
91
+        return parent::createQueryBuilder();
92
+    }
93
+
94
+    /**
95
+     * Gets the ExpressionBuilder for the connection.
96
+     *
97
+     * @return \Doctrine\DBAL\Query\Expression\ExpressionBuilder
98
+     * @deprecated please use $this->getQueryBuilder()->expr() instead
99
+     */
100
+    public function getExpressionBuilder() {
101
+        $backtrace = $this->getCallerBacktrace();
102
+        \OC::$server->getLogger()->debug('Doctrine ExpressionBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]);
103
+        return parent::getExpressionBuilder();
104
+    }
105
+
106
+    /**
107
+     * Get the file and line that called the method where `getCallerBacktrace()` was used
108
+     *
109
+     * @return string
110
+     */
111
+    protected function getCallerBacktrace() {
112
+        $traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
113
+
114
+        // 0 is the method where we use `getCallerBacktrace`
115
+        // 1 is the target method which uses the method we want to log
116
+        if (isset($traces[1])) {
117
+            return $traces[1]['file'] . ':' . $traces[1]['line'];
118
+        }
119
+
120
+        return '';
121
+    }
122
+
123
+    /**
124
+     * @return string
125
+     */
126
+    public function getPrefix() {
127
+        return $this->tablePrefix;
128
+    }
129
+
130
+    /**
131
+     * Initializes a new instance of the Connection class.
132
+     *
133
+     * @param array $params  The connection parameters.
134
+     * @param \Doctrine\DBAL\Driver $driver
135
+     * @param \Doctrine\DBAL\Configuration $config
136
+     * @param \Doctrine\Common\EventManager $eventManager
137
+     * @throws \Exception
138
+     */
139
+    public function __construct(array $params, Driver $driver, Configuration $config = null,
140
+        EventManager $eventManager = null)
141
+    {
142
+        if (!isset($params['adapter'])) {
143
+            throw new \Exception('adapter not set');
144
+        }
145
+        if (!isset($params['tablePrefix'])) {
146
+            throw new \Exception('tablePrefix not set');
147
+        }
148
+        parent::__construct($params, $driver, $config, $eventManager);
149
+        $this->adapter = new $params['adapter']($this);
150
+        $this->tablePrefix = $params['tablePrefix'];
151
+
152
+        $this->setTransactionIsolation(TransactionIsolationLevel::READ_COMMITTED);
153
+    }
154
+
155
+    /**
156
+     * Prepares an SQL statement.
157
+     *
158
+     * @param string $statement The SQL statement to prepare.
159
+     * @param int $limit
160
+     * @param int $offset
161
+     * @return \Doctrine\DBAL\Driver\Statement The prepared statement.
162
+     */
163
+    public function prepare( $statement, $limit=null, $offset=null ) {
164
+        if ($limit === -1) {
165
+            $limit = null;
166
+        }
167
+        if (!is_null($limit)) {
168
+            $platform = $this->getDatabasePlatform();
169
+            $statement = $platform->modifyLimitQuery($statement, $limit, $offset);
170
+        }
171
+        $statement = $this->replaceTablePrefix($statement);
172
+        $statement = $this->adapter->fixupStatement($statement);
173
+
174
+        return parent::prepare($statement);
175
+    }
176
+
177
+    /**
178
+     * Executes an, optionally parametrized, SQL query.
179
+     *
180
+     * If the query is parametrized, a prepared statement is used.
181
+     * If an SQLLogger is configured, the execution is logged.
182
+     *
183
+     * @param string                                      $query  The SQL query to execute.
184
+     * @param array                                       $params The parameters to bind to the query, if any.
185
+     * @param array                                       $types  The types the previous parameters are in.
186
+     * @param \Doctrine\DBAL\Cache\QueryCacheProfile|null $qcp    The query cache profile, optional.
187
+     *
188
+     * @return \Doctrine\DBAL\Driver\Statement The executed statement.
189
+     *
190
+     * @throws \Doctrine\DBAL\DBALException
191
+     */
192
+    public function executeQuery($query, array $params = array(), $types = array(), QueryCacheProfile $qcp = null)
193
+    {
194
+        $query = $this->replaceTablePrefix($query);
195
+        $query = $this->adapter->fixupStatement($query);
196
+        return parent::executeQuery($query, $params, $types, $qcp);
197
+    }
198
+
199
+    /**
200
+     * Executes an SQL INSERT/UPDATE/DELETE query with the given parameters
201
+     * and returns the number of affected rows.
202
+     *
203
+     * This method supports PDO binding types as well as DBAL mapping types.
204
+     *
205
+     * @param string $query  The SQL query.
206
+     * @param array  $params The query parameters.
207
+     * @param array  $types  The parameter types.
208
+     *
209
+     * @return integer The number of affected rows.
210
+     *
211
+     * @throws \Doctrine\DBAL\DBALException
212
+     */
213
+    public function executeUpdate($query, array $params = array(), array $types = array())
214
+    {
215
+        $query = $this->replaceTablePrefix($query);
216
+        $query = $this->adapter->fixupStatement($query);
217
+        return parent::executeUpdate($query, $params, $types);
218
+    }
219
+
220
+    /**
221
+     * Returns the ID of the last inserted row, or the last value from a sequence object,
222
+     * depending on the underlying driver.
223
+     *
224
+     * Note: This method may not return a meaningful or consistent result across different drivers,
225
+     * because the underlying database may not even support the notion of AUTO_INCREMENT/IDENTITY
226
+     * columns or sequences.
227
+     *
228
+     * @param string $seqName Name of the sequence object from which the ID should be returned.
229
+     * @return string A string representation of the last inserted ID.
230
+     */
231
+    public function lastInsertId($seqName = null) {
232
+        if ($seqName) {
233
+            $seqName = $this->replaceTablePrefix($seqName);
234
+        }
235
+        return $this->adapter->lastInsertId($seqName);
236
+    }
237
+
238
+    // internal use
239
+    public function realLastInsertId($seqName = null) {
240
+        return parent::lastInsertId($seqName);
241
+    }
242
+
243
+    /**
244
+     * Insert a row if the matching row does not exists. To accomplish proper race condition avoidance
245
+     * it is needed that there is also a unique constraint on the values. Then this method will
246
+     * catch the exception and return 0.
247
+     *
248
+     * @param string $table The table name (will replace *PREFIX* with the actual prefix)
249
+     * @param array $input data that should be inserted into the table  (column name => value)
250
+     * @param array|null $compare List of values that should be checked for "if not exists"
251
+     *				If this is null or an empty array, all keys of $input will be compared
252
+     *				Please note: text fields (clob) must not be used in the compare array
253
+     * @return int number of inserted rows
254
+     * @throws \Doctrine\DBAL\DBALException
255
+     * @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
256
+     */
257
+    public function insertIfNotExist($table, $input, array $compare = null) {
258
+        return $this->adapter->insertIfNotExist($table, $input, $compare);
259
+    }
260
+
261
+    public function insertIgnoreConflict(string $table, array $values) : int {
262
+        return $this->adapter->insertIgnoreConflict($table, $values);
263
+    }
264
+
265
+    private function getType($value) {
266
+        if (is_bool($value)) {
267
+            return IQueryBuilder::PARAM_BOOL;
268
+        } else if (is_int($value)) {
269
+            return IQueryBuilder::PARAM_INT;
270
+        } else {
271
+            return IQueryBuilder::PARAM_STR;
272
+        }
273
+    }
274
+
275
+    /**
276
+     * Insert or update a row value
277
+     *
278
+     * @param string $table
279
+     * @param array $keys (column name => value)
280
+     * @param array $values (column name => value)
281
+     * @param array $updatePreconditionValues ensure values match preconditions (column name => value)
282
+     * @return int number of new rows
283
+     * @throws \Doctrine\DBAL\DBALException
284
+     * @throws PreConditionNotMetException
285
+     * @suppress SqlInjectionChecker
286
+     */
287
+    public function setValues($table, array $keys, array $values, array $updatePreconditionValues = []) {
288
+        try {
289
+            $insertQb = $this->getQueryBuilder();
290
+            $insertQb->insert($table)
291
+                ->values(
292
+                    array_map(function($value) use ($insertQb) {
293
+                        return $insertQb->createNamedParameter($value, $this->getType($value));
294
+                    }, array_merge($keys, $values))
295
+                );
296
+            return $insertQb->execute();
297
+        } catch (ConstraintViolationException $e) {
298
+            // value already exists, try update
299
+            $updateQb = $this->getQueryBuilder();
300
+            $updateQb->update($table);
301
+            foreach ($values as $name => $value) {
302
+                $updateQb->set($name, $updateQb->createNamedParameter($value, $this->getType($value)));
303
+            }
304
+            $where = $updateQb->expr()->andX();
305
+            $whereValues = array_merge($keys, $updatePreconditionValues);
306
+            foreach ($whereValues as $name => $value) {
307
+                $where->add($updateQb->expr()->eq(
308
+                    $name,
309
+                    $updateQb->createNamedParameter($value, $this->getType($value)),
310
+                    $this->getType($value)
311
+                ));
312
+            }
313
+            $updateQb->where($where);
314
+            $affected = $updateQb->execute();
315
+
316
+            if ($affected === 0 && !empty($updatePreconditionValues)) {
317
+                throw new PreConditionNotMetException();
318
+            }
319
+
320
+            return 0;
321
+        }
322
+    }
323
+
324
+    /**
325
+     * Create an exclusive read+write lock on a table
326
+     *
327
+     * @param string $tableName
328
+     * @throws \BadMethodCallException When trying to acquire a second lock
329
+     * @since 9.1.0
330
+     */
331
+    public function lockTable($tableName) {
332
+        if ($this->lockedTable !== null) {
333
+            throw new \BadMethodCallException('Can not lock a new table until the previous lock is released.');
334
+        }
335
+
336
+        $tableName = $this->tablePrefix . $tableName;
337
+        $this->lockedTable = $tableName;
338
+        $this->adapter->lockTable($tableName);
339
+    }
340
+
341
+    /**
342
+     * Release a previous acquired lock again
343
+     *
344
+     * @since 9.1.0
345
+     */
346
+    public function unlockTable() {
347
+        $this->adapter->unlockTable();
348
+        $this->lockedTable = null;
349
+    }
350
+
351
+    /**
352
+     * returns the error code and message as a string for logging
353
+     * works with DoctrineException
354
+     * @return string
355
+     */
356
+    public function getError() {
357
+        $msg = $this->errorCode() . ': ';
358
+        $errorInfo = $this->errorInfo();
359
+        if (is_array($errorInfo)) {
360
+            $msg .= 'SQLSTATE = '.$errorInfo[0] . ', ';
361
+            $msg .= 'Driver Code = '.$errorInfo[1] . ', ';
362
+            $msg .= 'Driver Message = '.$errorInfo[2];
363
+        }
364
+        return $msg;
365
+    }
366
+
367
+    /**
368
+     * Drop a table from the database if it exists
369
+     *
370
+     * @param string $table table name without the prefix
371
+     */
372
+    public function dropTable($table) {
373
+        $table = $this->tablePrefix . trim($table);
374
+        $schema = $this->getSchemaManager();
375
+        if($schema->tablesExist(array($table))) {
376
+            $schema->dropTable($table);
377
+        }
378
+    }
379
+
380
+    /**
381
+     * Check if a table exists
382
+     *
383
+     * @param string $table table name without the prefix
384
+     * @return bool
385
+     */
386
+    public function tableExists($table){
387
+        $table = $this->tablePrefix . trim($table);
388
+        $schema = $this->getSchemaManager();
389
+        return $schema->tablesExist(array($table));
390
+    }
391
+
392
+    // internal use
393
+    /**
394
+     * @param string $statement
395
+     * @return string
396
+     */
397
+    protected function replaceTablePrefix($statement) {
398
+        return str_replace( '*PREFIX*', $this->tablePrefix, $statement );
399
+    }
400
+
401
+    /**
402
+     * Check if a transaction is active
403
+     *
404
+     * @return bool
405
+     * @since 8.2.0
406
+     */
407
+    public function inTransaction() {
408
+        return $this->getTransactionNestingLevel() > 0;
409
+    }
410
+
411
+    /**
412
+     * Escape a parameter to be used in a LIKE query
413
+     *
414
+     * @param string $param
415
+     * @return string
416
+     */
417
+    public function escapeLikeParameter($param) {
418
+        return addcslashes($param, '\\_%');
419
+    }
420
+
421
+    /**
422
+     * Check whether or not the current database support 4byte wide unicode
423
+     *
424
+     * @return bool
425
+     * @since 11.0.0
426
+     */
427
+    public function supports4ByteText() {
428
+        if (!$this->getDatabasePlatform() instanceof MySqlPlatform) {
429
+            return true;
430
+        }
431
+        return $this->getParams()['charset'] === 'utf8mb4';
432
+    }
433
+
434
+
435
+    /**
436
+     * Create the schema of the connected database
437
+     *
438
+     * @return Schema
439
+     */
440
+    public function createSchema() {
441
+        $schemaManager = new MDB2SchemaManager($this);
442
+        $migrator = $schemaManager->getMigrator();
443
+        return $migrator->createSchema();
444
+    }
445
+
446
+    /**
447
+     * Migrate the database to the given schema
448
+     *
449
+     * @param Schema $toSchema
450
+     */
451
+    public function migrateToSchema(Schema $toSchema) {
452
+        $schemaManager = new MDB2SchemaManager($this);
453
+        $migrator = $schemaManager->getMigrator();
454
+        $migrator->migrate($toSchema);
455
+    }
456 456
 }
Please login to merge, or discard this patch.