Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
when custom a event setBypass to false. it not work.
The reason for this problem is:
- When the first event sets byPass to true
- $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
Comment | File | Size | Author |
---|---|---|---|
fix_cant_set_bypass_to_false.patch | 605 bytes | xiukun.zhou | |
Comments
Comment #2
xiukun.zhou CreditAttribution: xiukun.zhou at DAVYIN Internet Solutions / 戴文信息科技有限公司 commentedComment #3
xiukun.zhou CreditAttribution: xiukun.zhou at DAVYIN Internet Solutions / 戴文信息科技有限公司 commented