Removing model id assignment form passedArgs, as it causes unexpected results. Closes #536

This commit is contained in:
Jose Lorenzo Rodriguez 2011-04-26 21:30:12 -04:30
parent c4c35f2539
commit 3433d123d4
2 changed files with 1 additions and 15 deletions

View file

@ -495,15 +495,9 @@ class Controller extends Object {
$this->Components->init($this);
if ($this->uses !== null || ($this->uses !== array())) {
if (empty($this->passedArgs) || !isset($this->passedArgs['0'])) {
$id = false;
} else {
$id = $this->passedArgs['0'];
}
$plugin = $this->plugin ? $this->plugin . '.' : null;
if ($this->uses === false) {
$this->loadModel($plugin . $this->modelClass, $id);
$this->loadModel($plugin . $this->modelClass);
} elseif ($this->uses) {
$uses = is_array($this->uses) ? $this->uses : array($this->uses);
list($plugin, $modelClassName) = pluginSplit($uses[0]);

View file

@ -470,16 +470,8 @@ class ControllerTest extends CakeTestCase {
$request = new CakeRequest('controller_posts/index');
$Controller = new Controller($request);
$Controller->modelClass = 'ControllerPost';
$Controller->passedArgs[] = '1';
$Controller->constructClasses();
$this->assertEqual($Controller->ControllerPost->id, 1);
unset($Controller);
$Controller = new Controller($request);
$Controller->uses = array('ControllerPost', 'ControllerComment');
$Controller->passedArgs[] = '1';
$Controller->constructClasses();
$this->assertTrue(is_a($Controller->ControllerPost, 'ControllerPost'));
$this->assertTrue(is_a($Controller->ControllerComment, 'ControllerComment'));