Bug #2580

Crash in MVC-Controller

Added by Malte Jansen over 12 years ago. Updated almost 11 years ago.

Status:
Resolved
Priority:
Must have
Assignee:
-
Category:
MVC
Target version:
-
Start date:
2009-02-05
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
Complexity:

Description

The function initializeAction() of the ActionController does not have the access to the to $this->view, because the first the function is called the view is not initilized.

The function is called twice
1. while creating the object (after the injections) --> $this->view is empty
2. while callActionMethod() --> the view is initialized

Expected result:
The view is available in initializeAction().

Solution:
Rename initializeAction() to preAction().

Perhaps some postAction() would also be pretty useful.

#1

Updated by Karsten Dambekalns over 12 years ago

The first call should be to initializeObject(), it is supposed to be called right after any injections have been done...

My gut feeling tells me that in initializeAction() the view should be available, indeed.

#2

Updated by Malte Jansen over 12 years ago

Have I read it later.

Perhaps there just must be two lines switched...

ActionController:


protected function callActionMethod() {
$actionMethodName = $this->request->getControllerActionName() . 'Action';
if (!method_exists($this, $actionMethodName)) throw new \F3\FLOW3\MVC\Exception\NoSuchAction('An action "' . $this->request->getControllerActionName() . '" does not exist in controller "' . get_class($this) . '".', 1186669086);
$this->initializeAction();
if ($this->initializeView) $this->initializeView();
$actionResult = call_user_func_array(array($this, $actionMethodName), array());
if (is_string($actionResult) && strlen($actionResult) > 0) {
$this->response->appendContent($actionResult);
}
}

Just call the initializeView() before initializeAction().

Haven't check it, but if the view is not init, than it should not be available in the initAction...

#3

Updated by Malte Jansen over 12 years ago

By the way in the AbstractController the function initializeArguments() should be protected like all others init-functions.

#4

Updated by Robert Lemke over 12 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Applied in changeset r1884.

Also available in: Atom PDF