PHP Warning when no role settings saved.

Created on 3 May 2022, about 2 years ago
Updated 17 October 2023, 9 months ago

Warning: Trying to access array offset on value of type null in Drupal\user_redirect\UserRedirect->prepareDestination() (line 83 of modules/contrib/user_redirect/src/UserRedirect.php).

Please add a check if "$config[$role]" is set.

πŸ› Bug report
Status

RTBC

Version

2.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany pebosi

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.

  • πŸ‡―πŸ‡΅Japan tyler36 Osaka

    Confirmed fix on Drupal 10.1.

    ## Test

    1. Install "user_redirect"
    1. Enable module via drush: drush en user_redirect
    1. Log in as administror, error appears

    1. Logout
    1. Install patch MR!2
    1. Log in as administrator, error no longer displays.
    1. Disabling patch causes error to re-appear.

  • πŸ‡³πŸ‡¬Nigeria chike Nigeria

    I had a redirect set for 'Login' and none set for 'Logout' then I tried logging out and got this error,

    ArgumentCountError: Too few arguments to function Drupal\user_redirect\UserRedirect::__construct(), 3 passed in /home/public_html/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 and exactly 6 expected in Drupal\user_redirect\UserRedirect->__construct() (line 80 of /home/public_html/modules/contrib/user_redirect/src/UserRedirect.php).

    I applied this patch and the error was solved.

  • Thanks very much for the patch and the module. I am getting the following PHP warnings after login as admin from /user/login. I tried the fixes and it seems to work on core 10.1.5.

    Warning: Undefined array key "authenticated" in Drupal\user_redirect\UserRedirect->prepareDestination() (line 83 of /code/web/modules/contrib/user_redirect/src/UserRedirect.php)
    Warning: Trying to access array offset on value of type null in Drupal\user_redirect\UserRedirect->prepareDestination() (line 83 of /code/web/modules/contrib/user_redirect/src/UserRedirect.php)

    I created a patch on 2.0.0 to see if this patch can be applied properly since composer doesn't see 2.0.x which has the fixes.

    Problem 1
    - Root composer.json requires drupal/user_redirect default, found drupal/user_redirect[dev-1.0.x, 1.0.0, 1.0.1, 1.0.2, 1.0.x-dev (alias of dev-1.0.x), 2.0.0] but it does not match the constraint.

Production build 0.69.0 2024