Problem/Motivation

The yearly report page accepts a user query parameter. If the parameter points to a user ID that does not exist, the controller stores NULL in the users list and later calls id() on NULL.

Error: Call to a member function id() on null in Drupal\labor_time_tracker\Controller\TimeLogReportController->report() (line 89 of /var/www/html/lib/web/modules/contrib/labor_time_tracker/src/Controller/TimeLogReportController.php).

Steps to reproduce

1. Install and enable labor_time_tracker.
2. Log in as a user with the "view labor times" permission.
3. Visit: /admin/config/labor-time/log-report?user=999999
Use any numeric user ID that does not exist on the site.

Proposed resolution

Validate the loaded account before adding it to the $users array. For example:
- If a user filter is present and no account is loaded, show an empty report or a warning message.
- Filter NULL values before iterating.
- Consider validating the filter form input before redirecting/submitting.

Comments

dkmishra created an issue. See original summary.

  • f55c306d committed on 1.0.x
    Fix: #3611286 - protect non-existing user in filters on query parameter...
tiagoz’s picture

Assigned: Unassigned » tiagoz
Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

dkmishra’s picture

Hi @tiagoz,

Thanks for fixing this issue.

I noticed that I wasn't granted issue credit. Since I originally reported the issue and proposed the resolution, would you mind adding issue credit for my contribution if you feel it's appropriate?

Thanks!

tiagoz’s picture

Of course @dkmishra ! Thanks for finding the issue.

tiagoz’s picture

Status: Fixed » Closed (fixed)