Bug #67274
closedinitializeObject() called before dependency injection
100%
Description
Given typical extbase controller actions:
public function listAction() { $records = $this->modelRepository->findAll(); $this->view->assign('records', $records); } public function showAction(Model $model) { $this->view->assign('model', $model); }
The method initializeObject() on the Models is called before the dependency injection has been performed. According to http://wiki.typo3.org/Dependency_Injection#initializeObject.28.29_as_object_lifecycle_method `initializeObject()` is called after DI has been done.
Tested on 6.2.12
Updated by Morton Jonuschat over 9 years ago
On 6.2.13-dev initializeObject() is not being called anymore - see #67272.
Seems to be related to the Doctrine Migrator changes.
Updated by Gerrit Code Review over 9 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39914
Updated by Gerrit Code Review over 9 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39914
Updated by Gerrit Code Review over 9 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39914
Updated by Xavier Perseguers over 9 years ago
- Target version set to 6.2.13
- Sprint Focus set to Stabilization Sprint
Updated by Gerrit Code Review over 9 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39914
Updated by Morton Jonuschat over 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset ec4f49f69fe8478e9c67ae56d9108a46fce9693e.
Updated by Gerrit Code Review over 9 years ago
- Status changed from Resolved to Under Review
Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/40056
Updated by Helmut Hummel over 9 years ago
- Status changed from Under Review to Needs Feedback
Morton Jonuschat wrote:
On 6.2.13-dev initializeObject() is not being called anymore - see #67272.
Seems to be related to the Doctrine Migrator changes.
If you tested that on 6.2.12, how can this be related to Doctrine Instantiator changes? These were not included in that release.
Can be please be very clear about that? Your issue is present before the Doctrine instatiator change, right?
Updated by Helmut Hummel over 9 years ago
Helmut Hummel wrote:
Morton Jonuschat wrote:
On 6.2.13-dev initializeObject() is not being called anymore - see #67272.
Seems to be related to the Doctrine Migrator changes.If you tested that on 6.2.12, how can this be related to Doctrine Instantiator changes? These were not included in that release.
Can be please be very clear about that? Your issue is present before the Doctrine instatiator change, right?
This very bug has nothing to do with the Doctrine instatiator change. Even before the initializeObject was called in __wakeup of domain objects and DI was done after that (since very long already)
Updated by Morton Jonuschat over 9 years ago
To be very clear:
Given the following Class:
class Event extends AbstractEntity { /** * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; */ protected $configurationManager; /** * inject the configurationManager * * @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager * @return void */ public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager) { print "<pre>injectConfigurationManager</pre>"; $this->configurationManager = $configurationManager; } /** * Tasks to perform on object initialization * * @return void */ public function initializeObject() { print "<pre>initializeObject</pre>"; $this->settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS); } }
On 6.2.12
Output:
initializeObject
followed by a PHP Fatal error since $this->configurationManager has not been injected yet
This is what THIS bug report was about
On 6.2.13-dev
I'd get the following Output:
initializeObject
Later on $this->settings would be empty since initializeObject() has not been called at all.
The comment you quoted is related to the observation that there is a different bug on 6.2.13-dev that skips initializeObject() alltogether - #67272
I was asked to verify this against 6.2.13-dev on Slack to see if the switch to Doctrine Instantiator fixed it.
Updated by Morton Jonuschat over 9 years ago
Sorry, on 6.2.13-dev the output was
injectConfigurationManager
Dumb copy&paste error
Updated by Alexander Opitz over 9 years ago
- Target version changed from 6.2.13 to 6.2.14
After Reverting DI in 6.2.13, is this issue still valid?
Updated by Morton Jonuschat over 9 years ago
Yes, this issue ist still valid as nothing has changed in 6.2.13 in this regard (The switch to doctrine instantiator has been reverted, so initializeObject() is being called in __wakeup() which happens before the dependency injection).
Updated by Alexander Opitz over 9 years ago
- Status changed from Needs Feedback to New
Updated by Christian Kuhn over 9 years ago
- Status changed from New to Resolved
the issue is fixed in master and will not be fixed / changed in 6.2
Updated by Riccardo De Contardi about 7 years ago
- Status changed from Resolved to Closed