Browse Source

Standardize on setting 'username' and 'password' keys

CakePHP users a variety of names for these keys internally, though the most widely recognized are the above, so it makes sense to standardize on them.

Note that we remove the `user` and `pass` key from the $parsed config instead of the $config as it is possible to have them in a querystring argument.
Jose Diaz-Gonzalez 11 years ago
parent
commit
393e69efef

+ 9 - 0
src/Core/StaticConfigTrait.php

@@ -180,6 +180,15 @@ trait StaticConfigTrait {
 			$queryArgs['driver'] = $driver;
 		}
 
+		if (isset($parsed['user'])) {
+			$parsed['username'] = $parsed['user'];
+		}
+
+		if (isset($parsed['pass'])) {
+			$parsed['password'] = $parsed['pass'];
+		}
+
+		unset($config['user'], $config['pass']);
 		$config = array_merge($queryArgs, $parsed, $config);
 
 		foreach ($config as $key => $value) {

+ 1 - 9
src/Datasource/ConnectionManager.php

@@ -86,19 +86,11 @@ class ConnectionManager {
 	public static function parseDsn($config = null) {
 		$config = static::_parseDsn($config);
 
-		if (isset($config['user'])) {
-			$config['login'] = $config['user'];
-		}
-
-		if (isset($config['pass'])) {
-			$config['password'] = $config['pass'];
-		}
-
 		if (isset($config['path'])) {
 			$config['database'] = substr($config['path'], 1);
 		}
 
-		unset($config['path'], $config['user'], $config['pass']);
+		unset($config['path']);
 		return $config;
 	}
 

+ 1 - 9
src/Network/Email/Email.php

@@ -1217,15 +1217,7 @@ class Email {
 			$config['className'] = $config['scheme'];
 		}
 
-		if (isset($config['user'])) {
-			$config['username'] = $config['user'];
-		}
-
-		if (isset($config['pass'])) {
-			$config['password'] = $config['pass'];
-		}
-
-		unset($config['scheme'], $config['user'], $config['pass']);
+		unset($config['scheme']);
 		return $config;
 	}