Project

General

Profile

Actions

Bug #77651

closed

Having an initializeAction() changes the order in which TSFE->page is accessible leading to very hard debugable behaviour.

Added by S P about 8 years ago. Updated almost 8 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2016-08-29
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

In an Extbase extension I have a Controller with some actions. In some of these actions I change $GLOBALS['TSFE']->page (for example the title) - this works perfectly well up to the point where I add an initializeAction (empty or not, doesn't matter) to the controller. In this case the actual action can not access fields of $GLOBALS['TSFE']->page! Instead it will be created and hence never correctly populated by the core.

public function initializeAction() {
   // having or not having this empty function changes the behaviour of $this->showAction() wrt. $GLOBALS['TSFE']->page.
}

public function showAction() {
    $GLOBALS['TSFE']->page['title'] = 'foo';

    var_dump($GLOBALS['TSFE']->page);
    // with initializeAction it will only have the title set and will never be filled.
    // without initializeAction it will be filled first and then altered
}

I discovered this in TYPO3 7.6, it is possibly already in 6.2.

Actions #1

Updated by Claus Due about 8 years ago

  • Status changed from New to Needs Feedback

Shot from the hip: you subclass something other than ActionController and that class contains an `initializeAction` method and you neglect calling `parent::initializeAction` in your own overridden method. Although it isn't exactly easy to debug, it is completely expected behavior and always something you need to watch out for yourself when you override methods.

Having an `initializeAction` only ever changes the logic of the controller if you are subclassing a class other than `ActionController` and the parent class has logic in the `initializeAction` method and you DO NOT call `parent::initializeAction`. So I assume this is what is happening in your case, and I also assume that in the parent controller class, `initializeAction` is responsible for filling out the page object or recreates that object somehow. You can fix this by either calling `parent::initializeAction` before you do anything in your own `initializeAction` - or you can do the more gentle thing and rename your `initializeAction` method to `initiaizeShowAction` and have it only execute when you call that specific action, and only after `initializeAction` is performed.

If this answers your problem please close the issue. If it does not, we need more information such as which controller you subclass, how you render the action (plugin? TS object? USER or USER_INT?). But I half expect that it does indeed solve your problem.

Actions #2

Updated by Riccardo De Contardi almost 8 years ago

  • Status changed from Needs Feedback to Closed

90 days without feedback > closing.

If you think that this is the wrong decision or have more information about how to reproduce it, please reopen it or open a new issue with a reference to this one.

Thank you

Actions

Also available in: Atom PDF