diff --git a/lib/Cake/Console/Command/Task/PluginTask.php b/lib/Cake/Console/Command/Task/PluginTask.php index b5f9c2cbe42..834c85fabc1 100644 --- a/lib/Cake/Console/Command/Task/PluginTask.php +++ b/lib/Cake/Console/Command/Task/PluginTask.php @@ -191,9 +191,11 @@ public function findPath($pathOptions) { $valid = false; foreach ($pathOptions as $i => $path) { if (!is_dir($path)) { - array_splice($pathOptions, $i, 1); + unset($pathOptions[$i]); } } + $pathOptions = array_values($pathOptions); + $max = count($pathOptions); while (!$valid) { foreach ($pathOptions as $i => $option) { diff --git a/lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php index 1d2065db516..2bf983e5f2d 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php @@ -185,7 +185,9 @@ public function testExecuteWithOneArg() { public function testFindPathNonExistant() { $paths = App::path('plugins'); $last = count($paths); - $paths[] = '/fake/path'; + + array_unshift($paths, '/fake/path'); + $paths[] = '/fake/path2'; $this->Task = $this->getMock('PluginTask', array('in', 'out', 'err', 'createFile', '_stop'),