Browse Source

Fix connection aliasing.

Revert 1162121f1e8b8d0f1df0fb65ddf8ace5af8693d0 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
Mark Story 10 years ago
parent
commit
cd1257bde6
2 changed files with 7 additions and 7 deletions
  1. 6 6
      src/Datasource/ConnectionManager.php
  2. 1 1
      src/TestSuite/Fixture/FixtureManager.php

+ 6 - 6
src/Datasource/ConnectionManager.php

@@ -134,20 +134,20 @@ class ConnectionManager
      *
      * 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;
     }
 
     /**

+ 1 - 1
src/TestSuite/Fixture/FixtureManager.php

@@ -133,7 +133,7 @@ class FixtureManager
                 continue;
             }
             if (strpos($connection, 'test_') === 0) {
-                $map[substr($connection, 5)] = $connection;
+                $map[$connection] = substr($connection, 5);
             } else {
                 $map['test_' . $connection] = $connection;
             }