Error: Call to a member function getRouteName() on bool

Created on 29 November 2021, almost 3 years ago
Updated 21 June 2023, over 1 year ago

Problem/Motivation

The following line in opigno_dashboard.module can cause logins to fail:

$default_route = \Drupal::pathValidator()->getUrlIfValid($default_path)->getRouteName();

getUrlIfValid() can return a FALSE if path is missing (e.g. disabled, unpublished, etc.), which can cause getRouteName() to fail. This line is in a login form submit hook. When this code throws an exception, it can prevent logins.

Steps to reproduce

1. Change the path of views.frontpage.page_1 (the front page view) to something else (e.g. /dashboard).
- Optionally, move all Opigno dashboard blocks in Block Layout to that new path.
2. Create a node page or a page_manager page.
3. Set the site homepage to the page created in step 2.
4. Log in and log out like normal.
5. Disable/unpublish the page created in step 2.
6. Try logging in.

Step 6 will throw an error:

Error: Call to a member function getRouteName() on bool in opigno_dashboard_user_login_submit() (line 277 of /var/app/current/web/modules/contrib/opigno_dashboard/opigno_dashboard.module)

Proposed resolution

Apply attached patch.

Remaining tasks

Review and test.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States fskreuz

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024