Project

General

Profile

Actions

Bug #83392

closed

Flashmessage won't work correctly with $this->redirect in a controllerAction

Added by Dieter Porth almost 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Should have
Category:
-
Target version:
-
Start date:
2017-12-20
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.1
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I got the following problem.
@
if ( ... ) {
...
$this->addFlashMessage(
LocalizationUtility::translate(
'flash.ad.checkCompany.missingData.message',
'project'
) . "\n" . $error,
LocalizationUtility::translate(
'flash.ad.checkCompany.missingData.title',
'project'
),

AbstractMessage::ERROR,
false
);
// the following line will not trigger a flashmessage
// $this->redirect(null, null, null, ['err' => 'ad'], $this->settings['pids']['profileCompany']);
//
$this->redirect('edit', 'Company', null, ['err' => 'ad'], $this->settings['pids']['profileCompany']);
}
@
Actions #1

Updated by Dieter Porth almost 7 years ago

Sorry. Misclick.
here the full code
@

if ( ... ) {
$this->addFlashMessage(
LocalizationUtility::translate(
'flash.ad.checkCompany.missingData.message',
'project'
) . "\n" . $error,
LocalizationUtility::translate(
'flash.ad.checkCompany.missingData.title',
'project'
),
AbstractMessage::ERROR,
false
);
// This won't show flashmessages
// $this->redirect(null, null, null, ['err' => 'ad'], $this->settings['pids']['profileCompany']);
//
$this->redirect('edit', 'Company', null, ['err' => 'ad'], $this->settings['pids']['profileCompany']);
}
@
Actions #2

Updated by Stephan Großberndt almost 7 years ago

  • Status changed from New to Closed
  • Assignee set to Stephan Großberndt

If you add a FlashMessage with the last parameter being FALSE you define that message not to be stored in session. When the request ends, it is discarded. As redirect starts a new request there is no message to display. Either set the last parameter to TRUE or use forward instead of redirect.

Please use the channel #typo3-cms on Slack or StackOverflow to ask questions about your implementations, this is the core bugtracker for actual bugs in TYPO3 core.

Actions #3

Updated by Susanne Moog almost 7 years ago

  • Description updated (diff)
Actions #4

Updated by Dieter Porth almost 7 years ago

The redirect in the comment won't show the flashmessage. That works correct and I have had a wrong idea.
But the current 'redirect' in the uncommented line shows the flashmessage. I think, the second line with the redirect is a bug.

P.S.
Thanks for your tipp on slack. I don't use activly slack or other chat-programm for everyday communication, because that tools are too chaotic and needs too much attention of mine.

Actions

Also available in: Atom PDF