Skip to content

Commit

Permalink
Removing model id assignment form passedArgs, as it causes unexpected…
Browse files Browse the repository at this point in the history
… results. Closes #536
  • Loading branch information
lorenzo committed Apr 27, 2011
1 parent c4c35f2 commit 3433d12
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
8 changes: 1 addition & 7 deletions lib/Cake/Controller/Controller.php
Expand Up @@ -495,15 +495,9 @@ public function constructClasses() {
$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]);
Expand Down
8 changes: 0 additions & 8 deletions lib/Cake/tests/Case/Controller/ControllerTest.php
Expand Up @@ -470,16 +470,8 @@ function testConstructClasses() {
$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'));
Expand Down

0 comments on commit 3433d12

Please sign in to comment.