Completed
Pull Request — master (#4890)
by Blizzz
14:37
created
lib/private/Preview/SVG.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
 
43 43
 			$content = stream_get_contents($fileview->fopen($path, 'r'));
44 44
 			if (substr($content, 0, 5) !== '<?xml') {
45
-				$content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content;
45
+				$content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'.$content;
46 46
 			}
47 47
 
48 48
 			// Do not parse SVG files with references
Please login to merge, or discard this patch.
lib/private/Log.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -97,16 +97,16 @@  discard block
 block discarded – undo
97 97
 	 * @param SystemConfig $config the system config object
98 98
 	 * @param null $normalizer
99 99
 	 */
100
-	public function __construct($logger=null, SystemConfig $config=null, $normalizer = null) {
100
+	public function __construct($logger = null, SystemConfig $config = null, $normalizer = null) {
101 101
 		// FIXME: Add this for backwards compatibility, should be fixed at some point probably
102
-		if($config === null) {
102
+		if ($config === null) {
103 103
 			$config = \OC::$server->getSystemConfig();
104 104
 		}
105 105
 
106 106
 		$this->config = $config;
107 107
 
108 108
 		// FIXME: Add this for backwards compatibility, should be fixed at some point probably
109
-		if($logger === null) {
109
+		if ($logger === null) {
110 110
 			$logType = $this->config->getValue('log_type', 'file');
111 111
 			$this->logger = static::getLogClass($logType);
112 112
 			call_user_func(array($this->logger, 'init'));
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 			 * check log condition based on the context of each log message
243 243
 			 * once this is met -> change the required log level to debug
244 244
 			 */
245
-			if(!empty($logCondition)
245
+			if (!empty($logCondition)
246 246
 				&& isset($logCondition['apps'])
247 247
 				&& in_array($app, $logCondition['apps'], true)) {
248 248
 				$minLevel = Util::DEBUG;
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 		// interpolate $message as defined in PSR-3
255 255
 		$replace = array();
256 256
 		foreach ($context as $key => $val) {
257
-			$replace['{' . $key . '}'] = $val;
257
+			$replace['{'.$key.'}'] = $val;
258 258
 		}
259 259
 
260 260
 		// interpolate replacement values into the message and return
@@ -264,27 +264,27 @@  discard block
 block discarded – undo
264 264
 		 * check for a special log condition - this enables an increased log on
265 265
 		 * a per request/user base
266 266
 		 */
267
-		if($this->logConditionSatisfied === null) {
267
+		if ($this->logConditionSatisfied === null) {
268 268
 			// default to false to just process this once per request
269 269
 			$this->logConditionSatisfied = false;
270
-			if(!empty($logCondition)) {
270
+			if (!empty($logCondition)) {
271 271
 
272 272
 				// check for secret token in the request
273
-				if(isset($logCondition['shared_secret'])) {
273
+				if (isset($logCondition['shared_secret'])) {
274 274
 					$request = \OC::$server->getRequest();
275 275
 
276 276
 					// if token is found in the request change set the log condition to satisfied
277
-					if($request && hash_equals($logCondition['shared_secret'], $request->getParam('log_secret', ''))) {
277
+					if ($request && hash_equals($logCondition['shared_secret'], $request->getParam('log_secret', ''))) {
278 278
 						$this->logConditionSatisfied = true;
279 279
 					}
280 280
 				}
281 281
 
282 282
 				// check for user
283
-				if(isset($logCondition['users'])) {
283
+				if (isset($logCondition['users'])) {
284 284
 					$user = \OC::$server->getUserSession()->getUser();
285 285
 
286 286
 					// if the user matches set the log condition to satisfied
287
-					if($user !== null && in_array($user->getUID(), $logCondition['users'], true)) {
287
+					if ($user !== null && in_array($user->getUID(), $logCondition['users'], true)) {
288 288
 						$this->logConditionSatisfied = true;
289 289
 					}
290 290
 				}
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 		}
293 293
 
294 294
 		// if log condition is satisfied change the required log level to DEBUG
295
-		if($this->logConditionSatisfied) {
295
+		if ($this->logConditionSatisfied) {
296 296
 			$minLevel = Util::DEBUG;
297 297
 		}
298 298
 
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
 			'File' => $exception->getFile(),
320 320
 			'Line' => $exception->getLine(),
321 321
 		);
322
-		$exception['Trace'] = preg_replace('!(' . implode('|', $this->methodsWithSensitiveParameters) . ')\(.*\)!', '$1(*** sensitive parameters replaced ***)', $exception['Trace']);
322
+		$exception['Trace'] = preg_replace('!('.implode('|', $this->methodsWithSensitiveParameters).')\(.*\)!', '$1(*** sensitive parameters replaced ***)', $exception['Trace']);
323 323
 		$msg = isset($context['message']) ? $context['message'] : 'Exception';
324
-		$msg .= ': ' . json_encode($exception);
324
+		$msg .= ': '.json_encode($exception);
325 325
 		$this->error($msg, $context);
326 326
 	}
327 327
 
Please login to merge, or discard this patch.
lib/private/Share20/Share.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function setId($id) {
88 88
 		if (is_int($id)) {
89
-			$id = (string)$id;
89
+			$id = (string) $id;
90 90
 		}
91 91
 
92
-		if(!is_string($id)) {
92
+		if (!is_string($id)) {
93 93
 			throw new \InvalidArgumentException('String expected.');
94 94
 		}
95 95
 
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
 		if ($this->providerId === null || $this->id === null) {
116 116
 			throw new \UnexpectedValueException;
117 117
 		}
118
-		return $this->providerId . ':' . $this->id;
118
+		return $this->providerId.':'.$this->id;
119 119
 	}
120 120
 
121 121
 	/**
122 122
 	 * @inheritdoc
123 123
 	 */
124 124
 	public function setProviderId($id) {
125
-		if(!is_string($id)) {
125
+		if (!is_string($id)) {
126 126
 			throw new \InvalidArgumentException('String expected.');
127 127
 		}
128 128
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
 			// for federated shares the owner can be a remote user, in this
158 158
 			// case we use the initiator
159
-			if($this->userManager->userExists($this->shareOwner)) {
159
+			if ($this->userManager->userExists($this->shareOwner)) {
160 160
 				$userFolder = $this->rootFolder->getUserFolder($this->shareOwner);
161 161
 			} else {
162 162
 				$userFolder = $this->rootFolder->getUserFolder($this->sharedBy);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
 			$nodes = $userFolder->getById($this->fileId);
166 166
 			if (empty($nodes)) {
167
-				throw new NotFoundException('Node for share not found, fileid: ' . $this->fileId);
167
+				throw new NotFoundException('Node for share not found, fileid: '.$this->fileId);
168 168
 			}
169 169
 
170 170
 			$this->node = $nodes[0];
Please login to merge, or discard this patch.
lib/private/Setup/PostgreSQL.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 				//use the admin login data for the new database user
61 61
 
62 62
 				//add prefix to the postgresql user name to prevent collisions
63
-				$this->dbUser = 'oc_' . strtolower($username);
63
+				$this->dbUser = 'oc_'.strtolower($username);
64 64
 				//create a new password so we don't need to store the admin config in the config file
65
-				$this->dbPassword = \OC::$server->getSecureRandom()->generate(30, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_DIGITS);
65
+				$this->dbPassword = \OC::$server->getSecureRandom()->generate(30, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS);
66 66
 
67 67
 				$this->createDBUser($connection);
68 68
 			}
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 			//create the database
76 76
 			$this->createDatabase($connection);
77 77
 			$query = $connection->prepare("select count(*) FROM pg_class WHERE relname=? limit 1");
78
-			$query->execute([$this->tablePrefix . "users"]);
78
+			$query->execute([$this->tablePrefix."users"]);
79 79
 			$tablesSetup = $query->fetchColumn() > 0;
80 80
 
81 81
 			// the connection to dbname=postgres is not needed anymore
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	private function createDatabase(IDBConnection $connection) {
112 112
 		if (!$this->databaseExists($connection)) {
113 113
 			//The database does not exists... let's create it
114
-			$query = $connection->prepare("CREATE DATABASE " . addslashes($this->dbName) . " OWNER " . addslashes($this->dbUser));
114
+			$query = $connection->prepare("CREATE DATABASE ".addslashes($this->dbName)." OWNER ".addslashes($this->dbUser));
115 115
 			try {
116 116
 				$query->execute();
117 117
 			} catch (DatabaseException $e) {
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 				$this->logger->logException($e);
120 120
 			}
121 121
 		} else {
122
-			$query = $connection->prepare("REVOKE ALL PRIVILEGES ON DATABASE " . addslashes($this->dbName) . " FROM PUBLIC");
122
+			$query = $connection->prepare("REVOKE ALL PRIVILEGES ON DATABASE ".addslashes($this->dbName)." FROM PUBLIC");
123 123
 			try {
124 124
 				$query->execute();
125 125
 			} catch (DatabaseException $e) {
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
 			$i = 1;
156 156
 			while ($this->userExists($connection)) {
157 157
 				$i++;
158
-				$this->dbUser = $dbUser . $i;
158
+				$this->dbUser = $dbUser.$i;
159 159
 			};
160 160
 
161 161
 			// create the user
162
-			$query = $connection->prepare("CREATE USER " . addslashes($this->dbUser) . " CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
162
+			$query = $connection->prepare("CREATE USER ".addslashes($this->dbUser)." CREATEDB PASSWORD '".addslashes($this->dbPassword)."'");
163 163
 			$query->execute();
164 164
 		} catch (DatabaseException $e) {
165 165
 			$this->logger->error('Error while trying to create database user');
Please login to merge, or discard this patch.
lib/private/Setup/AbstractDatabase.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -68,14 +68,14 @@
 block discarded – undo
68 68
 
69 69
 	public function validate($config) {
70 70
 		$errors = array();
71
-		if(empty($config['dbuser']) && empty($config['dbname'])) {
71
+		if (empty($config['dbuser']) && empty($config['dbname'])) {
72 72
 			$errors[] = $this->trans->t("%s enter the database username and name.", array($this->dbprettyname));
73
-		} else if(empty($config['dbuser'])) {
73
+		} else if (empty($config['dbuser'])) {
74 74
 			$errors[] = $this->trans->t("%s enter the database username.", array($this->dbprettyname));
75
-		} else if(empty($config['dbname'])) {
75
+		} else if (empty($config['dbname'])) {
76 76
 			$errors[] = $this->trans->t("%s enter the database name.", array($this->dbprettyname));
77 77
 		}
78
-		if(substr_count($config['dbname'], '.') >= 1) {
78
+		if (substr_count($config['dbname'], '.') >= 1) {
79 79
 			$errors[] = $this->trans->t("%s you may not use dots in the database name", array($this->dbprettyname));
80 80
 		}
81 81
 		return $errors;
Please login to merge, or discard this patch.
lib/private/Setup/MySQL.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		$this->createDatabase($connection);
44 44
 
45 45
 		//fill the database if needed
46
-		$query='select count(*) from information_schema.tables where table_schema=? AND table_name = ?';
46
+		$query = 'select count(*) from information_schema.tables where table_schema=? AND table_name = ?';
47 47
 		$result = $connection->executeQuery($query, [$this->dbName, $this->tablePrefix.'users']);
48 48
 		$row = $result->fetch();
49 49
 		if (!$row or $row['count(*)'] === '0') {
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * @param \OC\DB\Connection $connection
56 56
 	 */
57 57
 	private function createDatabase($connection) {
58
-		try{
58
+		try {
59 59
 			$name = $this->dbName;
60 60
 			$user = $this->dbUser;
61 61
 			//we can't use OC_DB functions here because we need to connect as the administrative user.
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 		try {
74 74
 			//this query will fail if there aren't the right permissions, ignore the error
75
-			$query="GRANT ALL PRIVILEGES ON `$name` . * TO '$user'";
75
+			$query = "GRANT ALL PRIVILEGES ON `$name` . * TO '$user'";
76 76
 			$connection->executeUpdate($query);
77 77
 		} catch (\Exception $ex) {
78 78
 			$this->logger->debug('Could not automatically grant privileges, this can be ignored if database user already had privileges: {error}', [
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @throws \OC\DatabaseSetupException
88 88
 	 */
89 89
 	private function createDBUser($connection) {
90
-		try{
90
+		try {
91 91
 			$name = $this->dbUser;
92 92
 			$password = $this->dbPassword;
93 93
 			// we need to create 2 accounts, one for global use and one for local user. if we don't specify the local one,
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			$query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'";
98 98
 			$connection->executeUpdate($query);
99 99
 		}
100
-		catch (\Exception $ex){
100
+		catch (\Exception $ex) {
101 101
 			$this->logger->error('Database User creation failed: {error}', [
102 102
                                 'app' => 'mysql.setup',
103 103
                                 'error' => $ex->getMessage()
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			//we don't have a dbuser specified in config
119 119
 			if ($this->dbUser !== $oldUser) {
120 120
 				//add prefix to the admin username to prevent collisions
121
-				$adminUser = substr('oc_' . $username, 0, 16);
121
+				$adminUser = substr('oc_'.$username, 0, 16);
122 122
 
123 123
 				$i = 1;
124 124
 				while (true) {
@@ -135,15 +135,15 @@  discard block
 block discarded – undo
135 135
 							$this->dbUser = $adminUser;
136 136
 
137 137
 							//create a random password so we don't need to store the admin password in the config file
138
-							$this->dbPassword =  $this->random->generate(30);
138
+							$this->dbPassword = $this->random->generate(30);
139 139
 
140 140
 							$this->createDBUser($connection);
141 141
 
142 142
 							break;
143 143
 						} else {
144 144
 							//repeat with different username
145
-							$length = strlen((string)$i);
146
-							$adminUser = substr('oc_' . $username, 0, 16 - $length) . $i;
145
+							$length = strlen((string) $i);
146
+							$adminUser = substr('oc_'.$username, 0, 16 - $length).$i;
147 147
 							$i++;
148 148
 						}
149 149
 					} else {
Please login to merge, or discard this patch.
lib/private/PreviewManager.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 		}
245 245
 
246 246
 		$mount = $file->getMountPoint();
247
-		if ($mount and !$mount->getOption('previews', true)){
247
+		if ($mount and !$mount->getOption('previews', true)) {
248 248
 			return false;
249 249
 		}
250 250
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 */
331 331
 	protected function registerCoreProvider($class, $mimeType, $options = []) {
332 332
 		if (in_array(trim($class, '\\'), $this->getEnabledDefaultProvider())) {
333
-			$this->registerProvider($mimeType, function () use ($class, $options) {
333
+			$this->registerProvider($mimeType, function() use ($class, $options) {
334 334
 				return new $class($options);
335 335
 			});
336 336
 		}
Please login to merge, or discard this patch.
lib/private/Encryption/Update.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 			if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') {
88 88
 				$path = Filesystem::getPath($params['fileSource']);
89 89
 				list($owner, $ownerPath) = $this->getOwnerPath($path);
90
-				$absPath = '/' . $owner . '/files/' . $ownerPath;
90
+				$absPath = '/'.$owner.'/files/'.$ownerPath;
91 91
 				$this->update($absPath);
92 92
 			}
93 93
 		}
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 			if ($params['itemType'] === 'file' || $params['itemType'] === 'folder') {
104 104
 				$path = Filesystem::getPath($params['fileSource']);
105 105
 				list($owner, $ownerPath) = $this->getOwnerPath($path);
106
-				$absPath = '/' . $owner . '/files/' . $ownerPath;
106
+				$absPath = '/'.$owner.'/files/'.$ownerPath;
107 107
 				$this->update($absPath);
108 108
 			}
109 109
 		}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	public function postRestore($params) {
119 119
 		if ($this->encryptionManager->isEnabled()) {
120
-			$path = Filesystem::normalizePath('/' . $this->uid . '/files/' . $params['filePath']);
120
+			$path = Filesystem::normalizePath('/'.$this->uid.'/files/'.$params['filePath']);
121 121
 			$this->update($path);
122 122
 		}
123 123
 	}
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
 	public function postRename($params) {
132 132
 		$source = $params['oldpath'];
133 133
 		$target = $params['newpath'];
134
-		if(
134
+		if (
135 135
 			$this->encryptionManager->isEnabled() &&
136 136
 			dirname($source) !== dirname($target)
137 137
 		) {
138 138
 				list($owner, $ownerPath) = $this->getOwnerPath($target);
139
-				$absPath = '/' . $owner . '/files/' . $ownerPath;
139
+				$absPath = '/'.$owner.'/files/'.$ownerPath;
140 140
 				$this->update($absPath);
141 141
 		}
142 142
 	}
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 	protected function getOwnerPath($path) {
152 152
 		$info = Filesystem::getFileInfo($path);
153 153
 		$owner = Filesystem::getOwner($path);
154
-		$view = new View('/' . $owner . '/files');
154
+		$view = new View('/'.$owner.'/files');
155 155
 		$path = $view->getPath($info->getId());
156 156
 		if ($path === null) {
157
-			throw new \InvalidArgumentException('No file found for ' . $info->getId());
157
+			throw new \InvalidArgumentException('No file found for '.$info->getId());
158 158
 		}
159 159
 
160 160
 		return array($owner, $path);
Please login to merge, or discard this patch.
lib/private/Encryption/Exceptions/ModuleAlreadyExistsException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
 	 * @param string $name
33 33
 	 */
34 34
 	public function __construct($id, $name) {
35
-		parent::__construct('Id "' . $id . '" already used by encryption module "' . $name . '"');
35
+		parent::__construct('Id "'.$id.'" already used by encryption module "'.$name.'"');
36 36
 	}
37 37
 
38 38
 }
Please login to merge, or discard this patch.