Problem/Motivation

when custom a event setBypass to false. it not work.
The reason for this problem is:

  1. When the first event sets byPass to true
  2. $this->bypass in the second event will always be true
$this->bypass = !empty($bypass) ? TRUE : $this->bypass;

So here it will be true anyway

Steps to reproduce

custom a event.

namespace Drupal\mymodule\EventSubscriber;

use Drupal\session_limit\Event\SessionLimitBypassEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class SessionLimitBypass  implements EventSubscriberInterface {

  public function onSessionLimitBypass(SessionLimitBypassEvent $event) {
    $event->setBypass(false);
    var_dump($event->shouldBypass());
    exit();
  }
  public static function getSubscribedEvents()
  {
    $events['session_limit.bypass'][] = ['onSessionLimitBypass', -1000];
    return $events;
  }
}

this output TRUE

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
fix_cant_set_bypass_to_false.patch605 bytesxiukun.zhou
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xiukun.zhou created an issue. See original summary.

xiukun.zhou’s picture

Issue summary: View changes
xiukun.zhou’s picture

Issue summary: View changes