Bug #2580

Crash in MVC-Controller

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

Must have
Target version:
Start date:
Due date:
% Done:


Estimated time:
PHP Version:
Has patch:


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().

Rename initializeAction() to preAction().

Perhaps some postAction() would also be pretty useful.


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.


Updated by Malte Jansen over 12 years ago

Have I read it later.

Perhaps there just must be two lines switched...


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);
if ($this->initializeView) $this->initializeView();
$actionResult = call_user_func_array(array($this, $actionMethodName), array());
if (is_string($actionResult) && strlen($actionResult) > 0) {

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...


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.


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