RequestHandlerComponent::beforeRedirect() is deprecated

Hello,
my method add, is returning a deprecation warning:

Deprecated (16384): RequestHandlerComponent::beforeRedirect() is deprecated. This functionality will be removed in 4.0.0. Set the enableBeforeRedirect option to false to disable this warning. - C:\wamp64\www\planning\vendor\cakephp\cakephp\src\Event\EventManager.php, line: 353 [CORE\src\Core\functions.php, line 305]

Warning (512): Unable to emit headers. Headers sent in file=C:\wamp64\www\planning\vendor\cakephp\cakephp\src\Error\Debugger.php line=853 [CORE\src\Http\ResponseEmitter.php, line 48]

Warning (2): Cannot modify header information - headers already sent by (output started at C:\wamp64\www\planning\vendor\cakephp\cakephp\src\Error\Debugger.php:853) [CORE\src\Http\ResponseEmitter.php, line 148]

Warning (2): Cannot modify header information - headers already sent by (output started at C:\wamp64\www\planning\vendor\cakephp\cakephp\src\Error\Debugger.php:853) [CORE\src\Http\ResponseEmitter.php, line 181]

Warning (2): Cannot modify header information - headers already sent by (output started at C:\wamp64\www\planning\vendor\cakephp\cakephp\src\Error\Debugger.php:853) [CORE\src\Http\ResponseEmitter.php, line 181]

Warning (2): Cannot modify header information - headers already sent by (output started at C:\wamp64\www\planning\vendor\cakephp\cakephp\src\Error\Debugger.php:853) [CORE\src\Http\ResponseEmitter.php, line 181]

code:
I used the bake generator
/**

  • Add method

  • @return \Cake\Http\Response|null Redirects on successful add, renders view otherwise.
    */
    public function add()
    {
    $planning = $this->Plannings->newEntity();
    if ($this->request->is(‘post’)) {
    $planning = $this->Plannings->patchEntity($planning, $this->request->getData());
    if ($this->Plannings->save($planning)) {
    $this->Flash->success(__(‘The planning has been saved.’));

         return $this->redirect(['action' => 'index']);
     }
     $this->Flash->error(__('The planning could not be saved. Please, try again.'));
    

    }
    $this->set(compact(‘planning’));
    }

AppController.php

$this->loadComponent('RequestHandler', [
    'enableBeforeRedirect' => false
]);
1 Like