Skip to content

Commit

Permalink
Fix connection aliasing.
Browse files Browse the repository at this point in the history
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 cd1257b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/Datasource/ConnectionManager.php
Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/TestSuite/Fixture/FixtureManager.php
Expand Up @@ -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;
}
Expand Down

0 comments on commit cd1257b

Please sign in to comment.