Skip to content
Permalink
Browse files

Fix connection aliasing.

Revert 1162121 Which caused non-default
connections to be incorrectly aliased.

I've also updated the alias() doc blocks to make the parameter names
a bit clearer and hopefully reduce confusion later. The original
FriendsOfCake/Crud issue sounded like the reporter was missing
a `test_alpha` connection.

Refs #8319
  • Loading branch information...
markstory committed Mar 6, 2016
1 parent c4873c8 commit cd1257bde64baf448a40863ebcf56a78df7370bb
Showing with 7 additions and 7 deletions.
  1. +6 −6 src/Datasource/ConnectionManager.php
  2. +1 −1 src/TestSuite/Fixture/FixtureManager.php
@@ -134,20 +134,20 @@ public static function parseDsn($config = null)
*
* You can remove aliases with ConnectionManager::dropAlias().
*
* @param string $from The connection to add an alias to.
* @param string $to The alias to create. $from should return when loaded with get().
* @param string $original The connection to add an alias to.
* @param string $target The alias to create. Fetching $original will return $target when loaded with get().
* @return void
* @throws \Cake\Datasource\Exception\MissingDatasourceConfigException When aliasing a
* connection that does not exist.
*/
public static function alias($from, $to)
public static function alias($original, $target)
{
if (empty(static::$_config[$to]) && empty(static::$_config[$from])) {
if (empty(static::$_config[$target]) && empty(static::$_config[$original])) {
throw new MissingDatasourceConfigException(
sprintf('Cannot create alias of "%s" as it does not exist.', $from)
sprintf('Cannot create alias of "%s" as it does not exist.', $original)
);
}
static::$_aliasMap[$to] = $from;
static::$_aliasMap[$target] = $original;
}
/**
@@ -133,7 +133,7 @@ protected function _aliasConnections()
continue;
}
if (strpos($connection, 'test_') === 0) {
$map[substr($connection, 5)] = $connection;
$map[$connection] = substr($connection, 5);
} else {
$map['test_' . $connection] = $connection;
}

0 comments on commit cd1257b

Please sign in to comment.
You can’t perform that action at this time.