TypeError: Drupal\Core\Form\FormState::setRedirectUrl(): Argument #1 ($url) must be of type Drupal\Core\Url, null given

Created on 14 November 2023, about 1 year ago

Problem/Motivation

TypeError: Drupal\Core\Form\FormState::setRedirectUrl(): Argument #1 ($url) must be of type Drupal\Core\Url, null given, called in C:\wamp64\www\my_learning_site\web\modules\Contrib\customerror\customerror.module on line 101 in Drupal\Core\Form\FormState->setRedirectUrl() (line 1034 of core\lib\Drupal\Core\Form\FormState.php).

Steps to reproduce

step 1. install Customerror module and enable it.
step 2. Try to login

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇳India viren18febS

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @viren18febS
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India viren18febS

    I have fixed the issues and added a patch. please review

  • Issue was unassigned.
  • 🇳🇴Norway gisle Norway

    We need someone else to review the patch.

  • 🇮🇳India shalini_jha

    hi @gisle
    I have tested the patch and it's working fine for me.
    I am able to log in after enabling this module with this patch.

  • 🇳🇴Norway gisle Norway

    The patch works, put it is still not correct.

    The statement:

    $request->request->has('destination')
    

    returns a boolean value (i.e. true or false). The patch tests whether this is value is !empty (which in PHP happens to be equivalent to true). However, doing so obfuscates the logic. We just want to check if this boolean value is true.

    I've created a MR with the correct logic.

  • @gisle opened merge request.
  • Status changed to Fixed about 1 year ago
  • 🇳🇴Norway gisle Norway

    Merged. Pipelines fail for unrelated causes.,

Production build 0.71.5 2024