mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Removing model id assignment form passedArgs, as it causes unexpected results. Closes #536
This commit is contained in:
parent
c4c35f2539
commit
3433d123d4
2 changed files with 1 additions and 15 deletions
|
@ -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]);
|
||||
|
|
|
@ -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'));
|
||||
|
|
Loading…
Reference in a new issue