Hello! I'm always getting a log message about undefined user variable inside "src/ShieldMiddleware.php" file (line 79). I created a patch to solve this.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

devandrew created an issue. See original summary.

andpet’s picture

andpet’s picture

Status: Active » Needs review
geek-merlin’s picture

Status: Needs review » Needs work

Thanks for reporting this! Yes code says this can happen. Alas, this patch will leave notices.
Fix this by guaranteeing $user is set also in the switch case 'multikey' code path.

mmenavas’s picture

I apologize I can't create a patch right now, but initializing `$user` before the switch statement has worked for me:

  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
    $config = $this->configFactory->get('shield.settings');
    $allow_cli = $config->get('allow_cli');
    $user = NULL;

    switch ($config->get('credential_provider')) {
gantal’s picture

FileSize
520 bytes

Initializing $user before the `switch` block worked for me. Attaching a patch based on mmenavas's suggestion.

gantal’s picture

FileSize
523 bytes

Same patch as #6, just fixed the indentation. Whoops!

andpet’s picture

Status: Needs work » Patch (to be ported)
andpet’s picture

Yeah, works fine for me. Thanks!

andpet’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

  • axel.rutz committed 93ee979 on 8.x-1.x authored by gantal
    Issue #2990069 by gantal, kesenai, mmenavas: Notice: Undefined variable...
geek-merlin’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ccasals’s picture

Would you please add this to a stable release? Thanks!